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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2005-11-27 19:21:25 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2005-11-27 19:21:25 +0300
commit0e0cafcada38937449e6160aba923ecafbc0e507 (patch)
treec10e1c21fdf6321110c0630c635fb578e7945a91 /source/blender
parentdfd22eb94340165e049d2ecb31d96e20de94938d (diff)
"UV Test Grid" option in Image Window > Image menu > New, to generate
a colored grid instead of a blank image, for quickly spotting distortion in UV maps.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_image.h2
-rw-r--r--source/blender/blenkernel/intern/image.c32
-rw-r--r--source/blender/src/header_image.c6
3 files changed, 32 insertions, 8 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 1927ad9bb02..1ae5552104c 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -47,7 +47,7 @@ void free_image(struct Image *me);
void free_image_buffers(struct Image *ima);
struct Image *add_image(char *name);
void free_unused_animimages(void);
-struct Image *new_image(int width, int height, char *name);
+struct Image *new_image(int width, int height, char *name, short uvtestgrid);
void makepicstring(char *string, int frame);
void addImageExtension(char *string);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 5be1c0ed48f..c09f68643ce 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -54,6 +54,7 @@
#include "DNA_userdef_types.h"
#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
#include "BKE_bmfont.h"
#include "BKE_packedFile.h"
@@ -148,7 +149,7 @@ Image *add_image(char *name)
return ima;
}
-Image *new_image(int width, int height, char *name)
+Image *new_image(int width, int height, char *name, short uvtestgrid)
{
Image *ima;
@@ -159,6 +160,7 @@ Image *new_image(int width, int height, char *name)
ImBuf *ibuf;
unsigned char *rect;
int x, y;
+ float h=0.0, hoffs=0.0, s=0.9, v=0.6, r, g, b;
strcpy(ima->name, "Untitled");
@@ -167,10 +169,30 @@ Image *new_image(int width, int height, char *name)
ima->ibuf= ibuf;
rect= (unsigned char*)ibuf->rect;
- 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;
+
+ if (uvtestgrid) {
+ for(y=0; y<ibuf->y; y++) {
+ if (y % 20 == 0) hoffs += 0.125;
+ if (y % 160 == 0) hoffs = 0.0;
+
+ for(x=0; x<ibuf->x; x++, rect+=4) {
+ if (x % 20 == 0) h += 0.125;
+ if (x % 160 == 0) h = 0.0;
+
+ hsv_to_rgb(fabs(h-hoffs), s, v, &r, &g, &b);
+
+ rect[0]= (char)(r * 255.0);
+ rect[1]= (char)(g * 255.0);
+ rect[2]= (char)(b * 255.0);
+ rect[3]= 255;
+ }
+ }
+ } 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;
+ }
}
}
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index 8a4603ec532..e0571e94e45 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -731,6 +731,7 @@ static void do_image_imagemenu(void *arg, int event)
case 7: /* New Image */
{
static int width= 256, height= 256;
+ static short uvtestgrid=0;
char name[256];
strcpy(name, "Image");
@@ -738,10 +739,11 @@ static void do_image_imagemenu(void *arg, int event)
add_numbut(0, TEX, "Name:", 0, 255, name, NULL);
add_numbut(1, NUM|INT, "Width:", 1, 5000, &width, NULL);
add_numbut(2, NUM|INT, "Height:", 1, 5000, &height, NULL);
- if (!do_clever_numbuts("New Image", 3, REDRAW))
+ add_numbut(3, TOG|SHO, "UV Test Grid", 0, 0, &uvtestgrid, NULL);
+ if (!do_clever_numbuts("New Image", 4, REDRAW))
return;
- G.sima->image= new_image(width, height, name);
+ G.sima->image= new_image(width, height, name, uvtestgrid);
image_changed(G.sima, 0);
allqueue(REDRAWIMAGE, 0);