mirror of https://github.com/GNOME/gimp.git
removed redundant functions gimp_rgb_to_hsv_double() and
2003-05-20 Michael Natterer <mitch@gimp.org> * libgimpcolor/gimpcolorspace.[ch]: removed redundant functions gimp_rgb_to_hsv_double() and gimp_hsv_to_rgb_double(). * app/core/gimpdrawable-blend.c: use gimp_rgb_to_hsv() and gimp_hsv_to_rgb() instead. * plug-ins/fp/fp.[ch] * plug-ins/fp/fp_misc.c: ditto. Deuglyfied the changed functions' coding style a lot.
This commit is contained in:
parent
a1abf2c55c
commit
fc6ddb0540
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2003-05-20 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpcolor/gimpcolorspace.[ch]: removed redundant functions
|
||||
gimp_rgb_to_hsv_double() and gimp_hsv_to_rgb_double().
|
||||
|
||||
* app/core/gimpdrawable-blend.c: use gimp_rgb_to_hsv() and
|
||||
gimp_hsv_to_rgb() instead.
|
||||
|
||||
* plug-ins/fp/fp.[ch]
|
||||
* plug-ins/fp/fp_misc.c: ditto. Deuglyfied the changed functions'
|
||||
coding style a lot.
|
||||
|
||||
2003-05-20 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpimage-undo-push.c (undo_pop_layer_mod): call
|
||||
|
|
|
@ -771,7 +771,13 @@ gradient_render_pixel (double x,
|
|||
color->a = rbd->fg.a + (rbd->bg.a - rbd->fg.a) * factor;
|
||||
|
||||
if (rbd->blend_mode == GIMP_FG_BG_HSV_MODE)
|
||||
gimp_hsv_to_rgb_double (&color->r, &color->g, &color->b);
|
||||
{
|
||||
GimpHSV hsv;
|
||||
|
||||
hsv = *((GimpHSV *) color);
|
||||
|
||||
gimp_hsv_to_rgb (&hsv, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -861,10 +867,16 @@ gradient_fill_region (GimpImage *gimage,
|
|||
|
||||
case GIMP_FG_BG_HSV_MODE:
|
||||
/* Convert to HSV */
|
||||
{
|
||||
GimpHSV fg_hsv;
|
||||
GimpHSV bg_hsv;
|
||||
|
||||
gimp_rgb_to_hsv_double (&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
|
||||
gimp_rgb_to_hsv_double (&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
|
||||
gimp_rgb_to_hsv (&rbd.fg, &fg_hsv);
|
||||
gimp_rgb_to_hsv (&rbd.bg, &bg_hsv);
|
||||
|
||||
rbd.fg = *((GimpRGB *) &fg_hsv);
|
||||
rbd.bg = *((GimpRGB *) &bg_hsv);
|
||||
}
|
||||
break;
|
||||
|
||||
case GIMP_FG_TRANSPARENT_MODE:
|
||||
|
@ -872,7 +884,6 @@ gradient_fill_region (GimpImage *gimage,
|
|||
|
||||
rbd.bg = rbd.fg;
|
||||
rbd.bg.a = 0.0; /* transparent */
|
||||
|
||||
break;
|
||||
|
||||
case GIMP_CUSTOM_MODE:
|
||||
|
|
|
@ -634,140 +634,6 @@ gimp_hls_to_rgb_int (gint *hue,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgb_to_hsv_double (gdouble *red,
|
||||
gdouble *green,
|
||||
gdouble *blue)
|
||||
{
|
||||
gdouble r, g, b;
|
||||
gdouble h, s, v;
|
||||
gdouble min, max;
|
||||
gdouble delta;
|
||||
|
||||
r = *red;
|
||||
g = *green;
|
||||
b = *blue;
|
||||
|
||||
h = 0.0; /* Shut up -Wall */
|
||||
|
||||
if (r > g)
|
||||
{
|
||||
max = MAX (r, b);
|
||||
min = MIN (g, b);
|
||||
}
|
||||
else
|
||||
{
|
||||
max = MAX (g, b);
|
||||
min = MIN (r, b);
|
||||
}
|
||||
|
||||
v = max;
|
||||
|
||||
if (max != 0.0)
|
||||
s = (max - min) / max;
|
||||
else
|
||||
s = 0.0;
|
||||
|
||||
if (s == 0.0)
|
||||
{
|
||||
h = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
delta = max - min;
|
||||
|
||||
if (delta == 0.0)
|
||||
delta = 1.0;
|
||||
|
||||
if (r == max)
|
||||
h = (g - b) / delta;
|
||||
else if (g == max)
|
||||
h = 2 + (b - r) / delta;
|
||||
else if (b == max)
|
||||
h = 4 + (r - g) / delta;
|
||||
|
||||
h /= 6.0;
|
||||
|
||||
if (h < 0.0)
|
||||
h += 1.0;
|
||||
else if (h > 1.0)
|
||||
h -= 1.0;
|
||||
}
|
||||
|
||||
*red = h;
|
||||
*green = s;
|
||||
*blue = v;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_hsv_to_rgb_double (gdouble *hue,
|
||||
gdouble *saturation,
|
||||
gdouble *value)
|
||||
{
|
||||
gdouble h, s, v;
|
||||
gdouble f, p, q, t;
|
||||
|
||||
if (*saturation == 0.0)
|
||||
{
|
||||
*hue = *value;
|
||||
*saturation = *value;
|
||||
*value = *value;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = *hue * 6.0;
|
||||
s = *saturation;
|
||||
v = *value;
|
||||
|
||||
if (h == 6.0)
|
||||
h = 0.0;
|
||||
|
||||
f = h - (gint) h;
|
||||
p = v * (1.0 - s);
|
||||
q = v * (1.0 - s * f);
|
||||
t = v * (1.0 - s * (1.0 - f));
|
||||
|
||||
switch ((gint) h)
|
||||
{
|
||||
case 0:
|
||||
*hue = v;
|
||||
*saturation = t;
|
||||
*value = p;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
*hue = q;
|
||||
*saturation = v;
|
||||
*value = p;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*hue = p;
|
||||
*saturation = v;
|
||||
*value = t;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
*hue = p;
|
||||
*saturation = q;
|
||||
*value = v;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*hue = t;
|
||||
*saturation = p;
|
||||
*value = v;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
*hue = v;
|
||||
*saturation = p;
|
||||
*value = q;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgb_to_hsv4 (guchar *rgb,
|
||||
gdouble *hue,
|
||||
|
|
|
@ -72,13 +72,6 @@ void gimp_hls_to_rgb_int (gint *hue /* returns red */,
|
|||
|
||||
/* gdouble functions */
|
||||
|
||||
void gimp_rgb_to_hsv_double (gdouble *red /* returns hue */,
|
||||
gdouble *green /* returns saturation */,
|
||||
gdouble *blue /* returns value */);
|
||||
void gimp_hsv_to_rgb_double (gdouble *hue /* returns red */,
|
||||
gdouble *saturation, /* returns green */
|
||||
gdouble *value /* returns blue */);
|
||||
|
||||
void gimp_rgb_to_hsv4 (guchar *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *saturation,
|
||||
|
|
|
@ -150,72 +150,78 @@ fp_row (const guchar *src_row,
|
|||
gint row_width,
|
||||
gint bytes)
|
||||
{
|
||||
gint col, bytenum, k;
|
||||
int JudgeBy, Intensity=0, P[3], backupP[3];
|
||||
hsv H,S,V;
|
||||
gint M, m, middle;
|
||||
gint col, bytenum, k;
|
||||
gint JudgeBy, Intensity=0, P[3], backupP[3];
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
gint M, m, middle;
|
||||
|
||||
for (col = 0; col < row_width ; col++)
|
||||
{
|
||||
|
||||
backupP[0] = P[0] = src_row[col*bytes+0];
|
||||
backupP[0] = P[1] = src_row[col*bytes+1];
|
||||
backupP[0] = P[2] = src_row[col*bytes+2];
|
||||
backupP[0] = P[0] = src_row[col * bytes + 0];
|
||||
backupP[0] = P[1] = src_row[col * bytes + 1];
|
||||
backupP[0] = P[2] = src_row[col * bytes + 2];
|
||||
|
||||
H = P[0]/255.0;
|
||||
S = P[1]/255.0;
|
||||
V = P[2]/255.0;
|
||||
gimp_rgb_to_hsv_double(&H, &S, &V);
|
||||
gimp_rgb_set_uchar (&rgb, (guchar) P[0], (guchar) P[1], (guchar) P[2]);
|
||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
||||
|
||||
for (JudgeBy = BY_HUE; JudgeBy < JUDGE_BY; JudgeBy++)
|
||||
{
|
||||
if (! Current.Touched[JudgeBy])
|
||||
continue;
|
||||
|
||||
switch (JudgeBy)
|
||||
{
|
||||
case BY_HUE:
|
||||
Intensity = 255 * hsv.h;
|
||||
break;
|
||||
|
||||
case BY_SAT:
|
||||
Intensity = 255 * hsv.s;
|
||||
break;
|
||||
|
||||
case BY_VAL:
|
||||
Intensity = 255 * hsv.v;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* It's important to take care of Saturation first!!! */
|
||||
|
||||
for (JudgeBy=BY_HUE; JudgeBy<JUDGE_BY; JudgeBy++) {
|
||||
if (!Current.Touched[JudgeBy]) continue;
|
||||
|
||||
switch (JudgeBy) {
|
||||
case BY_HUE:
|
||||
Intensity=255*H;
|
||||
break;
|
||||
case BY_SAT:
|
||||
Intensity=255*S;
|
||||
break;
|
||||
case BY_VAL:
|
||||
Intensity=255*V;
|
||||
break;
|
||||
}
|
||||
m = MIN (MIN (P[0], P[1]), P[2]);
|
||||
M = MAX (MAX (P[0], P[1]), P[2]);
|
||||
middle = (M + m) / 2;
|
||||
|
||||
|
||||
/* It's important to take care of Saturation first!!! */
|
||||
for (k = 0; k < 3; k++)
|
||||
if (P[k] != m && P[k] != M)
|
||||
middle = P[k];
|
||||
|
||||
m = MIN(MIN(P[0],P[1]),P[2]);
|
||||
M = MAX(MAX(P[0],P[1]),P[2]);
|
||||
middle=(M+m)/2;
|
||||
for (k = 0; k < 3; k++)
|
||||
if (M != m)
|
||||
{
|
||||
if (P[k] == M)
|
||||
P[k] = MAX (P[k] + Current.satAdj[JudgeBy][Intensity], middle);
|
||||
else if (P[k] == m)
|
||||
P[k] = MIN (P[k] - Current.satAdj[JudgeBy][Intensity], middle);
|
||||
}
|
||||
|
||||
for (k=0; k<3; k++)
|
||||
if (P[k]!=m && P[k]!=M) middle=P[k];
|
||||
|
||||
for (k=0; k<3; k++)
|
||||
if (M!=m) {
|
||||
if (P[k] == M)
|
||||
P[k] = MAX(P[k]+Current.satAdj[JudgeBy][Intensity],middle);
|
||||
else if (P[k] == m)
|
||||
P[k] = MIN(P[k]-Current.satAdj[JudgeBy][Intensity],middle);
|
||||
}
|
||||
P[0] += Current.redAdj[JudgeBy][Intensity];
|
||||
P[1] += Current.greenAdj[JudgeBy][Intensity];
|
||||
P[2] += Current.blueAdj[JudgeBy][Intensity];
|
||||
|
||||
|
||||
P[0] += Current.redAdj[JudgeBy][Intensity];
|
||||
P[1] += Current.greenAdj[JudgeBy][Intensity];
|
||||
P[2] += Current.blueAdj[JudgeBy][Intensity];
|
||||
|
||||
P[0] = MAX(0,MIN(255, P[0]));
|
||||
P[1] = MAX(0,MIN(255, P[1]));
|
||||
P[2] = MAX(0,MIN(255, P[2]));
|
||||
}
|
||||
dest_row[col*bytes + 0] = P[0];
|
||||
dest_row[col*bytes + 1] = P[1];
|
||||
dest_row[col*bytes + 2] = P[2];
|
||||
|
||||
if (bytes>3)
|
||||
for (bytenum = 3; bytenum<bytes; bytenum++)
|
||||
dest_row[col*bytes+bytenum] = src_row[col*bytes+bytenum];
|
||||
P[0] = MAX (0, MIN (255, P[0]));
|
||||
P[1] = MAX (0, MIN (255, P[1]));
|
||||
P[2] = MAX (0, MIN (255, P[2]));
|
||||
}
|
||||
|
||||
dest_row[col * bytes + 0] = P[0];
|
||||
dest_row[col * bytes + 1] = P[1];
|
||||
dest_row[col * bytes + 2] = P[2];
|
||||
|
||||
if (bytes > 3)
|
||||
for (bytenum = 3; bytenum < bytes; bytenum++)
|
||||
dest_row[col * bytes + bytenum] = src_row[col * bytes + bytenum];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
118
plug-ins/fp/fp.c
118
plug-ins/fp/fp.c
|
@ -150,72 +150,78 @@ fp_row (const guchar *src_row,
|
|||
gint row_width,
|
||||
gint bytes)
|
||||
{
|
||||
gint col, bytenum, k;
|
||||
int JudgeBy, Intensity=0, P[3], backupP[3];
|
||||
hsv H,S,V;
|
||||
gint M, m, middle;
|
||||
gint col, bytenum, k;
|
||||
gint JudgeBy, Intensity=0, P[3], backupP[3];
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
gint M, m, middle;
|
||||
|
||||
for (col = 0; col < row_width ; col++)
|
||||
{
|
||||
|
||||
backupP[0] = P[0] = src_row[col*bytes+0];
|
||||
backupP[0] = P[1] = src_row[col*bytes+1];
|
||||
backupP[0] = P[2] = src_row[col*bytes+2];
|
||||
backupP[0] = P[0] = src_row[col * bytes + 0];
|
||||
backupP[0] = P[1] = src_row[col * bytes + 1];
|
||||
backupP[0] = P[2] = src_row[col * bytes + 2];
|
||||
|
||||
H = P[0]/255.0;
|
||||
S = P[1]/255.0;
|
||||
V = P[2]/255.0;
|
||||
gimp_rgb_to_hsv_double(&H, &S, &V);
|
||||
gimp_rgb_set_uchar (&rgb, (guchar) P[0], (guchar) P[1], (guchar) P[2]);
|
||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
||||
|
||||
for (JudgeBy = BY_HUE; JudgeBy < JUDGE_BY; JudgeBy++)
|
||||
{
|
||||
if (! Current.Touched[JudgeBy])
|
||||
continue;
|
||||
|
||||
switch (JudgeBy)
|
||||
{
|
||||
case BY_HUE:
|
||||
Intensity = 255 * hsv.h;
|
||||
break;
|
||||
|
||||
case BY_SAT:
|
||||
Intensity = 255 * hsv.s;
|
||||
break;
|
||||
|
||||
case BY_VAL:
|
||||
Intensity = 255 * hsv.v;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* It's important to take care of Saturation first!!! */
|
||||
|
||||
for (JudgeBy=BY_HUE; JudgeBy<JUDGE_BY; JudgeBy++) {
|
||||
if (!Current.Touched[JudgeBy]) continue;
|
||||
|
||||
switch (JudgeBy) {
|
||||
case BY_HUE:
|
||||
Intensity=255*H;
|
||||
break;
|
||||
case BY_SAT:
|
||||
Intensity=255*S;
|
||||
break;
|
||||
case BY_VAL:
|
||||
Intensity=255*V;
|
||||
break;
|
||||
}
|
||||
m = MIN (MIN (P[0], P[1]), P[2]);
|
||||
M = MAX (MAX (P[0], P[1]), P[2]);
|
||||
middle = (M + m) / 2;
|
||||
|
||||
|
||||
/* It's important to take care of Saturation first!!! */
|
||||
for (k = 0; k < 3; k++)
|
||||
if (P[k] != m && P[k] != M)
|
||||
middle = P[k];
|
||||
|
||||
m = MIN(MIN(P[0],P[1]),P[2]);
|
||||
M = MAX(MAX(P[0],P[1]),P[2]);
|
||||
middle=(M+m)/2;
|
||||
for (k = 0; k < 3; k++)
|
||||
if (M != m)
|
||||
{
|
||||
if (P[k] == M)
|
||||
P[k] = MAX (P[k] + Current.satAdj[JudgeBy][Intensity], middle);
|
||||
else if (P[k] == m)
|
||||
P[k] = MIN (P[k] - Current.satAdj[JudgeBy][Intensity], middle);
|
||||
}
|
||||
|
||||
for (k=0; k<3; k++)
|
||||
if (P[k]!=m && P[k]!=M) middle=P[k];
|
||||
|
||||
for (k=0; k<3; k++)
|
||||
if (M!=m) {
|
||||
if (P[k] == M)
|
||||
P[k] = MAX(P[k]+Current.satAdj[JudgeBy][Intensity],middle);
|
||||
else if (P[k] == m)
|
||||
P[k] = MIN(P[k]-Current.satAdj[JudgeBy][Intensity],middle);
|
||||
}
|
||||
P[0] += Current.redAdj[JudgeBy][Intensity];
|
||||
P[1] += Current.greenAdj[JudgeBy][Intensity];
|
||||
P[2] += Current.blueAdj[JudgeBy][Intensity];
|
||||
|
||||
|
||||
P[0] += Current.redAdj[JudgeBy][Intensity];
|
||||
P[1] += Current.greenAdj[JudgeBy][Intensity];
|
||||
P[2] += Current.blueAdj[JudgeBy][Intensity];
|
||||
|
||||
P[0] = MAX(0,MIN(255, P[0]));
|
||||
P[1] = MAX(0,MIN(255, P[1]));
|
||||
P[2] = MAX(0,MIN(255, P[2]));
|
||||
}
|
||||
dest_row[col*bytes + 0] = P[0];
|
||||
dest_row[col*bytes + 1] = P[1];
|
||||
dest_row[col*bytes + 2] = P[2];
|
||||
|
||||
if (bytes>3)
|
||||
for (bytenum = 3; bytenum<bytes; bytenum++)
|
||||
dest_row[col*bytes+bytenum] = src_row[col*bytes+bytenum];
|
||||
P[0] = MAX (0, MIN (255, P[0]));
|
||||
P[1] = MAX (0, MIN (255, P[1]));
|
||||
P[2] = MAX (0, MIN (255, P[2]));
|
||||
}
|
||||
|
||||
dest_row[col * bytes + 0] = P[0];
|
||||
dest_row[col * bytes + 1] = P[1];
|
||||
dest_row[col * bytes + 2] = P[2];
|
||||
|
||||
if (bytes > 3)
|
||||
for (bytenum = 3; bytenum < bytes; bytenum++)
|
||||
dest_row[col * bytes + bytenum] = src_row[col * bytes + bytenum];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,11 @@ typedef struct {
|
|||
gint run;
|
||||
} fpInterface;
|
||||
|
||||
typedef double hsv;
|
||||
|
||||
typedef struct {
|
||||
gint width;
|
||||
gint height;
|
||||
guchar *rgb;
|
||||
hsv *hsv;
|
||||
gdouble *hsv;
|
||||
guchar *mask;
|
||||
} ReducedImage;
|
||||
|
||||
|
|
|
@ -50,97 +50,106 @@ ReducedImage *Reduce_The_Image(GimpDrawable *drawable,
|
|||
gint LongerSize,
|
||||
gint Slctn)
|
||||
{
|
||||
gint RH, RW, width, height, bytes=drawable->bpp;
|
||||
ReducedImage *temp=(ReducedImage *)malloc(sizeof(ReducedImage));
|
||||
guchar *tempRGB, *src_row, *tempmask, *src_mask_row,R,G,B;
|
||||
gint i, j, whichcol, whichrow, x1, x2, y1, y2;
|
||||
GimpPixelRgn srcPR, srcMask;
|
||||
gint NoSelectionMade=TRUE;
|
||||
hsv *tempHSV, H, S, V;
|
||||
gint RH, RW, width, height, bytes=drawable->bpp;
|
||||
ReducedImage *temp = (ReducedImage *) malloc (sizeof (ReducedImage));
|
||||
guchar *tempRGB, *src_row, *tempmask, *src_mask_row, R, G, B;
|
||||
gint i, j, whichcol, whichrow, x1, x2, y1, y2;
|
||||
GimpPixelRgn srcPR, srcMask;
|
||||
gboolean NoSelectionMade=TRUE;
|
||||
gdouble *tempHSV;
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
width = x2-x1;
|
||||
height = y2-y1;
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
|
||||
if (width != drawable->width && height != drawable->height)
|
||||
NoSelectionMade=FALSE;
|
||||
NoSelectionMade = FALSE;
|
||||
|
||||
if (Slctn==0) {
|
||||
x1=0;
|
||||
x2=drawable->width;
|
||||
y1=0;
|
||||
y2=drawable->height;
|
||||
}
|
||||
if (Slctn == 0)
|
||||
{
|
||||
x1 = 0;
|
||||
x2 = drawable->width;
|
||||
y1 = 0;
|
||||
y2 = drawable->height;
|
||||
}
|
||||
|
||||
if (Slctn==2) {
|
||||
x1=MAX(0, x1-width/2.0);
|
||||
x2=MIN(drawable->width, x2+width/2.0);
|
||||
y1=MAX(0, y1-height/2.0);
|
||||
y2=MIN(drawable->height, y2+height/2.0);
|
||||
}
|
||||
if (Slctn == 2)
|
||||
{
|
||||
x1 = MAX (0, x1 - width / 2.0);
|
||||
x2 = MIN (drawable->width, x2 + width / 2.0);
|
||||
y1 = MAX (0, y1 - height / 2.0);
|
||||
y2 = MIN (drawable->height, y2 + height / 2.0);
|
||||
}
|
||||
|
||||
width = x2-x1;
|
||||
height = y2-y1;
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
|
||||
if (width>height) {
|
||||
RW=LongerSize;
|
||||
RH=(float) height * (float) LongerSize/ (float) width;
|
||||
}
|
||||
else {
|
||||
RH=LongerSize;
|
||||
RW=(float)width * (float) LongerSize/ (float) height;
|
||||
}
|
||||
if (width > height)
|
||||
{
|
||||
RW = LongerSize;
|
||||
RH = (gfloat) height * (gfloat) LongerSize / (gfloat) width;
|
||||
}
|
||||
else
|
||||
{
|
||||
RH = LongerSize;
|
||||
RW = (gfloat) width * (gfloat) LongerSize / (gfloat) height;
|
||||
}
|
||||
|
||||
tempRGB = (guchar *) malloc(RW*RH*bytes);
|
||||
tempHSV = (hsv *) malloc(RW*RH*bytes*sizeof(hsv));
|
||||
tempmask = (guchar *) malloc(RW*RH);
|
||||
tempRGB = (guchar *) malloc (RW * RH * bytes);
|
||||
tempHSV = (gdouble *) malloc (RW * RH * bytes * sizeof (gdouble));
|
||||
tempmask = (guchar *) malloc (RW * RH);
|
||||
|
||||
gimp_pixel_rgn_init (&srcPR, drawable, x1, y1, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init (&srcMask, mask, x1, y1, width, height, FALSE, FALSE);
|
||||
|
||||
src_row = (guchar *) malloc (width*bytes);
|
||||
src_mask_row = (guchar *) malloc (width*bytes);
|
||||
|
||||
for (i=0; i<RH; i++) {
|
||||
whichrow=(float)i*(float)height/(float)RH;
|
||||
gimp_pixel_rgn_get_row (&srcPR, src_row, x1, y1+whichrow, width);
|
||||
gimp_pixel_rgn_get_row (&srcMask, src_mask_row, x1, y1+whichrow, width);
|
||||
src_row = (guchar *) malloc (width * bytes);
|
||||
src_mask_row = (guchar *) malloc (width * bytes);
|
||||
|
||||
for (i = 0; i < RH; i++)
|
||||
{
|
||||
whichrow = (gfloat) i * (gfloat) height / (gfloat) RH;
|
||||
|
||||
gimp_pixel_rgn_get_row (&srcPR, src_row, x1, y1 + whichrow, width);
|
||||
gimp_pixel_rgn_get_row (&srcMask, src_mask_row, x1, y1 + whichrow, width);
|
||||
|
||||
for (j=0; j<RW; j++) {
|
||||
whichcol=(float)j*(float)width/(float)RW;
|
||||
for (j = 0; j < RW; j++)
|
||||
{
|
||||
whichcol = (gfloat) j * (gfloat) width / (gfloat) RW;
|
||||
|
||||
if (NoSelectionMade)
|
||||
tempmask[i*RW+j]=255;
|
||||
else
|
||||
tempmask[i*RW+j]=src_mask_row[whichcol];
|
||||
if (NoSelectionMade)
|
||||
tempmask[i * RW + j] = 255;
|
||||
else
|
||||
tempmask[i * RW + j] = src_mask_row[whichcol];
|
||||
|
||||
R=src_row[whichcol*bytes+0];
|
||||
G=src_row[whichcol*bytes+1];
|
||||
B=src_row[whichcol*bytes+2];
|
||||
|
||||
H = R/255.0;
|
||||
S = G/255.0;
|
||||
V = B/255.0;
|
||||
gimp_rgb_to_hsv_double(&H,&S,&V);
|
||||
R = src_row[whichcol * bytes + 0];
|
||||
G = src_row[whichcol * bytes + 1];
|
||||
B = src_row[whichcol * bytes + 2];
|
||||
|
||||
tempRGB[i*RW*bytes+j*bytes+0]=R;
|
||||
tempRGB[i*RW*bytes+j*bytes+1]=G;
|
||||
tempRGB[i*RW*bytes+j*bytes+2]=B;
|
||||
gimp_rgb_set_uchar (&rgb, R, G, B);
|
||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
||||
|
||||
tempHSV[i*RW*bytes+j*bytes+0]=H;
|
||||
tempHSV[i*RW*bytes+j*bytes+1]=S;
|
||||
tempHSV[i*RW*bytes+j*bytes+2]=V;
|
||||
tempRGB[i * RW * bytes + j * bytes + 0] = R;
|
||||
tempRGB[i * RW * bytes + j * bytes + 1] = G;
|
||||
tempRGB[i * RW * bytes + j * bytes + 2] = B;
|
||||
|
||||
if (bytes==4)
|
||||
tempRGB[i*RW*bytes+j*bytes+3]=src_row[whichcol*bytes+3];
|
||||
|
||||
tempHSV[i * RW * bytes + j * bytes + 0] = hsv.h;
|
||||
tempHSV[i * RW * bytes + j * bytes + 1] = hsv.s;
|
||||
tempHSV[i * RW * bytes + j * bytes + 2] = hsv.v;
|
||||
|
||||
if (bytes == 4)
|
||||
tempRGB[i * RW * bytes + j * bytes + 3] =
|
||||
src_row[whichcol * bytes + 3];
|
||||
}
|
||||
}
|
||||
}
|
||||
temp->width=RW;
|
||||
temp->height=RH;
|
||||
temp->rgb=tempRGB;
|
||||
temp->hsv=tempHSV;
|
||||
temp->mask=tempmask;
|
||||
|
||||
temp->width = RW;
|
||||
temp->height = RH;
|
||||
temp->rgb = tempRGB;
|
||||
temp->hsv = tempHSV;
|
||||
temp->mask = tempmask;
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
@ -341,47 +350,64 @@ fp_create_smoothness_graph (GtkWidget *preview)
|
|||
}
|
||||
|
||||
void
|
||||
fp_range_preview_spill(GtkWidget *preview, int type)
|
||||
fp_range_preview_spill (GtkWidget *preview,
|
||||
gint type)
|
||||
{
|
||||
guchar data[256*3];
|
||||
int i, j;
|
||||
hsv R,G,B;
|
||||
|
||||
for (i=0; i<RANGE_HEIGHT; i++) {
|
||||
for (j=0; j<256; j++)
|
||||
if (!((j+1)%32)) {
|
||||
data[3*j+0]=255;
|
||||
data[3*j+1]=128;
|
||||
data[3*j+2]=128;
|
||||
}
|
||||
else
|
||||
switch (type) {
|
||||
case BY_VAL:
|
||||
data[3*j+0]=j-Current.Offset;
|
||||
data[3*j+1]=j-Current.Offset;
|
||||
data[3*j+2]=j-Current.Offset;
|
||||
break;
|
||||
case BY_HUE:
|
||||
R = (hsv)((j-Current.Offset+256)%256)/255.0;
|
||||
G = 1.0;
|
||||
B = .5;
|
||||
gimp_hsv_to_rgb_double(&R, &G, &B);
|
||||
data[3*j+0]=R*255;
|
||||
data[3*j+1]=G*255;
|
||||
data[3*j+2]=B*255;
|
||||
break;
|
||||
case BY_SAT:
|
||||
R = .5;
|
||||
G = (hsv)((j-(gint)Current.Offset+256)%256)/255.0;
|
||||
B = .5;
|
||||
gimp_hsv_to_rgb_double(&R,&G,&B);
|
||||
data[3*j+0]=R*255;
|
||||
data[3*j+1]=G*255;
|
||||
data[3*j+2]=B*255;
|
||||
break;
|
||||
}
|
||||
gtk_preview_draw_row( GTK_PREVIEW(preview),data,0,i,256);
|
||||
}
|
||||
guchar data[256 * 3];
|
||||
gint i, j;
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
|
||||
for (i = 0; i < RANGE_HEIGHT; i++)
|
||||
{
|
||||
for (j = 0; j < 256; j++)
|
||||
{
|
||||
if (! ((j + 1) % 32))
|
||||
{
|
||||
data[3 * j + 0] = 255;
|
||||
data[3 * j + 1] = 128;
|
||||
data[3 * j + 2] = 128;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case BY_VAL:
|
||||
data[3 * j + 0] = j - Current.Offset;
|
||||
data[3 * j + 1] = j - Current.Offset;
|
||||
data[3 * j + 2] = j - Current.Offset;
|
||||
break;
|
||||
|
||||
case BY_HUE:
|
||||
gimp_hsv_set (&hsv,
|
||||
((j - Current.Offset + 256) % 256) / 255.0,
|
||||
1.0,
|
||||
0.5);
|
||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
||||
gimp_rgb_get_uchar (&rgb,
|
||||
&data[3 * j + 0],
|
||||
&data[3 * j + 1],
|
||||
&data[3 * j + 2]);
|
||||
break;
|
||||
|
||||
case BY_SAT:
|
||||
gimp_hsv_set (&hsv,
|
||||
0.5,
|
||||
((j-(gint)Current.Offset+256)%256) / 255.0,
|
||||
0.5);
|
||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
||||
gimp_rgb_get_uchar (&rgb,
|
||||
&data[3 * j + 0],
|
||||
&data[3 * j + 1],
|
||||
&data[3 * j + 2]);
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), data, 0, i, 256);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (preview);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue