replace ImBuf.depth with ImBuf.planes to match ImageFormatData.planes & to avoid confusion with ImageFormatData.depth

This commit is contained in:
Campbell Barton 2011-11-21 20:47:19 +00:00
parent 02a164baaa
commit 30fd1ab523
34 changed files with 106 additions and 154 deletions

@ -467,53 +467,6 @@ class RENDER_PT_output(RenderButtonsPanel, Panel):
col.prop(rd, "use_overwrite")
col.prop(rd, "use_placeholder")
"""
if file_format in {'AVI_JPEG', 'JPEG'}:
layout.prop(rd, "file_quality", slider=True)
if file_format == 'PNG':
layout.prop(rd, "file_quality", slider=True, text="Compression")
if file_format in {'OPEN_EXR', 'MULTILAYER'}:
row = layout.row()
row.prop(rd, "exr_codec", text="Codec")
if file_format == 'OPEN_EXR':
row = layout.row()
row.prop(rd, "use_exr_half")
row.prop(rd, "exr_zbuf")
row.prop(rd, "exr_preview")
elif file_format == 'JPEG2000':
split = layout.split()
col = split.column()
col.label(text="Depth:")
col.row().prop(rd, "jpeg2k_depth", expand=True)
col = split.column()
col.prop(rd, "jpeg2k_preset", text="")
col.prop(rd, "jpeg2k_ycc")
elif file_format in {'CINEON', 'DPX'}:
split = layout.split()
split.label("FIXME: hard coded Non-Linear, Gamma:1.0")
'''
col = split.column()
col.prop(rd, "use_cineon_log", text="Convert to Log")
col = split.column(align=True)
col.active = rd.use_cineon_log
col.prop(rd, "cineon_black", text="Black")
col.prop(rd, "cineon_white", text="White")
col.prop(rd, "cineon_gamma", text="Gamma")
'''
elif file_format == 'TIFF':
layout.prop(rd, "use_tiff_16bit")
elif """
if file_format == 'QUICKTIME_CARBON':
layout.operator("scene.render_data_set_quicktime_codec")

@ -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);
}

@ -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;

@ -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);

@ -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;

@ -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);
}
}

@ -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;
}

@ -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;
}
}

@ -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 */

@ -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,

@ -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");

@ -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);

@ -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 */

@ -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);

@ -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)

@ -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; y<h; y++)
@ -555,12 +555,12 @@ 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_float(float *rect_float, char planes, int w, int h)
{
float val, *cp;
int x, y;
if(depth==24) { /* put alpha at 1.0 */
if(planes==24) { /* put alpha at 1.0 */
cp= rect_float;
for(y=0; y<h; y++)
@ -587,9 +587,9 @@ void IMB_premultiply_alpha(ImBuf *ibuf)
return;
if(ibuf->rect)
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);
}

@ -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;

@ -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);

@ -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<<image->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;

@ -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:

@ -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),

@ -117,7 +117,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
if(flags & IB_mem)
name= "<memory>";
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);

@ -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);

@ -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){

@ -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);

@ -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 "

@ -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

@ -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])

@ -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;
}

@ -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;
}

@ -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);
}

@ -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);
}

@ -619,7 +619,7 @@ static int set_image_type(int argc, const char **argv, void *data)
#endif
else {
printf("\nError: Format from '-F / --render-format' not known or not compiled in this release.\n");
imtype_new= imtype_new;
imtype_new= scene->r.im_format.imtype;
}
scene->r.im_format.imtype= imtype_new;

@ -171,7 +171,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);
}