]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/planar.c
wwww
[16.git] / src / lib / planar.c
index 8b713691d1dcd2c03921feda2558452581645909..5541217fe4fa2ac2cc76f74caaf67dbd2b4e5a5c 100755 (executable)
@@ -1,24 +1,24 @@
-/* Project 16 Source Code~
- * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
- *
- * This file is part of Project 16.
- *
- * Project 16 is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Project 16 is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
- * write to the Free Software Foundation, Inc., 51 Franklin Street,
- * Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
+ *\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Project 16 is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
+ */\r
 /*\r
  * Implimentation of the planar buffer files.\r
  */\r
  */\r
 planar_buf_t *\r
 planar_buf_from_bitmap(bitmap_t *b) {\r
-    planar_buf_t *p;\r
-    int plane, bi, pi, x, y;\r
+       planar_buf_t *p;\r
+       int plane, bi, pi, x, y;\r
 \r
-    /* allocate the buffer */\r
-    p = planar_buf_alloc(b->width, b->height);\r
+       /* allocate the buffer */\r
+       p = planar_buf_alloc(b->width, b->height);\r
 \r
-    /* copy the bitmap data into the planar format */\r
-    bi=0;\r
-    pi=0;\r
-    for(y=0; y < b->height; y++) {\r
+       /* copy the bitmap data into the planar format */\r
+       bi=0;\r
+       pi=0;\r
+       for(y=0; y < b->height; y++) {\r
        /* start on the first plane */\r
        plane=0;\r
        for(x=0; x < b->width; x++) {\r
-           /* copy to each plane */\r
-           p->plane[plane++][pi]=b->data[bi++];\r
+               /* copy to each plane */\r
+               p->plane[plane++][pi]=b->data[bi++];\r
 \r
-           /* handle the completion of 4 planes. */\r
-           if(plane==4) {\r
-               plane=0;\r
-               pi++;\r
-           }\r
+               /* handle the completion of 4 planes. */\r
+               if(plane==4) {\r
+                       plane=0;\r
+                       pi++;\r
+               }\r
        }\r
 \r
        /* correct for images not divisible by 4 */\r
        if(plane) pi++;\r
-    }\r
+       }\r
 \r
-    return p;\r
+       return p;\r
 }\r
 \r
 \r
 /* allocates a planar buffer with specified dimensions */\r
 planar_buf_t *\r
 planar_buf_alloc(word width, word height) {\r
-    planar_buf_t *p;\r
-    int i;\r
+       planar_buf_t *p;\r
+       int i;\r
 \r
-    /* allocate the structure and populate sizes */\r
-    p=malloc(sizeof(planar_buf_t));\r
-    p->width  = width;\r
-    p->height = height;\r
-    p->pwidth = width / 4 + (width%4 ? 1 : 0);\r
+       /* allocate the structure and populate sizes */\r
+       p=malloc(sizeof(planar_buf_t));\r
+       p->width  = width;\r
+       p->height = height;\r
+       p->pwidth = width / 4 + (width%4 ? 1 : 0);\r
 \r
-    /* allocate the planes */\r
-    for(i=0; i<4; i++) {\r
+       /* allocate the planes */\r
+       for(i=0; i<4; i++) {\r
        p->plane[i] = malloc(p->height * p->pwidth);\r
-    }\r
+       }\r
 \r
-    return p;\r
+       return p;\r
 }\r
 \r
 \r
 /* deallocates a planar buffer */\r
 void\r
 planar_buf_free(planar_buf_t *p) {\r
-    int i;\r
+       int i;\r
 \r
-    /* free the planes */\r
-    for(i=0; i<4; i++) {\r
+       /* free the planes */\r
+       for(i=0; i<4; i++) {\r
        free(p->plane[i]);\r
-    }\r
+       }\r
 \r
-    /* free the structure */\r
-    free(p);\r
+       /* free the structure */\r
+       free(p);\r
 }\r