X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fplanar.c;h=4eda45155878659bbaf5ed57309013eb37fe6a09;hb=b86d6405d4000f67776b98d6cee575d08dd736a6;hp=55f4d99ea3ca30d11946484b35b7ba985dc2d116;hpb=a6438b2f886a103d5af0bfb304afa95033ad0396;p=16.git diff --git a/src/lib/planar.c b/src/lib/planar.c index 55f4d99e..4eda4515 100755 --- a/src/lib/planar.c +++ b/src/lib/planar.c @@ -30,10 +30,11 @@ 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; + word q; /* allocate the buffer */ p = planar_buf_alloc(b->width, b->height); @@ -46,7 +47,6 @@ planar_buf_from_bitmap(bitmap_t *b) { plane=0; for(x=0; x < b->width; x++) { /* copy to each plane */ - if(!(b->data[bi])) b->data[bi] = 1; p->plane[plane++][pi]=b->data[bi++]; /* handle the completion of 4 planes. */ @@ -60,12 +60,18 @@ planar_buf_from_bitmap(bitmap_t *b) { if(plane) pi++; } + 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; @@ -98,3 +104,41 @@ planar_buf_free(planar_buf_t *p) { /* free the structure */ free(p); } + +/* non pointer version */ +planar_buf_t planar_buf_from_bitmap0(bitmap_t *b) { + planar_buf_t p; + int plane, bi, pi, x, y; + word q=0; + + /* 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++) { + /* 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++; + } + } + + /* correct for images not divisible by 4 */ + if(plane) pi++; + } + p.palette = modexNewPal(); + for(;qpalette[q]; + } + + return p; +}