Fix bug in image texture UI: "Use Alpha" checkbox doesn't appear if file format is...
authorIRIE Shinsuke <irieshinsuke@yahoo.co.jp>
Mon, 31 Mar 2014 05:20:55 +0000 (14:20 +0900)
committerIRIE Shinsuke <irieshinsuke@yahoo.co.jp>
Mon, 31 Mar 2014 08:37:55 +0000 (17:37 +0900)
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/intern/image.c
source/blender/editors/space_image/image_buttons.c
source/blender/makesrna/intern/rna_scene.c

index e36d4bab5661cf9654b64eef5b9ea62cde600b8c..f7fd745073458707b69baea84b2158c700c64f8f 100644 (file)
@@ -73,7 +73,7 @@ int     BKE_imtype_supports_zbuf(const char imtype);
 int     BKE_imtype_supports_compress(const char imtype);
 int     BKE_imtype_supports_quality(const char imtype);
 int     BKE_imtype_requires_linear_float(const char imtype);
-char    BKE_imtype_valid_channels(const char imtype);
+char    BKE_imtype_valid_channels(const char imtype, bool write_file);
 char    BKE_imtype_valid_depths(const char imtype);
 
 char    BKE_imtype_from_arg(const char *arg);
index 7d8ada0fa68efcf0fea3171b9757e9f5b6fa8690..b74424a1d28dea3fab0c02b0c601c35983cb6834 100644 (file)
@@ -1161,16 +1161,18 @@ int BKE_imtype_requires_linear_float(const char imtype)
        return 0;
 }
 
-char BKE_imtype_valid_channels(const char imtype)
+char BKE_imtype_valid_channels(const char imtype, bool write_file)
 {
        char chan_flag = IMA_CHAN_FLAG_RGB; /* assume all support rgb */
 
        /* alpha */
        switch (imtype) {
+               case R_IMF_IMTYPE_BMP:
+                       if (write_file) break;
+                       /* fall-through */
                case R_IMF_IMTYPE_TARGA:
                case R_IMF_IMTYPE_IRIS:
                case R_IMF_IMTYPE_PNG:
-               /* case R_IMF_IMTYPE_BMP: */ /* read but not write */
                case R_IMF_IMTYPE_RADHDR:
                case R_IMF_IMTYPE_TIFF:
                case R_IMF_IMTYPE_OPENEXR:
index 21f54a86df46e7603415df044d2b1f89c388e452..f88cdaf67138f8d47f1f4f58a632840f4a02bb33 100644 (file)
@@ -753,7 +753,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
 
                                        if (ibuf) {
                                                int imtype = BKE_ftype_to_imtype(ibuf->ftype);
-                                               char valid_channels = BKE_imtype_valid_channels(imtype);
+                                               char valid_channels = BKE_imtype_valid_channels(imtype, false);
 
                                                has_alpha = (valid_channels & IMA_CHAN_FLAG_ALPHA) != 0;
 
index 90d14a7ba6fdcc2e0440664024e65286eac83c08..0c70e3320530f29680b0ffdb968f8c544364fffa 100644 (file)
@@ -729,7 +729,7 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value)
        ID *id = ptr->id.data;
        const char is_render = (id && GS(id->name) == ID_SCE);
        /* see note below on why this is */
-       const char chan_flag = BKE_imtype_valid_channels(imf->imtype) | (is_render ? IMA_CHAN_FLAG_BW : 0);
+       const char chan_flag = BKE_imtype_valid_channels(imf->imtype, true) | (is_render ? IMA_CHAN_FLAG_BW : 0);
 
        imf->imtype = value;
 
@@ -800,7 +800,7 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext *UNUS
         * where 'BW' will force grayscale even if the output format writes
         * as RGBA, this is age old blender convention and not sure how useful
         * it really is but keep it for now - campbell */
-       char chan_flag = BKE_imtype_valid_channels(imf->imtype) | (is_render ? IMA_CHAN_FLAG_BW : 0);
+       char chan_flag = BKE_imtype_valid_channels(imf->imtype, true) | (is_render ? IMA_CHAN_FLAG_BW : 0);
 
 #ifdef WITH_FFMPEG
        /* a WAY more crappy case than B&W flag: depending on codec, file format MIGHT support