X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fplanar.c;h=3fd1c5ed2b25b85ac5a5849bf9d282ea2d010cf2;hb=469a7d2fd636a0b3066d45ec641bafebefe81e7c;hp=8b713691d1dcd2c03921feda2558452581645909;hpb=d9e8696a3a67052729b1b783f0f3f1b0d20d9e9a;p=16.git
diff --git a/src/lib/planar.c b/src/lib/planar.c
old mode 100644
new mode 100755
index 8b713691..3fd1c5ed
--- a/src/lib/planar.c
+++ b/src/lib/planar.c
@@ -1,28 +1,31 @@
-/* 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 , or
- * write to the Free Software Foundation, Inc., 51 Franklin Street,
- * Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123
+ *
+ * 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 , or
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
/*
* Implimentation of the planar buffer files.
*/
+#include
#include
+#include
+
#include "src/lib/planar.h"
/* creates a planar buffer from the bitmap data.
@@ -30,70 +33,77 @@
be destroyed with the planar_buf_free function when no longer
needed.
*/
-planar_buf_t *
+planar_buf_t huge *
planar_buf_from_bitmap(bitmap_t *b) {
- planar_buf_t *p;
- int plane, bi, pi, x, y;
+ planar_buf_t *p;
+ int plane, bi, pi, x, y;
+ word q;
- /* allocate the buffer */
- p = planar_buf_alloc(b->width, b->height);
+ /* allocate the buffer */
+ p = planar_buf_alloc(b->width, b->height);
- /* copy the bitmap data into the planar format */
- bi=0;
- pi=0;
- for(y=0; y < b->height; y++) {
+ /* copy the bitmap data into the planar format */
+ bi=0;
+ pi=0;
+ for(y=0; y < b->height; y++) {
/* start on the first plane */
plane=0;
for(x=0; x < b->width; x++) {
- /* copy to each plane */
- p->plane[plane++][pi]=b->data[bi++];
-
- /* handle the completion of 4 planes. */
- if(plane==4) {
- plane=0;
- pi++;
- }
+ /* copy to each plane */
+ p->plane[plane++][pi]=b->data[bi++];
+
+ /* handle the completion of 4 planes. */
+ if(plane==4) {
+ plane=0;
+ pi++;
+ }
}
/* correct for images not divisible by 4 */
if(plane) pi++;
- }
+ }
- return p;
+ p->palette = modexNewPal();
+ for(;qpalette[q]=b->palette[q];
+ }
+
+ return p;
}
/* allocates a planar buffer with specified dimensions */
-planar_buf_t *
+planar_buf_t huge *
planar_buf_alloc(word width, word height) {
- planar_buf_t *p;
- int i;
+ planar_buf_t *p;
+ int i;
- /* allocate the structure and populate sizes */
- p=malloc(sizeof(planar_buf_t));
- p->width = width;
- p->height = height;
- p->pwidth = width / 4 + (width%4 ? 1 : 0);
+ /* allocate the structure and populate sizes */
+ p=malloc(sizeof(planar_buf_t));
+ p->width = width;
+ p->height = height;
+ p->pwidth = width / 4 + (width%4 ? 1 : 0);
- /* allocate the planes */
- for(i=0; i<4; i++) {
- p->plane[i] = malloc(p->height * p->pwidth);
- }
+ /* allocate the planes */
+ for(i=0; i<4; i++) {
+ p->plane[i] = malloc(p->height * p->pwidth);
+ }
- return p;
+ return p;
}
/* deallocates a planar buffer */
void
planar_buf_free(planar_buf_t *p) {
- int i;
+ int i;
- /* free the planes */
- for(i=0; i<4; i++) {
+ /* free the planes */
+ for(i=0; i<4; i++) {
free(p->plane[i]);
- }
+ }
- /* free the structure */
- free(p);
+ /* free the structure */
+ free(p);
}