From 30fd1ab523393216a66a7debb7e42ec39e40a242 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Nov 2011 20:47:19 +0000 Subject: replace ImBuf.depth with ImBuf.planes to match ImageFormatData.planes & to avoid confusion with ImageFormatData.depth --- source/blender/imbuf/IMB_imbuf_types.h | 2 +- source/blender/imbuf/intern/IMB_filter.h | 4 ++-- source/blender/imbuf/intern/allocimbuf.c | 8 ++++---- source/blender/imbuf/intern/filter.c | 20 ++++++++++---------- source/blender/imbuf/intern/imbuf_cocoa.m | 2 +- source/blender/imbuf/intern/iris.c | 6 +++--- source/blender/imbuf/intern/jp2.c | 10 +++++----- source/blender/imbuf/intern/jpeg.c | 4 ++-- source/blender/imbuf/intern/openexr/openexr_api.cpp | 8 ++++---- source/blender/imbuf/intern/png.c | 2 +- source/blender/imbuf/intern/scaling.c | 10 +++++----- source/blender/imbuf/intern/targa.c | 20 ++++++++++---------- source/blender/imbuf/intern/thumbs.c | 2 +- source/blender/imbuf/intern/tiff.c | 4 ++-- 14 files changed, 51 insertions(+), 51 deletions(-) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 59899dc7490..5ce3d63fe86 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -74,7 +74,7 @@ typedef struct ImBuf { * but this is problematic with texture math in imagetexture.c * avoid problems and use int. - campbell */ - unsigned char depth; /* Active amount of bits/bitplanes */ + unsigned char planes; /* Active amount of bits/bitplanes */ int channels; /* amount of channels in rect_float (0 = 4 channel default) */ /* flags */ diff --git a/source/blender/imbuf/intern/IMB_filter.h b/source/blender/imbuf/intern/IMB_filter.h index a9e9e0ae776..29e6c4950df 100644 --- a/source/blender/imbuf/intern/IMB_filter.h +++ b/source/blender/imbuf/intern/IMB_filter.h @@ -40,8 +40,8 @@ struct ImBuf; void imb_filterx(struct ImBuf *ibuf); -void IMB_premultiply_rect(unsigned int *rect, int depth, int w, int h); -void IMB_premultiply_rect_float(float *rect_float, int depth, int w, int h); +void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h); +void IMB_premultiply_rect_float(float *rect_float, char planes, int w, int h); void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1); diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 5bbabd84648..d08c86aacbc 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -323,7 +323,7 @@ short imb_addrectImBuf(ImBuf *ibuf) if((ibuf->rect = MEM_mapallocN(size, "imb_addrectImBuf"))) { ibuf->mall |= IB_rect; ibuf->flags |= IB_rect; - if(ibuf->depth > 32) return (addzbufImBuf(ibuf)); + if(ibuf->planes > 32) return (addzbufImBuf(ibuf)); else return TRUE; } @@ -341,7 +341,7 @@ short imb_addtilesImBuf(ImBuf *ibuf) return (ibuf->tiles != NULL); } -ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar d, unsigned int flags) +ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int flags) { ImBuf *ibuf; @@ -350,7 +350,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar d, unsigned int flag if(ibuf) { ibuf->x= x; ibuf->y= y; - ibuf->depth= d; + ibuf->planes= planes; ibuf->ftype= TGA; ibuf->channels= 4; /* float option, is set to other values when buffers get assigned */ ibuf->ppm[0]= ibuf->ppm[1]= 150.0 / 0.0254; /* 150dpi -> pixels-per-meter */ @@ -402,7 +402,7 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) y = ibuf1->y; if(ibuf1->flags & IB_fields) y *= 2; - ibuf2 = IMB_allocImBuf(x, y, ibuf1->depth, flags); + ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags); if(ibuf2 == NULL) return NULL; if(flags & IB_rect) diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 479c7ed5626..29da7973654 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -148,7 +148,7 @@ void IMB_filtery(struct ImBuf *ibuf) for (;x>0;x--){ if (point) { - if (ibuf->depth > 24) filtcolum(point,y,skip); + if (ibuf->planes > 24) filtcolum(point,y,skip); point++; filtcolum(point,y,skip); point++; @@ -158,7 +158,7 @@ void IMB_filtery(struct ImBuf *ibuf) point++; } if (pointf) { - if (ibuf->depth > 24) filtcolumf(pointf,y,skip); + if (ibuf->planes > 24) filtcolumf(pointf,y,skip); pointf++; filtcolumf(pointf,y,skip); pointf++; @@ -186,7 +186,7 @@ void imb_filterx(struct ImBuf *ibuf) for (;y>0;y--){ if (point) { - if (ibuf->depth > 24) filtrow(point,x); + if (ibuf->planes > 24) filtrow(point,x); point++; filtrow(point,x); point++; @@ -196,7 +196,7 @@ void imb_filterx(struct ImBuf *ibuf) point+=skip; } if (pointf) { - if (ibuf->depth > 24) filtrowf(pointf,x); + if (ibuf->planes > 24) filtrowf(pointf,x); pointf++; filtrowf(pointf,x); pointf++; @@ -529,12 +529,12 @@ ImBuf *IMB_getmipmap(ImBuf *ibuf, int level) return (level == 0)? ibuf: ibuf->mipmap[level-1]; } -void IMB_premultiply_rect(unsigned int *rect, int depth, int w, int h) +void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h) { char *cp; int x, y, val; - if(depth == 24) { /* put alpha at 255 */ + if(planes == 24) { /* put alpha at 255 */ cp= (char *)(rect); for(y=0; yrect) - IMB_premultiply_rect(ibuf->rect, ibuf->depth, ibuf->x, ibuf->y); + IMB_premultiply_rect(ibuf->rect, ibuf->planes, ibuf->x, ibuf->y); if(ibuf->rect_float) - IMB_premultiply_rect_float(ibuf->rect_float, ibuf->depth, ibuf->x, ibuf->y); + IMB_premultiply_rect_float(ibuf->rect_float, ibuf->planes, ibuf->x, ibuf->y); } diff --git a/source/blender/imbuf/intern/imbuf_cocoa.m b/source/blender/imbuf/intern/imbuf_cocoa.m index 7005558d753..b79b1358ec2 100644 --- a/source/blender/imbuf/intern/imbuf_cocoa.m +++ b/source/blender/imbuf/intern/imbuf_cocoa.m @@ -228,7 +228,7 @@ short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags) /* check for a valid number of bytes per pixel. Like the PNG writer, * the TIFF writer supports 1, 3 or 4 bytes per pixel, corresponding * to gray, RGB, RGBA respectively. */ - samplesperpixel = (uint16_t)((ibuf->depth + 7) >> 3); + samplesperpixel = (uint16_t)((ibuf->planes + 7) >> 3); switch (samplesperpixel) { case 4: /*RGBA type*/ hasAlpha = YES; diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index cf7337a574b..83351b5e0e4 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -320,7 +320,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) if (bpp == 1) { ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect); - if (ibuf->depth > 32) ibuf->depth = 32; + if (ibuf->planes > 32) ibuf->planes = 32; base = ibuf->rect; zbase = (unsigned int *)ibuf->zbuf; @@ -404,7 +404,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) if (bpp == 1) { ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect); - if (ibuf->depth > 32) ibuf->depth = 32; + if (ibuf->planes > 32) ibuf->planes = 32; base = ibuf->rect; zbase = (unsigned int *)ibuf->zbuf; @@ -822,7 +822,7 @@ int imb_saveiris(struct ImBuf * ibuf, const char *name, int flags) short zsize; int ret; - zsize = (ibuf->depth + 7) >> 3; + zsize = (ibuf->planes + 7) >> 3; if (flags & IB_zbuf && ibuf->zbuf != NULL) zsize = 8; IMB_convert_rgba_to_abgr(ibuf); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 151933d6651..568dd7a9fb7 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -101,7 +101,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) int index; - int w, h, depth; + int w, h, planes; opj_dparameters_t parameters; /* decompression parameters */ @@ -166,10 +166,10 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) switch (image->numcomps) { case 1: /* Greyscale */ case 3: /* Color */ - depth= 24; + planes= 24; break; default: /* 2 or 4 - Greyscale or Color + alpha */ - depth= 32; /* greyscale + alpha */ + planes= 32; /* greyscale + alpha */ break; } @@ -190,7 +190,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) float_divs[i]= (1<comps[i].prec)-1; } - ibuf= IMB_allocImBuf(w, h, depth, use_float ? IB_rectfloat : IB_rect); + ibuf= IMB_allocImBuf(w, h, planes, use_float ? IB_rectfloat : IB_rect); if (ibuf==NULL) { if(dinfo) @@ -494,7 +494,7 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) { /* 32bit images == alpha channel */ /* grayscale not supported yet */ - numcomps= (ibuf->depth==32) ? 4 : 3; + numcomps= (ibuf->planes==32) ? 4 : 3; } w= ibuf->x; diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 89038d7d1d2..5a40de0a65e 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -571,8 +571,8 @@ static int init_jpeg(FILE * outfile, struct jpeg_compress_struct * cinfo, struct cinfo->image_height = ibuf->y; cinfo->in_color_space = JCS_RGB; - if (ibuf->depth == 8) cinfo->in_color_space = JCS_GRAYSCALE; - if (ibuf->depth == 32) cinfo->in_color_space = JCS_UNKNOWN; + if (ibuf->planes == 8) cinfo->in_color_space = JCS_GRAYSCALE; + if (ibuf->planes == 32) cinfo->in_color_space = JCS_UNKNOWN; switch(cinfo->in_color_space){ case JCS_RGB: diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 1084355dd74..a5a9427ea89 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -208,7 +208,7 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags header.channels().insert ("R", Channel (HALF)); header.channels().insert ("G", Channel (HALF)); header.channels().insert ("B", Channel (HALF)); - if (ibuf->depth==32 && channels >= 4) + if (ibuf->planes==32 && channels >= 4) header.channels().insert ("A", Channel (HALF)); if (write_zbuf) // z we do as float always header.channels().insert ("Z", Channel (FLOAT)); @@ -226,7 +226,7 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags frameBuffer.insert ("R", Slice (HALF, (char *) &pixels[0].r, xstride, ystride)); frameBuffer.insert ("G", Slice (HALF, (char *) &pixels[0].g, xstride, ystride)); frameBuffer.insert ("B", Slice (HALF, (char *) &pixels[0].b, xstride, ystride)); - if (ibuf->depth==32 && channels >= 4) + if (ibuf->planes==32 && channels >= 4) frameBuffer.insert ("A", Slice (HALF, (char *) &pixels[0].a, xstride, ystride)); if (write_zbuf) frameBuffer.insert ("Z", Slice (FLOAT, (char *)(ibuf->zbuf_float + (height-1)*width), @@ -335,7 +335,7 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag header.channels().insert ("R", Channel (FLOAT)); header.channels().insert ("G", Channel (FLOAT)); header.channels().insert ("B", Channel (FLOAT)); - if (ibuf->depth==32 && channels >= 4) + if (ibuf->planes==32 && channels >= 4) header.channels().insert ("A", Channel (FLOAT)); if (write_zbuf) header.channels().insert ("Z", Channel (FLOAT)); @@ -355,7 +355,7 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag frameBuffer.insert ("R", Slice (FLOAT, (char *)rect[0], xstride, ystride)); frameBuffer.insert ("G", Slice (FLOAT, (char *)rect[1], xstride, ystride)); frameBuffer.insert ("B", Slice (FLOAT, (char *)rect[2], xstride, ystride)); - if (ibuf->depth==32 && channels >= 4) + if (ibuf->planes==32 && channels >= 4) frameBuffer.insert ("A", Slice (FLOAT, (char *)rect[3], xstride, ystride)); if (write_zbuf) frameBuffer.insert ("Z", Slice (FLOAT, (char *) (ibuf->zbuf_float + (height-1)*width), diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index be245baef21..74047ae74f5 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -117,7 +117,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) if(flags & IB_mem) name= ""; - bytesperpixel = (ibuf->depth + 7) >> 3; + bytesperpixel = (ibuf->planes + 7) >> 3; if ((bytesperpixel > 4) || (bytesperpixel == 2)) { printf("imb_savepng: Cunsupported bytes per pixel: %d for file: '%s'\n", bytesperpixel, name); return (0); diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 6519e389a21..4ee4aa218da 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -67,7 +67,7 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1) if (ibuf1->x <= 1) return(IMB_dupImBuf(ibuf1)); - ibuf2 = IMB_allocImBuf((ibuf1->x)/2, ibuf1->y, ibuf1->depth, ibuf1->flags); + ibuf2 = IMB_allocImBuf((ibuf1->x)/2, ibuf1->y, ibuf1->planes, ibuf1->flags); if (ibuf2==NULL) return (NULL); _p1 = (uchar *) ibuf1->rect; @@ -128,7 +128,7 @@ struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1) do_rect= (ibuf1->rect != NULL); do_float= (ibuf1->rect_float != NULL); - ibuf2 = IMB_allocImBuf(2 * ibuf1->x , ibuf1->y , ibuf1->depth, ibuf1->flags); + ibuf2 = IMB_allocImBuf(2 * ibuf1->x , ibuf1->y , ibuf1->planes, ibuf1->flags); if (ibuf2==NULL) return (NULL); p1 = (int *) ibuf1->rect; @@ -187,7 +187,7 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1) do_rect= (ibuf1->rect != NULL); do_float= (ibuf1->rect_float != NULL); - ibuf2 = IMB_allocImBuf(ibuf1->x , (ibuf1->y) / 2 , ibuf1->depth, ibuf1->flags); + ibuf2 = IMB_allocImBuf(ibuf1->x , (ibuf1->y) / 2 , ibuf1->planes, ibuf1->flags); if (ibuf2==NULL) return (NULL); _p1 = (uchar *) ibuf1->rect; @@ -255,7 +255,7 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1) do_rect= (ibuf1->rect != NULL); do_float= (ibuf1->rect_float != NULL); - ibuf2 = IMB_allocImBuf(ibuf1->x , 2 * ibuf1->y , ibuf1->depth, ibuf1->flags); + ibuf2 = IMB_allocImBuf(ibuf1->x , 2 * ibuf1->y , ibuf1->planes, ibuf1->flags); if (ibuf2==NULL) return (NULL); p1 = (int *) ibuf1->rect; @@ -353,7 +353,7 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1) if (ibuf1->x <= 1) return(IMB_half_y(ibuf1)); if (ibuf1->y <= 1) return(IMB_half_x(ibuf1)); - ibuf2=IMB_allocImBuf((ibuf1->x)/2, (ibuf1->y)/2, ibuf1->depth, ibuf1->flags); + ibuf2=IMB_allocImBuf((ibuf1->x)/2, (ibuf1->y)/2, ibuf1->planes, ibuf1->flags); if (ibuf2==NULL) return (NULL); imb_onehalf_no_alloc(ibuf2, ibuf1); diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 2efed56ac2c..895f922a0da 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -200,20 +200,20 @@ static int dumptarga(struct ImBuf * ibuf, FILE * file) size = ibuf->x * ibuf->y; rect = (uchar *) ibuf->rect; - if (ibuf->depth <= 8) { + if (ibuf->planes <= 8) { while(size > 0){ if (putc(*rect, file) == EOF) return (0); size--; rect += 4; } - } else if (ibuf->depth <= 16) { + } else if (ibuf->planes <= 16) { while(size > 0){ putc(rect[0], file); if (putc(rect[1], file) == EOF) return (0); size--; rect += 4; } - } else if (ibuf->depth <= 24) { + } else if (ibuf->planes <= 24) { while(size > 0){ putc(rect[2], file); putc(rect[1], file); @@ -221,7 +221,7 @@ static int dumptarga(struct ImBuf * ibuf, FILE * file) size--; rect += 4; } - } else if (ibuf->depth <= 32) { + } else if (ibuf->planes <= 32) { while(size > 0){ putc(rect[2], file); putc(rect[1], file); @@ -244,8 +244,8 @@ int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags) (void)flags; /* unused */ - buf[16] = (ibuf->depth + 0x7 ) & ~0x7; - if (ibuf->depth > 8 ){ + buf[16] = (ibuf->planes + 0x7 ) & ~0x7; + if (ibuf->planes > 8 ){ buf[2] = 10; } else{ buf[2] = 11; @@ -265,7 +265,7 @@ int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags) /* Don't forget to indicate that your 32 bit * targa uses 8 bits for the alpha channel! */ - if (ibuf->depth==32) { + if (ibuf->planes==32) { buf[17] |= 0x08; } fildes = fopen(name,"wb"); @@ -279,7 +279,7 @@ int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags) if (ibuf->ftype == RAWTGA) { ok = dumptarga(ibuf, fildes); } else { - switch((ibuf->depth + 7) >> 3){ + switch((ibuf->planes + 7) >> 3){ case 1: ok = makebody_tga(ibuf, fildes, tga_out1); break; @@ -582,7 +582,7 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) size = 0; for (col = maxcol - 1; col > 0; col >>= 1) size++; - ibuf->depth = size; + ibuf->planes = size; if (tga.mapbits != 32) { /* set alpha bits */ cmap[0] &= BIG_LONG(0x00ffffffl); @@ -643,7 +643,7 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) cp[3] += cp[3] >> 5; cp[0] = 0xff; } - ibuf->depth = 24; + ibuf->planes = 24; } if (tga.imgtyp == 3 || tga.imgtyp == 11){ diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index ffe255ab9eb..41278e8381a 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -363,7 +363,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im IMB_metadata_change_field(img, "Thumb::Image::Height", cheight); } img->ftype = PNG; - img->depth = 32; + img->planes = 32; if (IMB_saveiff(img, temp, IB_rect | IB_metadata)) { #ifndef WIN32 chmod(temp, S_IRUSR | S_IWUSR); diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index d9580961cf5..2051b8d2195 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -404,7 +404,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) ib_flag = IB_rect; } - tmpibuf= IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->depth, ib_flag); + tmpibuf= IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, ib_flag); /* simple RGBA image */ if (!(bitspersample == 32 || bitspersample == 16)) { @@ -685,7 +685,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) /* check for a valid number of bytes per pixel. Like the PNG writer, * the TIFF writer supports 1, 3 or 4 bytes per pixel, corresponding * to gray, RGB, RGBA respectively. */ - samplesperpixel = (uint16)((ibuf->depth + 7) >> 3); + samplesperpixel = (uint16)((ibuf->planes + 7) >> 3); if((samplesperpixel > 4) || (samplesperpixel == 2)) { fprintf(stderr, "imb_savetiff: unsupported number of bytes per " -- cgit v1.2.3