Commit ce4263f9 authored by Federico Mena's avatar Federico Mena Committed by Arturo Espinosa

red/green/blue parameters are now expected to be in [0, 65535], to be

Fri Jan 30 08:51:16 1998  Federico Mena  <federico@bananoid.nuclecu.unam.mx>

	* gdk/gdkcc.c (gdk_color_context_get_pixel): red/green/blue
 	parameters are now expected to be in [0, 65535], to be consistent
 	with the rest of Gdk.
	(gdk_color_context_get_pixels): Made it use 16-bit color values as
 	well.  Fixed mdist=1000000 buglet (it should start with at least
 	0x1000000).
	(gdk_color_context_get_pixels_incremental): Same as
	gdk_color_context_get_pixels().
parent 4af33fa2
Fri Jan 30 08:51:16 1998 Federico Mena <federico@bananoid.nuclecu.unam.mx>
* gdk/gdkcc.c (gdk_color_context_get_pixel): red/green/blue
parameters are now expected to be in [0, 65535], to be consistent
with the rest of Gdk.
(gdk_color_context_get_pixels): Made it use 16-bit color values as
well. Fixed mdist=1000000 buglet (it should start with at least
0x1000000).
(gdk_color_context_get_pixels_incremental): Same as
gdk_color_context_get_pixels().
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
......
Fri Jan 30 08:51:16 1998 Federico Mena <federico@bananoid.nuclecu.unam.mx>
* gdk/gdkcc.c (gdk_color_context_get_pixel): red/green/blue
parameters are now expected to be in [0, 65535], to be consistent
with the rest of Gdk.
(gdk_color_context_get_pixels): Made it use 16-bit color values as
well. Fixed mdist=1000000 buglet (it should start with at least
0x1000000).
(gdk_color_context_get_pixels_incremental): Same as
gdk_color_context_get_pixels().
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
......
Fri Jan 30 08:51:16 1998 Federico Mena <federico@bananoid.nuclecu.unam.mx>
* gdk/gdkcc.c (gdk_color_context_get_pixel): red/green/blue
parameters are now expected to be in [0, 65535], to be consistent
with the rest of Gdk.
(gdk_color_context_get_pixels): Made it use 16-bit color values as
well. Fixed mdist=1000000 buglet (it should start with at least
0x1000000).
(gdk_color_context_get_pixels_incremental): Same as
gdk_color_context_get_pixels().
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
......
Fri Jan 30 08:51:16 1998 Federico Mena <federico@bananoid.nuclecu.unam.mx>
* gdk/gdkcc.c (gdk_color_context_get_pixel): red/green/blue
parameters are now expected to be in [0, 65535], to be consistent
with the rest of Gdk.
(gdk_color_context_get_pixels): Made it use 16-bit color values as
well. Fixed mdist=1000000 buglet (it should start with at least
0x1000000).
(gdk_color_context_get_pixels_incremental): Same as
gdk_color_context_get_pixels().
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
......
Fri Jan 30 08:51:16 1998 Federico Mena <federico@bananoid.nuclecu.unam.mx>
* gdk/gdkcc.c (gdk_color_context_get_pixel): red/green/blue
parameters are now expected to be in [0, 65535], to be consistent
with the rest of Gdk.
(gdk_color_context_get_pixels): Made it use 16-bit color values as
well. Fixed mdist=1000000 buglet (it should start with at least
0x1000000).
(gdk_color_context_get_pixels_incremental): Same as
gdk_color_context_get_pixels().
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
......
Fri Jan 30 08:51:16 1998 Federico Mena <federico@bananoid.nuclecu.unam.mx>
* gdk/gdkcc.c (gdk_color_context_get_pixel): red/green/blue
parameters are now expected to be in [0, 65535], to be consistent
with the rest of Gdk.
(gdk_color_context_get_pixels): Made it use 16-bit color values as
well. Fixed mdist=1000000 buglet (it should start with at least
0x1000000).
(gdk_color_context_get_pixels_incremental): Same as
gdk_color_context_get_pixels().
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
......
Fri Jan 30 08:51:16 1998 Federico Mena <federico@bananoid.nuclecu.unam.mx>
* gdk/gdkcc.c (gdk_color_context_get_pixel): red/green/blue
parameters are now expected to be in [0, 65535], to be consistent
with the rest of Gdk.
(gdk_color_context_get_pixels): Made it use 16-bit color values as
well. Fixed mdist=1000000 buglet (it should start with at least
0x1000000).
(gdk_color_context_get_pixels_incremental): Same as
gdk_color_context_get_pixels().
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
......
......@@ -52,11 +52,6 @@
* cwikla@wri.com
*/
/* NOTES:
*
* - When a CC is destroyed, remember to destroy the hash table properly.
*/
#include <X11/Xlib.h>
#include <stdlib.h>
......@@ -710,13 +705,9 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
{
gdouble value;
red <<= 8;
green <<= 8;
blue <<= 8;
value = red / 65535.0 * 0.30
+ green / 65535.0 * 0.59
+ blue / 65535.0 * 0.11;
value = (red / 65535.0 * 0.30
+ green / 65535.0 * 0.59
+ blue / 65535.0 * 0.11);
if (value > 0.5)
return cc->white_pixel;
......@@ -728,28 +719,21 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
{
gulong ired, igreen, iblue;
red <<= 8;
green <<= 8;
blue <<= 8;
red = red * 0.30 + green * 0.59 + blue * 0.11;
green = 0;
blue = 0;
if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff)
> ccp->std_cmap.red_max)
if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff) > ccp->std_cmap.red_max)
ired = ccp->std_cmap.red_max;
ired *= ccp->std_cmap.red_mult;
if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff)
> ccp->std_cmap.green_max)
if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff) > ccp->std_cmap.green_max)
igreen = ccp->std_cmap.green_max;
igreen *= ccp->std_cmap.green_mult;
if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff)
> ccp->std_cmap.blue_max)
if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff) > ccp->std_cmap.blue_max)
iblue = ccp->std_cmap.blue_max;
iblue *= ccp->std_cmap.blue_mult;
......@@ -764,10 +748,6 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
{
gulong ired, igreen, iblue;
red <<= 8;
green <<= 8;
blue <<= 8;
if (cc->clut == NULL)
{
red >>= 16 - cc->bits.red;
......@@ -797,10 +777,6 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
GdkColor color;
GdkColor *result;
red <<= 8;
green <<= 8;
blue <<= 8;
color.red = red;
color.green = green;
color.blue = blue;
......@@ -976,15 +952,6 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
my_x_query_colors (cc->colormap, cmap, cmapsize);
/* speedup: downscale here instead of in the matching code */
for (i = 0; i < cmapsize; i++)
{
cmap[i].red >>= 8;
cmap[i].green >>= 8;
cmap[i].blue >>= 8;
}
/* get a close match for any unallocated colors */
counter = nopen;
......@@ -998,7 +965,7 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
i = failed[idx];
mdist = 1000000;
mdist = 0x1000000;
close = -1;
/* Store these vals. Small performance increase as this skips three
......@@ -1015,9 +982,11 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
for (j = 0; (j < cmapsize) && (mdist != 0); j++)
{
rd = ri - cmap[j].red;
gd = gi - cmap[j].green;
bd = bi - cmap[j].blue;
/* Don't replace these by shifts; the sign may get clobbered */
rd = (ri - cmap[j].red) / 256;
gd = (gi - cmap[j].green) / 256;
bd = (bi - cmap[j].blue) / 256;
d = rd * rd + gd * gd + bd * bd;
......@@ -1083,7 +1052,7 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
i = failed[idx];
mdist = 1000000;
mdist = 0x1000000;
close = -1;
/* store */
......@@ -1098,9 +1067,11 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
{
k = allocated[j];
rd = ri - defs[k].red;
gd = gi - defs[k].green;
bd = bi - defs[k].blue;
/* Don't replace these by shifts; the sign may get clobbered */
rd = (ri - defs[k].red) / 256;
gd = (gi - defs[k].green) / 256;
bd = (bi - defs[k].blue) / 256;
d = rd * rd + gd * gd + bd * bd;
......@@ -1247,17 +1218,10 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
cmap[i].red = cmap[i].green = cmap[i].blue = 0;
}
/* read and downscale */
/* read */
my_x_query_colors (cc->colormap, cmap, cmapsize);
for (i = 0; i < cmapsize; i++)
{
cmap[i].red >>= 8;
cmap[i].green >>= 8;
cmap[i].blue >>= 8;
}
/* now match any unallocated colors */
counter = nopen;
......@@ -1271,7 +1235,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
i = failed[idx];
mdist = 1000000;
mdist = 0x1000000;
close = -1;
/* store */
......@@ -1282,9 +1246,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
for (j = 0; (j < cmapsize) && (mdist != 0); j++)
{
rd = ri - cmap[j].red;
gd = gi - cmap[j].green;
bd = bi - cmap[j].blue;
/* Don't replace these by shifts; the sign may get clobbered */
rd = (ri - cmap[j].red) / 256;
gd = (gi - cmap[j].green) / 256;
bd = (bi - cmap[j].blue) / 256;
d = rd * rd + gd * gd + bd * bd;
......@@ -1349,7 +1315,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
i = failed[idx];
mdist = 1000000;
mdist = 0x1000000;
close = -1;
ri = reds[i];
......@@ -1363,10 +1329,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
k = allocated[j];
/* downscale */
/* Don't replace these by shifts; the sign may get clobbered */
rd = ri - defs[k].red;
gd = gi - defs[k].green;
bd = bi - defs[k].blue;
rd = (ri - defs[k].red) / 256;
gd = (gi - defs[k].green) / 256;
bd = (bi - defs[k].blue) / 256;
d = rd * rd + gd * gd + bd * bd;
......
......@@ -52,11 +52,6 @@
* cwikla@wri.com
*/
/* NOTES:
*
* - When a CC is destroyed, remember to destroy the hash table properly.
*/
#include <X11/Xlib.h>
#include <stdlib.h>
......@@ -710,13 +705,9 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
{
gdouble value;
red <<= 8;
green <<= 8;
blue <<= 8;
value = red / 65535.0 * 0.30
+ green / 65535.0 * 0.59
+ blue / 65535.0 * 0.11;
value = (red / 65535.0 * 0.30
+ green / 65535.0 * 0.59
+ blue / 65535.0 * 0.11);
if (value > 0.5)
return cc->white_pixel;
......@@ -728,28 +719,21 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
{
gulong ired, igreen, iblue;
red <<= 8;
green <<= 8;
blue <<= 8;
red = red * 0.30 + green * 0.59 + blue * 0.11;
green = 0;
blue = 0;
if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff)
> ccp->std_cmap.red_max)
if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff) > ccp->std_cmap.red_max)
ired = ccp->std_cmap.red_max;
ired *= ccp->std_cmap.red_mult;
if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff)
> ccp->std_cmap.green_max)
if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff) > ccp->std_cmap.green_max)
igreen = ccp->std_cmap.green_max;
igreen *= ccp->std_cmap.green_mult;
if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff)
> ccp->std_cmap.blue_max)
if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff) > ccp->std_cmap.blue_max)
iblue = ccp->std_cmap.blue_max;
iblue *= ccp->std_cmap.blue_mult;
......@@ -764,10 +748,6 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
{
gulong ired, igreen, iblue;
red <<= 8;
green <<= 8;
blue <<= 8;
if (cc->clut == NULL)
{
red >>= 16 - cc->bits.red;
......@@ -797,10 +777,6 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
GdkColor color;
GdkColor *result;
red <<= 8;
green <<= 8;
blue <<= 8;
color.red = red;
color.green = green;
color.blue = blue;
......@@ -976,15 +952,6 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
my_x_query_colors (cc->colormap, cmap, cmapsize);
/* speedup: downscale here instead of in the matching code */
for (i = 0; i < cmapsize; i++)
{
cmap[i].red >>= 8;
cmap[i].green >>= 8;
cmap[i].blue >>= 8;
}
/* get a close match for any unallocated colors */
counter = nopen;
......@@ -998,7 +965,7 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
i = failed[idx];
mdist = 1000000;
mdist = 0x1000000;
close = -1;
/* Store these vals. Small performance increase as this skips three
......@@ -1015,9 +982,11 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
for (j = 0; (j < cmapsize) && (mdist != 0); j++)
{
rd = ri - cmap[j].red;
gd = gi - cmap[j].green;
bd = bi - cmap[j].blue;
/* Don't replace these by shifts; the sign may get clobbered */
rd = (ri - cmap[j].red) / 256;
gd = (gi - cmap[j].green) / 256;
bd = (bi - cmap[j].blue) / 256;
d = rd * rd + gd * gd + bd * bd;
......@@ -1083,7 +1052,7 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
i = failed[idx];
mdist = 1000000;
mdist = 0x1000000;
close = -1;
/* store */
......@@ -1098,9 +1067,11 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
{
k = allocated[j];
rd = ri - defs[k].red;
gd = gi - defs[k].green;
bd = bi - defs[k].blue;
/* Don't replace these by shifts; the sign may get clobbered */
rd = (ri - defs[k].red) / 256;
gd = (gi - defs[k].green) / 256;
bd = (bi - defs[k].blue) / 256;
d = rd * rd + gd * gd + bd * bd;
......@@ -1247,17 +1218,10 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
cmap[i].red = cmap[i].green = cmap[i].blue = 0;
}
/* read and downscale */
/* read */
my_x_query_colors (cc->colormap, cmap, cmapsize);
for (i = 0; i < cmapsize; i++)
{
cmap[i].red >>= 8;
cmap[i].green >>= 8;
cmap[i].blue >>= 8;
}
/* now match any unallocated colors */
counter = nopen;
......@@ -1271,7 +1235,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
i = failed[idx];
mdist = 1000000;
mdist = 0x1000000;
close = -1;
/* store */
......@@ -1282,9 +1246,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
for (j = 0; (j < cmapsize) && (mdist != 0); j++)
{
rd = ri - cmap[j].red;
gd = gi - cmap[j].green;
bd = bi - cmap[j].blue;
/* Don't replace these by shifts; the sign may get clobbered */
rd = (ri - cmap[j].red) / 256;
gd = (gi - cmap[j].green) / 256;
bd = (bi - cmap[j].blue) / 256;
d = rd * rd + gd * gd + bd * bd;
......@@ -1349,7 +1315,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
i = failed[idx];
mdist = 1000000;
mdist = 0x1000000;
close = -1;
ri = reds[i];
......@@ -1363,10 +1329,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
k = allocated[j];
/* downscale */
/* Don't replace these by shifts; the sign may get clobbered */
rd = ri - defs[k].red;
gd = gi - defs[k].green;
bd = bi - defs[k].blue;
rd = (ri - defs[k].red) / 256;
gd = (gi - defs[k].green) / 256;
bd = (bi - defs[k].blue) / 256;
d = rd * rd + gd * gd + bd * bd;
......
Markdown is supported
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