[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42118] trunk/blender/source/blender: - saving as a jpeg image would set the image as not having an alpha channel even when saving a copy .
Campbell Barton
ideasman42 at gmail.com
Thu Nov 24 07:30:44 CET 2011
Revision: 42118
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42118
Author: campbellbarton
Date: 2011-11-24 06:30:37 +0000 (Thu, 24 Nov 2011)
Log Message:
-----------
- saving as a jpeg image would set the image as not having an alpha channel even when saving a copy.
- setting the color channels on save as would ignore the channel - BW/RGB/RGBA setting.
now its used when available but still need to hide BW for formats blender can only write as color.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_image.h
trunk/blender/source/blender/blenkernel/intern/image.c
trunk/blender/source/blender/editors/space_image/image_ops.c
trunk/blender/source/blender/imbuf/intern/jpeg.c
Modified: trunk/blender/source/blender/blenkernel/BKE_image.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_image.h 2011-11-24 05:33:22 UTC (rev 42117)
+++ trunk/blender/source/blender/blenkernel/BKE_image.h 2011-11-24 06:30:37 UTC (rev 42118)
@@ -53,6 +53,7 @@
int BKE_alphatest_ibuf(struct ImBuf *ibuf);
int BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf);
int BKE_write_ibuf(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf);
+int BKE_write_ibuf_as(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf, const short is_copy);
void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, char imtype, const short use_ext, const short use_frames);
int BKE_add_image_extension(char *string, const char imtype);
char BKE_ftype_to_imtype(const int ftype);
Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c 2011-11-24 05:33:22 UTC (rev 42117)
+++ trunk/blender/source/blender/blenkernel/intern/image.c 2011-11-24 06:30:37 UTC (rev 42118)
@@ -1483,6 +1483,8 @@
return FALSE;
}
+/* note: imf->planes is ignored here, its assumed the image channels
+ * are already set */
int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf)
{
char imtype= imf->imtype;
@@ -1577,7 +1579,6 @@
/* R_IMF_IMTYPE_JPEG90, etc. default we save jpegs */
if(quality < 10) quality= 90;
ibuf->ftype= JPG|quality;
- if(ibuf->planes==32) ibuf->planes= 24; /* unsupported feature only confuses other s/w */
}
BLI_make_existing_file(name);
@@ -1590,6 +1591,29 @@
return(ok);
}
+/* same as BKE_write_ibuf_as but crappy workaround not to perminantly modify
+ * _some_, values in the imbuf */
+int BKE_write_ibuf_as(ImBuf *ibuf, const char *name, ImageFormatData *imf,
+ const short save_copy)
+{
+ ImBuf ibuf_back= *ibuf;
+ int ok;
+
+ /* all data is rgba anyway,
+ * this just controls how to save for some formats */
+ ibuf->planes= imf->planes;
+
+ ok= BKE_write_ibuf(ibuf, name, imf);
+
+ if (save_copy) {
+ /* note that we are not restoring _all_ settings */
+ ibuf->planes= ibuf_back.planes;
+ ibuf->ftype= ibuf_back.ftype;
+ }
+
+ return ok;
+}
+
int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, struct ImageFormatData *imf)
{
if(scene && scene->r.stamp & R_STAMP_ALL)
Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c 2011-11-24 05:33:22 UTC (rev 42117)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c 2011-11-24 06:30:37 UTC (rev 42118)
@@ -1075,7 +1075,7 @@
BKE_image_release_renderresult(scene, ima);
}
else {
- if (BKE_write_ibuf(ibuf, simopts->filepath, &simopts->im_format)) {
+ if (BKE_write_ibuf_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
ok= TRUE;
}
}
Modified: trunk/blender/source/blender/imbuf/intern/jpeg.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/jpeg.c 2011-11-24 05:33:22 UTC (rev 42117)
+++ trunk/blender/source/blender/imbuf/intern/jpeg.c 2011-11-24 06:30:37 UTC (rev 42118)
@@ -572,8 +572,12 @@
cinfo->in_color_space = JCS_RGB;
if (ibuf->planes == 8) cinfo->in_color_space = JCS_GRAYSCALE;
+#if 0
+ /* just write RGBA as RGB,
+ * unsupported feature only confuses other s/w */
+
if (ibuf->planes == 32) cinfo->in_color_space = JCS_UNKNOWN;
-
+#endif
switch(cinfo->in_color_space){
case JCS_RGB:
cinfo->input_components = 3;
More information about the Bf-blender-cvs
mailing list