Commit aa4448db authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/gui/info-window.c libgimpcolor/gimpcolorspace.c libgimpcolor/gimprgb.c

2003-06-13  Sven Neumann  <sven@gimp.org>

	* app/gui/info-window.c
	* libgimpcolor/gimpcolorspace.c
	* libgimpcolor/gimprgb.c
	* libgimpwidgets/gimpcolorscales.c
	* libgimpwidgets/gimpcolorselect.c: use ROUND() where appropriate.

	* libgimpwidgets/gimpcolorarea.c (gimp_color_area_render): use
	gimp_rgb_get_uchar().
parent 4dcb6a37
2003-06-13 Sven Neumann <sven@gimp.org>
* app/gui/info-window.c
* libgimpcolor/gimpcolorspace.c
* libgimpcolor/gimprgb.c
* libgimpwidgets/gimpcolorscales.c
* libgimpwidgets/gimpcolorselect.c: use ROUND() where appropriate.
* libgimpwidgets/gimpcolorarea.c (gimp_color_area_render): use
gimp_rgb_get_uchar().
2003-06-13 Michael Natterer <mitch@gimp.org>
 
Cleaned up and improved the message system:
......@@ -561,13 +561,13 @@ info_window_update_extended (GimpDisplay *gdisp,
color[BLUE_PIX]);
gimp_rgb_to_hsv (&rgb, &hsv);
g_snprintf (buf, sizeof (buf), "%d", (gint) (hsv.h * 359.999 + 0.5));
g_snprintf (buf, sizeof (buf), "%d", ROUND (hsv.h * 360.0));
gtk_label_set_text (GTK_LABEL (iwd->hsv_labels[0]), buf);
g_snprintf (buf, sizeof (buf), "%d", (gint) (hsv.s * 99.999 + 0.5));
g_snprintf (buf, sizeof (buf), "%d", ROUND (hsv.s * 100.0));
gtk_label_set_text (GTK_LABEL (iwd->hsv_labels[1]), buf);
g_snprintf (buf, sizeof (buf), "%d", (gint) (hsv.v * 99.999 + 0.5));
g_snprintf (buf, sizeof (buf), "%d", ROUND (hsv.v * 100.0));
gtk_label_set_text (GTK_LABEL (iwd->hsv_labels[2]), buf);
g_free (color);
......
......@@ -561,13 +561,13 @@ info_window_update_extended (GimpDisplay *gdisp,
color[BLUE_PIX]);
gimp_rgb_to_hsv (&rgb, &hsv);
g_snprintf (buf, sizeof (buf), "%d", (gint) (hsv.h * 359.999 + 0.5));
g_snprintf (buf, sizeof (buf), "%d", ROUND (hsv.h * 360.0));
gtk_label_set_text (GTK_LABEL (iwd->hsv_labels[0]), buf);
g_snprintf (buf, sizeof (buf), "%d", (gint) (hsv.s * 99.999 + 0.5));
g_snprintf (buf, sizeof (buf), "%d", ROUND (hsv.s * 100.0));
gtk_label_set_text (GTK_LABEL (iwd->hsv_labels[1]), buf);
g_snprintf (buf, sizeof (buf), "%d", (gint) (hsv.v * 99.999 + 0.5));
g_snprintf (buf, sizeof (buf), "%d", ROUND (hsv.v * 100.0));
gtk_label_set_text (GTK_LABEL (iwd->hsv_labels[2]), buf);
g_free (color);
......
......@@ -454,39 +454,39 @@ gimp_hsv_to_rgb_int (gint *hue,
switch ((gint) h)
{
case 0:
*hue = v * 255;
*saturation = t * 255;
*value = p * 255;
*hue = ROUND (v * 255.0);
*saturation = ROUND (t * 255.0);
*value = ROUND (p * 255.0);
break;
case 1:
*hue = q * 255;
*saturation = v * 255;
*value = p * 255;
*hue = ROUND (q * 255.0);
*saturation = ROUND (v * 255.0);
*value = ROUND (p * 255.0);
break;
case 2:
*hue = p * 255;
*saturation = v * 255;
*value = t * 255;
*hue = ROUND (p * 255.0);
*saturation = ROUND (v * 255.0);
*value = ROUND (t * 255.0);
break;
case 3:
*hue = p * 255;
*saturation = q * 255;
*value = v * 255;
*hue = ROUND (p * 255.0);
*saturation = ROUND (q * 255.0);
*value = ROUND (v * 255.0);
break;
case 4:
*hue = t * 255;
*saturation = p * 255;
*value = v * 255;
*hue = ROUND (t * 255.0);
*saturation = ROUND (p * 255.0);
*value = ROUND (v * 255.0);
break;
case 5:
*hue = v * 255;
*saturation = p * 255;
*value = q * 255;
*hue = ROUND (v * 255.0);
*saturation = ROUND (p * 255.0);
*value = ROUND (q * 255.0);
break;
}
}
......@@ -767,7 +767,7 @@ gimp_hsv_to_rgb4 (guchar *rgb,
}
}
rgb[0] = hue * 254.999 + 0.5;
rgb[1] = saturation * 254.999 + 0.5;
rgb[2] = value * 254.999 + 0.5;
rgb[0] = ROUND (hue * 255.0);
rgb[1] = ROUND (saturation * 255.0);
rgb[2] = ROUND (value * 255.0);
}
......@@ -73,9 +73,9 @@ gimp_rgb_get_uchar (const GimpRGB *rgb,
{
g_return_if_fail (rgb != NULL);
if (r) *r = CLAMP (rgb->r, 0.0, 1.0) * 254.999 + 0.5;
if (g) *g = CLAMP (rgb->g, 0.0, 1.0) * 254.999 + 0.5;
if (b) *b = CLAMP (rgb->b, 0.0, 1.0) * 254.999 + 0.5;
if (r) *r = ROUND (CLAMP (rgb->r, 0.0, 1.0) * 255.0);
if (g) *g = ROUND (CLAMP (rgb->g, 0.0, 1.0) * 255.0);
if (b) *b = ROUND (CLAMP (rgb->b, 0.0, 1.0) * 255.0);
}
void
......@@ -191,7 +191,7 @@ gimp_rgb_intensity_uchar (const GimpRGB *rgb)
{
g_return_val_if_fail (rgb != NULL, 0);
return gimp_rgb_intensity (rgb) * 254.999 + 0.5;
return ROUND (gimp_rgb_intensity (rgb) * 255.0);
}
void
......@@ -280,10 +280,10 @@ gimp_rgba_get_uchar (const GimpRGB *rgba,
{
g_return_if_fail (rgba != NULL);
if (r) *r = CLAMP (rgba->r, 0.0, 1.0) * 254.999 + 0.5;
if (g) *g = CLAMP (rgba->g, 0.0, 1.0) * 254.999 + 0.5;
if (b) *b = CLAMP (rgba->b, 0.0, 1.0) * 254.999 + 0.5;
if (a) *a = CLAMP (rgba->a, 0.0, 1.0) * 254.999 + 0.5;
if (r) *r = ROUND (CLAMP (rgba->r, 0.0, 1.0) * 255.0);
if (g) *g = ROUND (CLAMP (rgba->g, 0.0, 1.0) * 255.0);
if (b) *b = ROUND (CLAMP (rgba->b, 0.0, 1.0) * 255.0);
if (a) *a = ROUND (CLAMP (rgba->a, 0.0, 1.0) * 255.0);
}
void
......
......@@ -417,10 +417,8 @@ gimp_color_area_render (GimpColorArea *area)
check_size = GIMP_CHECK_SIZE;
break;
}
opaque[0] = area->color.r * 255.999;
opaque[1] = area->color.g * 255.999;
opaque[2] = area->color.b * 255.999;
gimp_rgb_get_uchar (&area->color, opaque, opaque + 1, opaque + 2);
if (area->color.a == 1.0 || !check_size)
{
......
......@@ -32,6 +32,7 @@
#include <gdk/gdkkeysyms.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "gimpwidgetstypes.h"
......@@ -386,13 +387,13 @@ gimp_color_scales_update_scales (GimpColorScales *scales,
selector = GIMP_COLOR_SELECTOR (scales);
values[GIMP_COLOR_SELECTOR_HUE] = (gint) (selector->hsv.h * 359.999 + 0.5);
values[GIMP_COLOR_SELECTOR_SATURATION] = (gint) (selector->hsv.s * 99.999 + 0.5);
values[GIMP_COLOR_SELECTOR_VALUE] = (gint) (selector->hsv.v * 99.999 + 0.5);
values[GIMP_COLOR_SELECTOR_RED] = (gint) (selector->rgb.r * 254.999 + 0.5);
values[GIMP_COLOR_SELECTOR_GREEN] = (gint) (selector->rgb.g * 254.999 + 0.5);
values[GIMP_COLOR_SELECTOR_BLUE] = (gint) (selector->rgb.b * 254.999 + 0.5);
values[GIMP_COLOR_SELECTOR_ALPHA] = (gint) (selector->rgb.a * 99.999 + 0.5);
values[GIMP_COLOR_SELECTOR_HUE] = ROUND (selector->hsv.h * 360.0);
values[GIMP_COLOR_SELECTOR_SATURATION] = ROUND (selector->hsv.s * 100.0);
values[GIMP_COLOR_SELECTOR_VALUE] = ROUND (selector->hsv.v * 100.0);
values[GIMP_COLOR_SELECTOR_RED] = ROUND (selector->rgb.r * 255.0);
values[GIMP_COLOR_SELECTOR_GREEN] = ROUND (selector->rgb.g * 255.0);
values[GIMP_COLOR_SELECTOR_BLUE] = ROUND (selector->rgb.b * 255.0);
values[GIMP_COLOR_SELECTOR_ALPHA] = ROUND (selector->rgb.a * 100.0);
for (i = 0; i < 7; i++)
{
......
......@@ -34,6 +34,7 @@
#include <gdk/gdkkeysyms.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "gimpwidgetstypes.h"
......@@ -621,35 +622,35 @@ gimp_color_select_update_pos (GimpColorSelect *select)
switch (select->z_color_fill)
{
case COLOR_SELECT_RED:
select->pos[0] = (gint) (selector->rgb.b * 254.999 + 0.5);
select->pos[1] = (gint) (selector->rgb.g * 254.999 + 0.5);
select->pos[2] = (gint) (selector->rgb.r * 254.999 + 0.5);
select->pos[0] = ROUND (selector->rgb.b * 255.0);
select->pos[1] = ROUND (selector->rgb.g * 255.0);
select->pos[2] = ROUND (selector->rgb.r * 255.0);
break;
case COLOR_SELECT_GREEN:
select->pos[0] = (gint) (selector->rgb.b * 254.999 + 0.5);
select->pos[1] = (gint) (selector->rgb.r * 254.999 + 0.5);
select->pos[2] = (gint) (selector->rgb.g * 254.999 + 0.5);
select->pos[0] = ROUND (selector->rgb.b * 255.0);
select->pos[1] = ROUND (selector->rgb.r * 255.0);
select->pos[2] = ROUND (selector->rgb.g * 255.0);
break;
case COLOR_SELECT_BLUE:
select->pos[0] = (gint) (selector->rgb.g * 254.999 + 0.5);
select->pos[1] = (gint) (selector->rgb.r * 254.999 + 0.5);
select->pos[2] = (gint) (selector->rgb.b * 254.999 + 0.5);
select->pos[0] = ROUND (selector->rgb.g * 255.0);
select->pos[1] = ROUND (selector->rgb.r * 255.0);
select->pos[2] = ROUND (selector->rgb.b * 255.0);
break;
case COLOR_SELECT_HUE:
select->pos[0] = (gint) (selector->hsv.v * 254.999 + 0.5);
select->pos[1] = (gint) (selector->hsv.s * 254.999 + 0.5);
select->pos[2] = (gint) (selector->hsv.h * 254.999 + 0.5);
select->pos[0] = ROUND (selector->hsv.v * 255.0);
select->pos[1] = ROUND (selector->hsv.s * 255.0);
select->pos[2] = ROUND (selector->hsv.h * 255.0);
break;
case COLOR_SELECT_SATURATION:
select->pos[0] = (gint) (selector->hsv.v * 254.999 + 0.5);
select->pos[1] = (gint) (selector->hsv.h * 254.999 + 0.5);
select->pos[2] = (gint) (selector->hsv.s * 254.999 + 0.5);
select->pos[0] = ROUND (selector->hsv.v * 255.0);
select->pos[1] = ROUND (selector->hsv.h * 255.0);
select->pos[2] = ROUND (selector->hsv.s * 255.0);
break;
case COLOR_SELECT_VALUE:
select->pos[0] = (gint) (selector->hsv.s * 254.999 + 0.5);
select->pos[1] = (gint) (selector->hsv.h * 254.999 + 0.5);
select->pos[2] = (gint) (selector->hsv.v * 254.999 + 0.5);
select->pos[0] = ROUND (selector->hsv.s * 255.0);
select->pos[1] = ROUND (selector->hsv.h * 255.0);
select->pos[2] = ROUND (selector->hsv.v * 255.0);
break;
default:
......@@ -743,14 +744,8 @@ gimp_color_select_xy_events (GtkWidget *widget,
select->pos[0] = (x * 255) / (XY_DEF_WIDTH - 1);
select->pos[1] = 255 - (y * 255) / (XY_DEF_HEIGHT - 1);
if (select->pos[0] < 0)
select->pos[0] = 0;
if (select->pos[0] > 255)
select->pos[0] = 255;
if (select->pos[1] < 0)
select->pos[1] = 0;
if (select->pos[1] > 255)
select->pos[1] = 255;
select->pos[0] = CLAMP (select->pos[0], 0, 255);
select->pos[1] = CLAMP (select->pos[1], 0, 255);
gimp_color_select_draw_xy_marker (select, NULL);
gimp_color_select_update (select, UPDATE_VALUES | UPDATE_CALLER);
......@@ -1139,7 +1134,7 @@ color_select_update_red_green (ColorSelectFill *csf)
p = csf->buffer;
csf->y += 1;
b = (gint) (csf->rgb.b * 254.999 + 0.5);
b = ROUND (csf->rgb.b * 255.0);
r = (csf->height - csf->y + 1) * 255 / csf->height;
if (r < 0)
......@@ -1170,7 +1165,7 @@ color_select_update_red_blue (ColorSelectFill *csf)
p = csf->buffer;
csf->y += 1;
g = (gint) (csf->rgb.g * 254.999 + 0.5);
g = ROUND (csf->rgb.g * 255.0);
r = (csf->height - csf->y + 1) * 255 / csf->height;
if (r < 0)
......@@ -1201,7 +1196,7 @@ color_select_update_green_blue (ColorSelectFill *csf)
p = csf->buffer;
csf->y += 1;
r = (gint) (csf->rgb.r * 254.999 + 0.5);
r = ROUND (csf->rgb.r * 255.0);
g = (csf->height - csf->y + 1) * 255 / csf->height;
if (g < 0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment