fix/workaround [#28040] float images reduced to 256 levels per channel upon save
authorCampbell Barton <ideasman42@gmail.com>
Thu, 21 Jul 2011 00:41:00 +0000 (00:41 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 21 Jul 2011 00:41:00 +0000 (00:41 +0000)
Generated images would not be re-generated with a float buffer on load, even when selected on creation.
Now save the float buffer setting as a generated image flag.

This means you can enable before baking to enable baking to a float buffer.

source/blender/blenkernel/intern/image.c
source/blender/editors/space_image/image_buttons.c
source/blender/makesdna/DNA_image_types.h
source/blender/makesrna/intern/rna_image.c

index c48497c45a12c82bda4bb9ab669a93ac1031e168..ab67d7e3f250fa2a4df6414bd7c4c4e617d8768a 100644 (file)
@@ -432,6 +432,7 @@ Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *n
                ima->gen_x= width;
                ima->gen_y= height;
                ima->gen_type= uvtestgrid;
+               ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
                
                ibuf= add_ibuf_size(width, height, name, depth, floatbuf, uvtestgrid, color);
                image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
@@ -2172,7 +2173,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
                                /* UV testgrid or black or solid etc */
                                if(ima->gen_x==0) ima->gen_x= 1024;
                                if(ima->gen_y==0) ima->gen_y= 1024;
-                               ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, 0, ima->gen_type, color);
+                               ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color);
                                image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
                                ima->ok= IMA_OK_LOADED;
                        }
index e9ebe78da296d302b49217e932566d291c9a69ba..66e844e67a8f689bc694b1d83e9df424ea56aad0 100644 (file)
@@ -804,6 +804,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
                                col= uiLayoutColumn(split, 1);
                                uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE);
                                uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE);
+                               uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);
 
                                uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
                        }
index 99ed2319415a1a46b92b5939016ab9eaa6e54f37..dd033339ca4292ac5d8e58909a81e2034a7d365f 100644 (file)
@@ -102,7 +102,8 @@ typedef struct Image {
        short animspeed;
        
        /* for generated images */
-       short gen_x, gen_y, gen_type;
+       short gen_x, gen_y;
+       char gen_type, gen_flag;
        
        /* display aspect - for UV editing images resized for faster openGL display */
        float aspx, aspy;
@@ -136,5 +137,8 @@ typedef struct Image {
 #define IMA_MAX_RENDER_TEXT            512
 #define IMA_MAX_RENDER_SLOT            8
 
+/* gen_flag */
+#define IMA_GEN_FLOAT          1
+
 #endif
 
index a52849b3366bddbe0c6876a30d1ea97268eedd8e..eac4932ac43af333391cebc583fcecb40910710b 100644 (file)
@@ -502,6 +502,11 @@ static void rna_def_image(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Generated Height", "Generated image height");
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update");
 
+       prop= RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT);
+       RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating point buffer");
+       RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update");
+
        /* realtime properties */
        prop= RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");