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().
This commit is contained in:
committed by
Arturo Espinosa
parent
4af33fa24d
commit
ce4263f901
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
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>
|
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||||
|
|
||||||
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
||||||
|
|||||||
@ -1,3 +1,14 @@
|
|||||||
|
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>
|
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||||
|
|
||||||
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
||||||
|
|||||||
@ -1,3 +1,14 @@
|
|||||||
|
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>
|
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||||
|
|
||||||
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
||||||
|
|||||||
@ -1,3 +1,14 @@
|
|||||||
|
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>
|
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||||
|
|
||||||
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
||||||
|
|||||||
@ -1,3 +1,14 @@
|
|||||||
|
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>
|
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||||
|
|
||||||
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
||||||
|
|||||||
@ -1,3 +1,14 @@
|
|||||||
|
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>
|
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||||
|
|
||||||
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
||||||
|
|||||||
@ -1,3 +1,14 @@
|
|||||||
|
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>
|
Thu Jan 29 22:57:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||||
|
|
||||||
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
* gtk/gtkstyle.c (gtk_default_draw_polygon): Close
|
||||||
|
|||||||
93
gdk/gdkcc.c
93
gdk/gdkcc.c
@ -52,11 +52,6 @@
|
|||||||
* cwikla@wri.com
|
* cwikla@wri.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* NOTES:
|
|
||||||
*
|
|
||||||
* - When a CC is destroyed, remember to destroy the hash table properly.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -710,13 +705,9 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
|
|||||||
{
|
{
|
||||||
gdouble value;
|
gdouble value;
|
||||||
|
|
||||||
red <<= 8;
|
value = (red / 65535.0 * 0.30
|
||||||
green <<= 8;
|
+ green / 65535.0 * 0.59
|
||||||
blue <<= 8;
|
+ 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)
|
if (value > 0.5)
|
||||||
return cc->white_pixel;
|
return cc->white_pixel;
|
||||||
@ -728,28 +719,21 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
|
|||||||
{
|
{
|
||||||
gulong ired, igreen, iblue;
|
gulong ired, igreen, iblue;
|
||||||
|
|
||||||
red <<= 8;
|
|
||||||
green <<= 8;
|
|
||||||
blue <<= 8;
|
|
||||||
|
|
||||||
red = red * 0.30 + green * 0.59 + blue * 0.11;
|
red = red * 0.30 + green * 0.59 + blue * 0.11;
|
||||||
green = 0;
|
green = 0;
|
||||||
blue = 0;
|
blue = 0;
|
||||||
|
|
||||||
if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff)
|
if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff) > ccp->std_cmap.red_max)
|
||||||
> ccp->std_cmap.red_max)
|
|
||||||
ired = ccp->std_cmap.red_max;
|
ired = ccp->std_cmap.red_max;
|
||||||
|
|
||||||
ired *= ccp->std_cmap.red_mult;
|
ired *= ccp->std_cmap.red_mult;
|
||||||
|
|
||||||
if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff)
|
if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff) > ccp->std_cmap.green_max)
|
||||||
> ccp->std_cmap.green_max)
|
|
||||||
igreen = ccp->std_cmap.green_max;
|
igreen = ccp->std_cmap.green_max;
|
||||||
|
|
||||||
igreen *= ccp->std_cmap.green_mult;
|
igreen *= ccp->std_cmap.green_mult;
|
||||||
|
|
||||||
if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff)
|
if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff) > ccp->std_cmap.blue_max)
|
||||||
> ccp->std_cmap.blue_max)
|
|
||||||
iblue = ccp->std_cmap.blue_max;
|
iblue = ccp->std_cmap.blue_max;
|
||||||
|
|
||||||
iblue *= ccp->std_cmap.blue_mult;
|
iblue *= ccp->std_cmap.blue_mult;
|
||||||
@ -764,10 +748,6 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
|
|||||||
{
|
{
|
||||||
gulong ired, igreen, iblue;
|
gulong ired, igreen, iblue;
|
||||||
|
|
||||||
red <<= 8;
|
|
||||||
green <<= 8;
|
|
||||||
blue <<= 8;
|
|
||||||
|
|
||||||
if (cc->clut == NULL)
|
if (cc->clut == NULL)
|
||||||
{
|
{
|
||||||
red >>= 16 - cc->bits.red;
|
red >>= 16 - cc->bits.red;
|
||||||
@ -797,10 +777,6 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
|
|||||||
GdkColor color;
|
GdkColor color;
|
||||||
GdkColor *result;
|
GdkColor *result;
|
||||||
|
|
||||||
red <<= 8;
|
|
||||||
green <<= 8;
|
|
||||||
blue <<= 8;
|
|
||||||
|
|
||||||
color.red = red;
|
color.red = red;
|
||||||
color.green = green;
|
color.green = green;
|
||||||
color.blue = blue;
|
color.blue = blue;
|
||||||
@ -976,15 +952,6 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
|
|||||||
|
|
||||||
my_x_query_colors (cc->colormap, cmap, cmapsize);
|
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 */
|
/* get a close match for any unallocated colors */
|
||||||
|
|
||||||
counter = nopen;
|
counter = nopen;
|
||||||
@ -998,7 +965,7 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
|
|||||||
|
|
||||||
i = failed[idx];
|
i = failed[idx];
|
||||||
|
|
||||||
mdist = 1000000;
|
mdist = 0x1000000;
|
||||||
close = -1;
|
close = -1;
|
||||||
|
|
||||||
/* Store these vals. Small performance increase as this skips three
|
/* 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++)
|
for (j = 0; (j < cmapsize) && (mdist != 0); j++)
|
||||||
{
|
{
|
||||||
rd = ri - cmap[j].red;
|
/* Don't replace these by shifts; the sign may get clobbered */
|
||||||
gd = gi - cmap[j].green;
|
|
||||||
bd = bi - cmap[j].blue;
|
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;
|
d = rd * rd + gd * gd + bd * bd;
|
||||||
|
|
||||||
@ -1083,7 +1052,7 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
|
|||||||
|
|
||||||
i = failed[idx];
|
i = failed[idx];
|
||||||
|
|
||||||
mdist = 1000000;
|
mdist = 0x1000000;
|
||||||
close = -1;
|
close = -1;
|
||||||
|
|
||||||
/* store */
|
/* store */
|
||||||
@ -1098,9 +1067,11 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
|
|||||||
{
|
{
|
||||||
k = allocated[j];
|
k = allocated[j];
|
||||||
|
|
||||||
rd = ri - defs[k].red;
|
/* Don't replace these by shifts; the sign may get clobbered */
|
||||||
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;
|
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;
|
cmap[i].red = cmap[i].green = cmap[i].blue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read and downscale */
|
/* read */
|
||||||
|
|
||||||
my_x_query_colors (cc->colormap, cmap, cmapsize);
|
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 */
|
/* now match any unallocated colors */
|
||||||
|
|
||||||
counter = nopen;
|
counter = nopen;
|
||||||
@ -1271,7 +1235,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
|
|||||||
|
|
||||||
i = failed[idx];
|
i = failed[idx];
|
||||||
|
|
||||||
mdist = 1000000;
|
mdist = 0x1000000;
|
||||||
close = -1;
|
close = -1;
|
||||||
|
|
||||||
/* store */
|
/* store */
|
||||||
@ -1282,9 +1246,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
|
|||||||
|
|
||||||
for (j = 0; (j < cmapsize) && (mdist != 0); j++)
|
for (j = 0; (j < cmapsize) && (mdist != 0); j++)
|
||||||
{
|
{
|
||||||
rd = ri - cmap[j].red;
|
/* Don't replace these by shifts; the sign may get clobbered */
|
||||||
gd = gi - cmap[j].green;
|
|
||||||
bd = bi - cmap[j].blue;
|
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;
|
d = rd * rd + gd * gd + bd * bd;
|
||||||
|
|
||||||
@ -1349,7 +1315,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
|
|||||||
|
|
||||||
i = failed[idx];
|
i = failed[idx];
|
||||||
|
|
||||||
mdist = 1000000;
|
mdist = 0x1000000;
|
||||||
close = -1;
|
close = -1;
|
||||||
|
|
||||||
ri = reds[i];
|
ri = reds[i];
|
||||||
@ -1363,10 +1329,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
|
|||||||
k = allocated[j];
|
k = allocated[j];
|
||||||
|
|
||||||
/* downscale */
|
/* downscale */
|
||||||
|
/* Don't replace these by shifts; the sign may get clobbered */
|
||||||
|
|
||||||
rd = ri - defs[k].red;
|
rd = (ri - defs[k].red) / 256;
|
||||||
gd = gi - defs[k].green;
|
gd = (gi - defs[k].green) / 256;
|
||||||
bd = bi - defs[k].blue;
|
bd = (bi - defs[k].blue) / 256;
|
||||||
|
|
||||||
d = rd * rd + gd * gd + bd * bd;
|
d = rd * rd + gd * gd + bd * bd;
|
||||||
|
|
||||||
|
|||||||
@ -52,11 +52,6 @@
|
|||||||
* cwikla@wri.com
|
* cwikla@wri.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* NOTES:
|
|
||||||
*
|
|
||||||
* - When a CC is destroyed, remember to destroy the hash table properly.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -710,13 +705,9 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
|
|||||||
{
|
{
|
||||||
gdouble value;
|
gdouble value;
|
||||||
|
|
||||||
red <<= 8;
|
value = (red / 65535.0 * 0.30
|
||||||
green <<= 8;
|
+ green / 65535.0 * 0.59
|
||||||
blue <<= 8;
|
+ 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)
|
if (value > 0.5)
|
||||||
return cc->white_pixel;
|
return cc->white_pixel;
|
||||||
@ -728,28 +719,21 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
|
|||||||
{
|
{
|
||||||
gulong ired, igreen, iblue;
|
gulong ired, igreen, iblue;
|
||||||
|
|
||||||
red <<= 8;
|
|
||||||
green <<= 8;
|
|
||||||
blue <<= 8;
|
|
||||||
|
|
||||||
red = red * 0.30 + green * 0.59 + blue * 0.11;
|
red = red * 0.30 + green * 0.59 + blue * 0.11;
|
||||||
green = 0;
|
green = 0;
|
||||||
blue = 0;
|
blue = 0;
|
||||||
|
|
||||||
if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff)
|
if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff) > ccp->std_cmap.red_max)
|
||||||
> ccp->std_cmap.red_max)
|
|
||||||
ired = ccp->std_cmap.red_max;
|
ired = ccp->std_cmap.red_max;
|
||||||
|
|
||||||
ired *= ccp->std_cmap.red_mult;
|
ired *= ccp->std_cmap.red_mult;
|
||||||
|
|
||||||
if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff)
|
if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff) > ccp->std_cmap.green_max)
|
||||||
> ccp->std_cmap.green_max)
|
|
||||||
igreen = ccp->std_cmap.green_max;
|
igreen = ccp->std_cmap.green_max;
|
||||||
|
|
||||||
igreen *= ccp->std_cmap.green_mult;
|
igreen *= ccp->std_cmap.green_mult;
|
||||||
|
|
||||||
if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff)
|
if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff) > ccp->std_cmap.blue_max)
|
||||||
> ccp->std_cmap.blue_max)
|
|
||||||
iblue = ccp->std_cmap.blue_max;
|
iblue = ccp->std_cmap.blue_max;
|
||||||
|
|
||||||
iblue *= ccp->std_cmap.blue_mult;
|
iblue *= ccp->std_cmap.blue_mult;
|
||||||
@ -764,10 +748,6 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
|
|||||||
{
|
{
|
||||||
gulong ired, igreen, iblue;
|
gulong ired, igreen, iblue;
|
||||||
|
|
||||||
red <<= 8;
|
|
||||||
green <<= 8;
|
|
||||||
blue <<= 8;
|
|
||||||
|
|
||||||
if (cc->clut == NULL)
|
if (cc->clut == NULL)
|
||||||
{
|
{
|
||||||
red >>= 16 - cc->bits.red;
|
red >>= 16 - cc->bits.red;
|
||||||
@ -797,10 +777,6 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
|
|||||||
GdkColor color;
|
GdkColor color;
|
||||||
GdkColor *result;
|
GdkColor *result;
|
||||||
|
|
||||||
red <<= 8;
|
|
||||||
green <<= 8;
|
|
||||||
blue <<= 8;
|
|
||||||
|
|
||||||
color.red = red;
|
color.red = red;
|
||||||
color.green = green;
|
color.green = green;
|
||||||
color.blue = blue;
|
color.blue = blue;
|
||||||
@ -976,15 +952,6 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
|
|||||||
|
|
||||||
my_x_query_colors (cc->colormap, cmap, cmapsize);
|
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 */
|
/* get a close match for any unallocated colors */
|
||||||
|
|
||||||
counter = nopen;
|
counter = nopen;
|
||||||
@ -998,7 +965,7 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
|
|||||||
|
|
||||||
i = failed[idx];
|
i = failed[idx];
|
||||||
|
|
||||||
mdist = 1000000;
|
mdist = 0x1000000;
|
||||||
close = -1;
|
close = -1;
|
||||||
|
|
||||||
/* Store these vals. Small performance increase as this skips three
|
/* 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++)
|
for (j = 0; (j < cmapsize) && (mdist != 0); j++)
|
||||||
{
|
{
|
||||||
rd = ri - cmap[j].red;
|
/* Don't replace these by shifts; the sign may get clobbered */
|
||||||
gd = gi - cmap[j].green;
|
|
||||||
bd = bi - cmap[j].blue;
|
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;
|
d = rd * rd + gd * gd + bd * bd;
|
||||||
|
|
||||||
@ -1083,7 +1052,7 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
|
|||||||
|
|
||||||
i = failed[idx];
|
i = failed[idx];
|
||||||
|
|
||||||
mdist = 1000000;
|
mdist = 0x1000000;
|
||||||
close = -1;
|
close = -1;
|
||||||
|
|
||||||
/* store */
|
/* store */
|
||||||
@ -1098,9 +1067,11 @@ gdk_color_context_get_pixels (GdkColorContext *cc,
|
|||||||
{
|
{
|
||||||
k = allocated[j];
|
k = allocated[j];
|
||||||
|
|
||||||
rd = ri - defs[k].red;
|
/* Don't replace these by shifts; the sign may get clobbered */
|
||||||
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;
|
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;
|
cmap[i].red = cmap[i].green = cmap[i].blue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read and downscale */
|
/* read */
|
||||||
|
|
||||||
my_x_query_colors (cc->colormap, cmap, cmapsize);
|
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 */
|
/* now match any unallocated colors */
|
||||||
|
|
||||||
counter = nopen;
|
counter = nopen;
|
||||||
@ -1271,7 +1235,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
|
|||||||
|
|
||||||
i = failed[idx];
|
i = failed[idx];
|
||||||
|
|
||||||
mdist = 1000000;
|
mdist = 0x1000000;
|
||||||
close = -1;
|
close = -1;
|
||||||
|
|
||||||
/* store */
|
/* store */
|
||||||
@ -1282,9 +1246,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
|
|||||||
|
|
||||||
for (j = 0; (j < cmapsize) && (mdist != 0); j++)
|
for (j = 0; (j < cmapsize) && (mdist != 0); j++)
|
||||||
{
|
{
|
||||||
rd = ri - cmap[j].red;
|
/* Don't replace these by shifts; the sign may get clobbered */
|
||||||
gd = gi - cmap[j].green;
|
|
||||||
bd = bi - cmap[j].blue;
|
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;
|
d = rd * rd + gd * gd + bd * bd;
|
||||||
|
|
||||||
@ -1349,7 +1315,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
|
|||||||
|
|
||||||
i = failed[idx];
|
i = failed[idx];
|
||||||
|
|
||||||
mdist = 1000000;
|
mdist = 0x1000000;
|
||||||
close = -1;
|
close = -1;
|
||||||
|
|
||||||
ri = reds[i];
|
ri = reds[i];
|
||||||
@ -1363,10 +1329,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
|
|||||||
k = allocated[j];
|
k = allocated[j];
|
||||||
|
|
||||||
/* downscale */
|
/* downscale */
|
||||||
|
/* Don't replace these by shifts; the sign may get clobbered */
|
||||||
|
|
||||||
rd = ri - defs[k].red;
|
rd = (ri - defs[k].red) / 256;
|
||||||
gd = gi - defs[k].green;
|
gd = (gi - defs[k].green) / 256;
|
||||||
bd = bi - defs[k].blue;
|
bd = (bi - defs[k].blue) / 256;
|
||||||
|
|
||||||
d = rd * rd + gd * gd + bd * bd;
|
d = rd * rd + gd * gd + bd * bd;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user