"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.
This commit is contained in:
Brecht Van Lommel
2005-11-27 16:21:25 +00:00
parent dfd22eb943
commit 0e0cafcada
3 changed files with 32 additions and 8 deletions

View File

@@ -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);

View File

@@ -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;
}
}
}

View File

@@ -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);