Followup for fix T37718: image was not saving with proper settings second time

This was actually a regression after color management re-implementation, need
to copy settings from saved image buffer to an original one since they might
be modified during save.

Also noticed image format planes detection didn't work properly from an image
buffer. Made it so save operator works fine now, but also marked a TODO in
BKE_imbuf_to_image_format() which needs to be investigated further.
This commit is contained in:
Sergey Sharybin 2013-12-19 17:17:40 +06:00
parent 01745d359e
commit b0c4133c67
Notes: blender-bot 2023-02-14 11:31:04 +01:00
Referenced by issue #37718, texture compression missing
2 changed files with 18 additions and 3 deletions

View File

@ -1497,6 +1497,12 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i
}
/* planes */
/* TODO(sergey): Channels doesn't correspond actual planes used for image buffer
* For example byte buffer will have 4 channels but it might easily
* be BW or RGB image.
*
* Need to use im_format->planes = imbuf->planes instead?
*/
switch (imbuf->channels) {
case 0:
case 4: im_format->planes = R_IMF_PLANES_RGBA;

View File

@ -1233,8 +1233,6 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
Image *ima = sima->image;
short is_depth_set = FALSE;
simopts->im_format.planes = ibuf->planes;
if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) {
/* imtype */
simopts->im_format = scene->r.im_format;
@ -1250,6 +1248,9 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
}
simopts->im_format.quality = ibuf->ftype & 0xff;
}
simopts->im_format.planes = ibuf->planes;
//simopts->subimtype = scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */
BLI_strncpy(simopts->filepath, ibuf->name, sizeof(simopts->filepath));
@ -1430,8 +1431,16 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
WM_cursor_wait(0);
if (colormanaged_ibuf != ibuf)
if (colormanaged_ibuf != ibuf) {
/* This guys might be modified by image buffer write functions,
* need to copy them back from color managed image buffer to an
* original one, so file type of image is being properly updated.
*/
ibuf->ftype = colormanaged_ibuf->ftype;
ibuf->planes = colormanaged_ibuf->planes;
IMB_freeImBuf(colormanaged_ibuf);
}
}
ED_space_image_release_buffer(sima, ibuf, lock);