Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/BKE_image.h6
-rw-r--r--source/blender/blenkernel/intern/image.c14
-rw-r--r--source/blender/editors/space_image/image_ops.c9
-rw-r--r--source/blender/makesrna/RNA_enum_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_image.c15
5 files changed, 27 insertions, 18 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 909ed471081..10f10cb1d13 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -106,6 +106,12 @@ struct RenderResult;
#define IMA_TYPE_R_RESULT 4
#define IMA_TYPE_COMPOSITE 5
+enum {
+ IMA_GENTYPE_BLANK = 0,
+ IMA_GENTYPE_GRID = 1,
+ IMA_GENTYPE_GRID_COLOR = 2
+};
+
/* ima->ok */
#define IMA_OK 1
#define IMA_OK_LOADED 2
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 2b2128439c7..6201473f317 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -595,7 +595,7 @@ Image *BKE_image_load_exists(const char *filepath)
return BKE_image_load(filepath);
}
-static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4])
+static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, float color[4])
{
ImBuf *ibuf;
unsigned char *rect = NULL;
@@ -615,11 +615,11 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));
ibuf->userflags |= IB_BITMAPDIRTY;
- switch (uvtestgrid) {
- case 1:
+ switch (gen_type) {
+ case IMA_GENTYPE_GRID:
BKE_image_buf_fill_checker(rect, rect_float, width, height);
break;
- case 2:
+ case IMA_GENTYPE_GRID_COLOR:
BKE_image_buf_fill_checker_color(rect, rect_float, width, height);
break;
default:
@@ -630,7 +630,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
}
/* adds new image block, creates ImBuf and initializes color */
-Image *BKE_image_add_generated(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4])
+Image *BKE_image_add_generated(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, float color[4])
{
/* on save, type is changed to FILE in editsima.c */
Image *ima = image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST);
@@ -641,10 +641,10 @@ Image *BKE_image_add_generated(unsigned int width, unsigned int height, const ch
/* BLI_strncpy(ima->name, name, FILE_MAX); */ /* don't do this, this writes in ain invalid filepath! */
ima->gen_x = width;
ima->gen_y = height;
- ima->gen_type = uvtestgrid;
+ ima->gen_type = gen_type;
ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
- ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, uvtestgrid, color);
+ ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
ima->ok = IMA_OK_LOADED;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 3d6b316b743..855f92720e8 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1586,7 +1586,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
PropertyRNA *prop;
char name[MAX_ID_NAME - 2];
float color[4];
- int width, height, floatbuf, uvtestgrid, alpha;
+ int width, height, floatbuf, gen_type, alpha;
/* retrieve state */
sima = CTX_wm_space_image(C);
@@ -1597,7 +1597,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
width = RNA_int_get(op->ptr, "width");
height = RNA_int_get(op->ptr, "height");
floatbuf = RNA_boolean_get(op->ptr, "float");
- uvtestgrid = RNA_boolean_get(op->ptr, "uv_test_grid");
+ gen_type = RNA_enum_get(op->ptr, "generated_type");
RNA_float_get_array(op->ptr, "color", color);
alpha = RNA_boolean_get(op->ptr, "alpha");
@@ -1607,7 +1607,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
if (!alpha)
color[3] = 1.0f;
- ima = BKE_image_add_generated(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color);
+ ima = BKE_image_add_generated(width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color);
if (!ima)
return OPERATOR_CANCELLED;
@@ -1664,7 +1664,8 @@ void IMAGE_OT_new(wmOperatorType *ot)
prop = RNA_def_float_color(ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
RNA_def_property_float_array_default(prop, default_color);
RNA_def_boolean(ot->srna, "alpha", 1, "Alpha", "Create an image with an alpha channel");
- RNA_def_boolean(ot->srna, "uv_test_grid", 0, "UV Test Grid", "Fill the image with a grid for UV map testing");
+ RNA_def_enum(ot->srna, "generated_type", image_generated_type_items, IMA_GENTYPE_BLANK,
+ "Generated Type", "Fill the image with a grid for UV map testing");
RNA_def_boolean(ot->srna, "float", 0, "32 bit Float", "Create image with 32 bit floating point bit depth");
}
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index dd230b7b9f8..b651d4d5e5c 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -57,6 +57,7 @@ extern EnumPropertyItem sequence_modifier_type_items[];
extern EnumPropertyItem image_type_items[];
extern EnumPropertyItem image_color_mode_items[];
extern EnumPropertyItem image_depth_mode_items[];
+extern EnumPropertyItem image_generated_type_items[];
extern EnumPropertyItem color_sets_items[];
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 03e446c9d91..62a06888613 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -42,6 +42,13 @@
#include "WM_types.h"
#include "WM_api.h"
+EnumPropertyItem image_generated_type_items[] = {
+ {IMA_GENTYPE_BLANK, "BLANK", 0, "Blank", "Generate a blank image"},
+ {IMA_GENTYPE_GRID, "UV_GRID", 0, "UV Grid", "Generated grid to test UV mappings"},
+ {IMA_GENTYPE_GRID_COLOR, "COLOR_GRID", 0, "Color Grid", "Generated improved UV grid to test UV mappings"},
+ {0, NULL, 0, NULL, NULL}
+};
+
static EnumPropertyItem image_source_items[] = {
{IMA_SRC_FILE, "FILE", 0, "Single Image", "Single image file"},
{IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Image Sequence", "Multiple image files, as a sequence"},
@@ -436,12 +443,6 @@ static void rna_def_image(BlenderRNA *brna)
{IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""},
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem prop_generated_type_items[] = {
- {0, "BLANK", 0, "Blank", "Generate a blank image"},
- {1, "UV_GRID", 0, "UV Grid", "Generated grid to test UV mappings"},
- {2, "COLOR_GRID", 0, "Color Grid", "Generated improved UV grid to test UV mappings"},
- {0, NULL, 0, NULL, NULL}
- };
static const EnumPropertyItem prop_mapping_items[] = {
{0, "UV", 0, "UV Coordinates", "Use UV coordinates for mapping the image"},
{IMA_REFLECT, "REFLECTION", 0, "Reflection", "Use reflection mapping for mapping the image"},
@@ -520,7 +521,7 @@ static void rna_def_image(BlenderRNA *brna)
/* generated image (image_generated_change_cb) */
prop = RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "gen_type");
- RNA_def_property_enum_items(prop, prop_generated_type_items);
+ RNA_def_property_enum_items(prop, image_generated_type_items);
RNA_def_property_ui_text(prop, "Generated Type", "Generated image type");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");