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/blenkernel/intern/bmfont.c | 2 +- source/blender/blenkernel/intern/image.c | 10 +++++----- source/blender/blenkernel/intern/movieclip.c | 4 ++-- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 6 +++--- source/blender/blenkernel/intern/tracking.c | 2 +- source/blender/editors/object/object_bake.c | 2 +- source/blender/editors/render/render_opengl.c | 2 +- source/blender/editors/sculpt_paint/paint_image.c | 2 +- source/blender/editors/space_image/image_buttons.c | 4 ++-- source/blender/editors/space_image/image_ops.c | 20 ++++++++++---------- 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 ++-- source/blender/makesdna/DNA_scene_types.h | 11 +++++------ source/blender/makesrna/intern/rna_image.c | 10 +++++----- source/blender/makesrna/intern/rna_image_api.c | 6 +++--- source/blender/makesrna/intern/rna_scene.c | 12 ++++++------ source/blender/render/intern/source/pipeline.c | 4 ++-- source/blender/render/intern/source/rendercore.c | 8 ++++---- 31 files changed, 104 insertions(+), 105 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index f1e6de9a0c4..0211dcdf42c 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -159,7 +159,7 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) ibuf->userdata = bmfont; ibuf->userflags |= IB_BITMAPFONT; - if (ibuf->depth < 32) { + if (ibuf->planes < 32) { // we're going to fake alpha here: calcAlpha(ibuf); } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 6a4cb049be7..c99396e6939 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -601,7 +601,7 @@ void BKE_image_memorypack(Image *ima) } ibuf->ftype= PNG; - ibuf->depth= 32; + ibuf->planes= R_IMF_PLANES_RGBA; IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem); if(ibuf->encodedbuffer==NULL) { @@ -1535,7 +1535,7 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf) /* R_JPEG90, etc. default we save jpegs */ if(quality < 10) quality= 90; ibuf->ftype= JPG|quality; - if(ibuf->depth==32) ibuf->depth= 24; /* unsupported feature only confuses other s/w */ + if(ibuf->planes==32) ibuf->planes= 24; /* unsupported feature only confuses other s/w */ } BLI_make_existing_file(name); @@ -2487,13 +2487,13 @@ int BKE_image_has_alpha(struct Image *image) { ImBuf *ibuf; void *lock; - int depth; + int planes; ibuf= BKE_image_acquire_ibuf(image, NULL, &lock); - depth = (ibuf?ibuf->depth:0); + planes = (ibuf?ibuf->planes:0); BKE_image_release_ibuf(image, lock); - if (depth == 32) + if (planes == 32) return 1; else return 0; diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 540d757f0c9..12a2fe28bc8 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -913,8 +913,8 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i scaleibuf->ftype= JPG | quality; /* unsupported feature only confuses other s/w */ - if(scaleibuf->depth==32) - scaleibuf->depth= 24; + if(scaleibuf->planes==32) + scaleibuf->planes= 24; BLI_lock_thread(LOCK_MOVIECLIP); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 68e5ebeed4f..ea0593aba66 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -348,7 +348,7 @@ Scene *add_scene(const char *name) sce->r.filtertype= R_FILTER_MITCH; sce->r.size= 50; - sce->r.im_format.planes= R_PLANES24; + sce->r.im_format.planes= R_IMF_PLANES_RGB; sce->r.im_format.imtype= R_PNG; sce->r.im_format.quality= 90; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5d35867d9c3..880bdbfaa96 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1327,8 +1327,8 @@ static void seq_proxy_build_frame(SeqRenderData context, ibuf->ftype= JPG | quality; /* unsupported feature only confuses other s/w */ - if(ibuf->depth==32) - ibuf->depth= 24; + if(ibuf->planes==32) + ibuf->planes= 24; BLI_make_existing_file(name); @@ -1729,7 +1729,7 @@ static ImBuf * input_preprocess( } if(seq->flag & SEQ_MAKE_PREMUL) { - if(ibuf->depth == 32 && ibuf->zbuf == NULL) { + if(ibuf->planes == 32 && ibuf->zbuf == NULL) { IMB_premultiply_alpha(ibuf); } } diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 0c395931212..474b00e626b 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -2022,7 +2022,7 @@ static ImBuf* stabilize_alloc_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int fill) } } else { - cacheibuf= IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->depth, flags); + cacheibuf= IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->planes, flags); cacheibuf->profile= srcibuf->profile; } diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 63a316e7f7b..5dc1c1b0f03 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -1039,7 +1039,7 @@ static void clear_images(MTFace *mtface, int totface) if((ima->id.flag&LIB_DOIT)==0) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); + IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid); ima->id.flag|= LIB_DOIT; } } diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 97e93eb2e7f..a68286b8e88 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -440,7 +440,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) if(ibuf) { /* color -> greyscale */ /* editing directly would alter the render view */ - if(scene->r.im_format.planes == R_PLANESBW) { + if(scene->r.im_format.planes == R_IMF_PLANES_BW) { ImBuf *ibuf_bw= IMB_dupImBuf(ibuf); IMB_color_to_bw(ibuf_bw); // IMB_freeImBuf(ibuf); /* owned by the image */ diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 9b256acbca9..f165c83b551 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4333,7 +4333,7 @@ static ImBuf *imapaint_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos) /* note: allocImbuf returns zero'd memory, so regions outside image will have zero alpha, and hence not be blended onto the image */ int w=ibufb->x, h=ibufb->y, destx=0, desty=0, srcx=pos[0], srcy=pos[1]; - ImBuf *clonebuf= IMB_allocImBuf(w, h, ibufb->depth, ibufb->flags); + ImBuf *clonebuf= IMB_allocImBuf(w, h, ibufb->planes, ibufb->flags); IMB_rectclip(clonebuf, ibuf, &destx, &desty, &srcx, &srcy, &w, &h); IMB_rectblend(clonebuf, ibuf, destx, desty, srcx, srcy, w, h, diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 48627e9d1ed..54ee92a4413 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -122,13 +122,13 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, if(ibuf->channels!=4) { ofs+= sprintf(str+ofs, "%d float channel(s)", ibuf->channels); } - else if(ibuf->depth==32) + else if(ibuf->planes == R_IMF_PLANES_RGBA) ofs+= sprintf(str+ofs, " RGBA float"); else ofs+= sprintf(str+ofs, " RGB float"); } else { - if(ibuf->depth==32) + if(ibuf->planes == R_IMF_PLANES_RGBA) ofs+= sprintf(str+ofs, " RGBA byte"); else ofs+= sprintf(str+ofs, " RGB byte"); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 448e109e98a..7e2a86f9324 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -949,7 +949,7 @@ typedef struct { static void save_image_options_defaults(SaveImageOptions *simopts) { - simopts->planes= R_PLANES24; + simopts->planes= R_IMF_PLANES_RGB; simopts->imtype= R_PNG; simopts->subimtype= 0; simopts->quality= 90; @@ -964,7 +964,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, if(ibuf) { Image *ima= sima->image; - simopts->planes= ibuf->depth; + simopts->planes= ibuf->planes; if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { simopts->imtype= scene->r.im_format.imtype; @@ -984,8 +984,8 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, /* sanitize all settings */ /* unlikely but just incase */ - if (ELEM3(simopts->planes, R_PLANESBW, R_PLANES24, R_PLANES32) == 0) { - simopts->planes= R_PLANES32; + if (ELEM3(simopts->planes, R_IMF_PLANES_BW, R_IMF_PLANES_RGB, R_IMF_PLANES_RGBA) == 0) { + simopts->planes= R_IMF_PLANES_RGBA; } /* some formats dont use quality so fallback to scenes quality */ @@ -1060,18 +1060,18 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI if(ima->type == IMA_TYPE_R_RESULT) { /* enforce user setting for RGB or RGBA, but skip BW */ - if(simopts->planes==R_PLANES32) { - ibuf->depth= 32; + if(simopts->planes==R_IMF_PLANES_RGBA) { + ibuf->planes= R_IMF_PLANES_RGBA; } - else if(simopts->planes==R_PLANES24) { - ibuf->depth= 24; + else if(simopts->planes==R_IMF_PLANES_RGB) { + ibuf->planes= R_IMF_PLANES_RGB; } } else { /* TODO, better solution, if a 24bit image is painted onto it may contain alpha */ if(ibuf->userflags & IB_BITMAPDIRTY) { /* it has been painted onto */ /* checks each pixel, not ideal */ - ibuf->depth= BKE_alphatest_ibuf(ibuf) ? 32 : 24; + ibuf->planes= BKE_alphatest_ibuf(ibuf) ? 32 : 24; } } @@ -1240,7 +1240,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot) /* format options */ RNA_def_enum(ot->srna, "file_format", image_file_type_items, R_PNG, "File Type", "File type to save image as"); - RNA_def_enum(ot->srna, "color_mode", image_color_mode_items, R_PLANES24, "Channels", "Image channels to save"); + RNA_def_enum(ot->srna, "color_mode", image_color_mode_items, R_IMF_PLANES_RGB, "Channels", "Image channels to save"); prop= RNA_def_int(ot->srna, "file_quality", 90, 0, 100, "Quality", "", 0, 100); RNA_def_property_subtype(prop, PROP_PERCENTAGE); 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 " diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index ce9903e91ee..9df8fc5c5d8 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -218,7 +218,7 @@ typedef struct ImageFormatData { char depth; /* bits per channel, R_IMF_CHAN_DEPTH_8 -> 32, * not a flag, only set 1 at a time */ - char planes ; /* - R_PLANESBW, R_PLANES24, R_PLANES32 */ + char planes ; /* - R_IMF_PLANES_BW, R_IMF_PLANES_RGB, R_IMF_PLANES_RGBA */ char flag; /* generic options for all image types, alpha zbuffer */ char quality; /* (0 - 100), eg: jpeg quality */ @@ -262,6 +262,10 @@ typedef struct ImageFormatData { #define R_IMF_CHAN_DEPTH_24 (1<<4) /* 24bits (unused) */ #define R_IMF_CHAN_DEPTH_32 (1<<5) /* 32bits (full float exr) */ +/* ImageFormatData.planes */ +#define R_IMF_PLANES_RGB 24 +#define R_IMF_PLANES_RGBA 32 +#define R_IMF_PLANES_BW 8 typedef struct RenderData { struct ImageFormatData im_format; @@ -1044,11 +1048,6 @@ typedef struct Scene { #define R_ALPHAPREMUL 1 #define R_ALPHAKEY 2 -/* planes */ -#define R_PLANES24 24 -#define R_PLANES32 32 -#define R_PLANESBW 8 - /* color_mgt_flag */ #define R_COLOR_MANAGEMENT 1 diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index ad6f459f851..737ce73ff1d 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -258,20 +258,20 @@ static int rna_Image_depth_get(PointerRNA *ptr) Image *im= (Image*)ptr->data; ImBuf *ibuf; void *lock; - int depth; + int planes; ibuf= BKE_image_acquire_ibuf(im, NULL, &lock); if(!ibuf) - depth= 0; + planes= 0; else if(ibuf->rect_float) - depth= ibuf->depth * 4; + planes= ibuf->planes * 4; else - depth= ibuf->depth; + planes= ibuf->planes; BKE_image_release_ibuf(im, lock); - return depth; + return planes; } static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 09af7fe1c5b..91aa9daac25 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -82,14 +82,14 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports } else { /* temp swap out the color */ - const unsigned char imb_depth_back= ibuf->depth; + const unsigned char imb_planes_back= ibuf->planes; const float dither_back= ibuf->dither; - ibuf->depth= scene->r.im_format.planes; + ibuf->planes= scene->r.im_format.planes; ibuf->dither= scene->r.dither_intensity; if (!BKE_write_ibuf(ibuf, path, &scene->r.im_format)) { BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path); } - ibuf->depth= imb_depth_back; + ibuf->planes= imb_planes_back; ibuf->dither= dither_back; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index e862652e9fb..8dcab8f5b04 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -208,9 +208,9 @@ EnumPropertyItem image_type_items[] = { {0, NULL, 0, NULL, NULL}}; EnumPropertyItem image_color_mode_items[] ={ - {R_PLANESBW, "BW", 0, "BW", "Images get saved in 8 bits grayscale (only PNG, JPEG, TGA, TIF)"}, - {R_PLANES24, "RGB", 0, "RGB", "Images are saved with RGB (color) data"}, - {R_PLANES32, "RGBA", 0, "RGBA", "Images are saved with RGB and Alpha data (if supported)"}, + {R_IMF_PLANES_BW, "BW", 0, "BW", "Images get saved in 8 bits grayscale (only PNG, JPEG, TGA, TIF)"}, + {R_IMF_PLANES_RGB, "RGB", 0, "RGB", "Images are saved with RGB (color) data"}, + {R_IMF_PLANES_RGBA, "RGBA", 0, "RGBA", "Images are saved with RGB and Alpha data (if supported)"}, {0, NULL, 0, NULL, NULL}}; EnumPropertyItem image_color_depth_items[] = { @@ -616,7 +616,7 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) /* ensure depth and color settings match */ if (!BKE_imtype_is_alpha_ok(imf->imtype)) { - imf->planes= R_PLANES24; + imf->planes= R_IMF_PLANES_RGB; } /* ensure usable depth */ @@ -677,8 +677,8 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext *C, P } else { static EnumPropertyItem color_mode_items[] ={ - {R_PLANESBW, "BW", 0, "BW", "Images get saved in 8 bits grayscale (only PNG, JPEG, TGA, TIF)"}, - {R_PLANES24, "RGB", 0, "RGB", "Images are saved with RGB (color) data"}, + {R_IMF_PLANES_BW, "BW", 0, "BW", "Images get saved in 8 bits grayscale (only PNG, JPEG, TGA, TIF)"}, + {R_IMF_PLANES_RGB, "RGB", 0, "RGB", "Images are saved with RGB (color) data"}, {0, NULL, 0, NULL, NULL}}; return color_mode_items; } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 9f96d28f1e6..b6dc5070222 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -3039,7 +3039,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie /* color -> greyscale */ /* editing directly would alter the render view */ - if(scene->r.im_format.planes == R_PLANESBW) { + if(scene->r.im_format.planes == R_IMF_PLANES_BW) { ImBuf *ibuf_bw= IMB_dupImBuf(ibuf); IMB_color_to_bw(ibuf_bw); IMB_freeImBuf(ibuf); @@ -3061,7 +3061,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie if(BLI_testextensie(name, ".exr")) name[strlen(name)-4]= 0; BKE_add_image_extension(name, R_JPEG90); - ibuf->depth= 24; + ibuf->planes= 24; BKE_write_ibuf_stamp(scene, camera, ibuf, name, &imf); printf("\nSaved: %s", name); } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 456702e0827..5559d2ff34c 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2458,7 +2458,7 @@ static int get_next_bake_face(BakeShade *bs) imb_freerectImBuf(ibuf); /* clear image */ if(R.r.bake_flag & R_BAKE_CLEAR) - IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); + IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid); /* might be read by UI to set active image for display */ R.bakebuf= ima; @@ -2566,7 +2566,7 @@ static void *do_bake_thread(void *bs_v) void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter) { /* must check before filtering */ - const short is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf); + const short is_new_alpha= (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_alphatest_ibuf(ibuf); /* Margin */ if(filter) { @@ -2575,10 +2575,10 @@ void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter) /* if the bake results in new alpha then change the image setting */ if(is_new_alpha) { - ibuf->depth= 32; + ibuf->planes= R_IMF_PLANES_RGBA; } else { - if(filter && ibuf->depth != 32) { + if(filter && ibuf->planes != R_IMF_PLANES_RGBA) { /* clear alpha added by filtering */ IMB_rectfill_alpha(ibuf, 1.0f); } -- cgit v1.2.3