diff options
author | Juho Vepsalainen <bebraw@gmail.com> | 2007-05-03 19:10:44 +0400 |
---|---|---|
committer | Juho Vepsalainen <bebraw@gmail.com> | 2007-05-03 19:10:44 +0400 |
commit | c71949419ed68ef1026b4ac7ac391a51ce055ae8 (patch) | |
tree | 910871aaad78fc88a53fb2213dbcc58f2a49522c /source | |
parent | 7c5c0db23dc6b35d3e26129b2fc1764c859b80b4 (diff) |
== UV/Image Editor ==
Patch #6570.
This patch adds color and alpha selectors to Image -> "New..." dialog.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 15 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Image.c | 3 | ||||
-rw-r--r-- | source/blender/python/api2_2x/bpy_data.c | 3 | ||||
-rw-r--r-- | source/blender/src/editsima.c | 13 | ||||
-rw-r--r-- | source/blender/src/toolbox.c | 5 | ||||
-rw-r--r-- | source/blender/src/verse_object.c | 4 |
7 files changed, 28 insertions, 17 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 1acaf004fb9..58f96491a1b 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -112,7 +112,7 @@ struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser); struct Image *BKE_add_image_file(const char *name); /* adds image, adds ibuf, generates color or pattern */ -struct Image *BKE_add_image_size(int width, int height, char *name, short uvtestgrid); +struct Image *BKE_add_image_size(int width, int height, char *name, short uvtestgrid, float color[4]); /* for reload, refresh, pack */ void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 8666e77078c..21fa38fd83d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -370,7 +370,7 @@ Image *BKE_add_image_file(const char *name) return ima; } -static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid) +static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid, float color[4]) { ImBuf *ibuf; float h=0.0, hoffs=0.0, hue=0.0, s=0.9, v=0.9, r, g, b; @@ -435,8 +435,10 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid) } else { /* blank image */ for(y=0; y<ibuf->y; y++) { for(x=0; x<ibuf->x; x++, rect+=4) { - rect[0]= rect[1]= rect[2]= 0; - rect[3]= 255; + rect[0]= (char)(color[0] * 255.0); + rect[1]= (char)(color[1] * 255.0); + rect[2]= (char)(color[2] * 255.0); + rect[3]= (char)(color[3] * 255.0); } } } @@ -444,7 +446,7 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid) } /* adds new image block, creates ImBuf and initializes color */ -Image *BKE_add_image_size(int width, int height, char *name, short uvtestgrid) +Image *BKE_add_image_size(int width, int height, char *name, short uvtestgrid, float color[4]) { Image *ima; @@ -459,7 +461,7 @@ Image *BKE_add_image_size(int width, int height, char *name, short uvtestgrid) ima->gen_y= height; ima->gen_type= uvtestgrid; - ibuf= add_ibuf_size(width, height, name, uvtestgrid); + ibuf= add_ibuf_size(width, height, name, uvtestgrid, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ima->ok= IMA_OK_LOADED; @@ -1370,6 +1372,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser) ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) { ImBuf *ibuf= NULL; + float color[] = {0, 0, 0, 1}; /* quick reject tests */ if(ima==NULL) @@ -1447,7 +1450,7 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) /* UV testgrid or black or solid etc */ if(ima->gen_x==0) ima->gen_x= 256; if(ima->gen_y==0) ima->gen_y= 256; - ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, ima->gen_type); + ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, ima->gen_type, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ima->ok= IMA_OK_LOADED; } diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index 60ac0f6c5c9..449ebcdfa7a 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -235,6 +235,7 @@ static PyObject *M_Image_New( PyObject * self, PyObject * args) { int width, height, depth; char *name; + float color[] = {0, 0, 0, 1}; Image *image; if( !PyArg_ParseTuple( args, "siii", &name, &width, &height, &depth ) ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, @@ -242,7 +243,7 @@ static PyObject *M_Image_New( PyObject * self, PyObject * args) if (width > 5000 || height > 5000 || width < 1 || height < 1) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "Image width and height must be between 1 and 5000" ) ); - image = BKE_add_image_size(width, height, name, 0); + image = BKE_add_image_size(width, height, name, 0, color); if( !image ) return ( EXPP_ReturnPyObjError( PyExc_MemoryError, "couldn't create PyObject Image_Type" ) ); diff --git a/source/blender/python/api2_2x/bpy_data.c b/source/blender/python/api2_2x/bpy_data.c index 2ccb1dfe109..d2cd650a814 100644 --- a/source/blender/python/api2_2x/bpy_data.c +++ b/source/blender/python/api2_2x/bpy_data.c @@ -395,6 +395,7 @@ PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd) ID *id = NULL; char *name=NULL, *filename=NULL, *data_type=NULL; int img_width=256, img_height=256; + float color[] = {0, 0, 0, 1}; short data_code = 0; int user_count = 0; @@ -537,7 +538,7 @@ PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd) break; case ID_IM: { - id = (ID *)BKE_add_image_size(img_width, img_height, name?name:"Image", 0); + id = (ID *)BKE_add_image_size(img_width, img_height, name?name:"Image", 0, color); if( !id ) return ( EXPP_ReturnPyObjError( PyExc_MemoryError, "couldn't create PyObject Image_Type" ) ); diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c index 2af4444cd08..40cbe36ac8c 100644 --- a/source/blender/src/editsima.c +++ b/source/blender/src/editsima.c @@ -1881,7 +1881,8 @@ void reload_image_sima(void) void new_image_sima(void) { static int width= 256, height= 256; - static short uvtestgrid=0; + static short uvtestgrid= 0; + static float color[] = {0, 0, 0, 1}; char name[22]; strcpy(name, "Untitled"); @@ -1889,11 +1890,13 @@ void new_image_sima(void) add_numbut(0, TEX, "Name:", 0, 21, name, NULL); add_numbut(1, NUM|INT, "Width:", 1, 5000, &width, NULL); add_numbut(2, NUM|INT, "Height:", 1, 5000, &height, NULL); - add_numbut(3, TOG|SHO, "UV Test Grid", 0, 0, &uvtestgrid, NULL); - if (!do_clever_numbuts("New Image", 4, REDRAW)) - return; + add_numbut(3, COL, "", 0, 0, &color, NULL); + add_numbut(4, NUM|FLO, "Alpha:", 0.0, 1.0, &color[3], NULL); + add_numbut(5, TOG|SHO, "UV Test Grid", 0, 0, &uvtestgrid, NULL); + if (!do_clever_numbuts("New Image", 6, REDRAW)) + return; - G.sima->image= BKE_add_image_size(width, height, name, uvtestgrid); + G.sima->image= BKE_add_image_size(width, height, name, uvtestgrid, color); BKE_image_signal(G.sima->image, &G.sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE); image_changed(G.sima, 0); diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index 0657d89f1fc..4a3dde25c67 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -570,8 +570,9 @@ int do_clever_numbuts(char *name, int tot, int winevent) if(varstr->type==TEX) { uiDefBut(block, TEX, 0, varstr->name,(short)((x1+15) + (sizex*xi)),(short)(y2-55- 20*yi),(short)(sizex), 19, numbpoin[a], varstr->min, varstr->max, 0, 0, varstr->tip); - } - else { + } else if(varstr->type==COL) { + uiDefButF(block, COL, 0, "",(short)((x1+15) + (sizex*xi)),(short)(y2-55- 20*yi),(short)(sizex), 19, numbpoin[a], varstr->min, varstr->max, 0, 0, ""); + } else { if(varstr->type==LABEL) {/* dont include the label when rounding the buttons */ uiBlockEndAlign(block); diff --git a/source/blender/src/verse_object.c b/source/blender/src/verse_object.c index 3cebb8fad12..fc937469d42 100644 --- a/source/blender/src/verse_object.c +++ b/source/blender/src/verse_object.c @@ -270,6 +270,7 @@ void b_verse_pop_node(VNode *vnode) else if(vnode->type==V_NT_BITMAP) { struct VBitmapData *vbitmap; struct VBitmapLayer *vblayer; + float color[] = {0, 0, 0, 1}; vbitmap = (VBitmapData*)vnode->data; @@ -293,7 +294,8 @@ void b_verse_pop_node(VNode *vnode) vbitmap->width, vbitmap->height, vnode->name, - 0); + 0, + color); ((Image*)vbitmap->image)->vnode = (void*)vnode; sync_blender_image_with_verse_bitmap_node(vnode); |