forked from AuroraMiddleware/gtk
Refactor to use API that's available in OS X 10.4 as well
This commit is contained in:
parent
093a867e51
commit
3770d914ec
@ -200,8 +200,9 @@ CGColorRef
|
|||||||
_gdk_quartz_colormap_get_cgcolor_from_pixel (GdkDrawable *drawable,
|
_gdk_quartz_colormap_get_cgcolor_from_pixel (GdkDrawable *drawable,
|
||||||
guint32 pixel)
|
guint32 pixel)
|
||||||
{
|
{
|
||||||
CGFloat r, g, b, a;
|
CGFloat components[4] = { 0.0f, };
|
||||||
CGColorRef color;
|
CGColorRef color;
|
||||||
|
CGColorSpaceRef colorspace;
|
||||||
const GdkVisual *visual;
|
const GdkVisual *visual;
|
||||||
GdkColormap *colormap;
|
GdkColormap *colormap;
|
||||||
|
|
||||||
@ -215,25 +216,30 @@ _gdk_quartz_colormap_get_cgcolor_from_pixel (GdkDrawable *drawable,
|
|||||||
{
|
{
|
||||||
case GDK_VISUAL_STATIC_GRAY:
|
case GDK_VISUAL_STATIC_GRAY:
|
||||||
case GDK_VISUAL_GRAYSCALE:
|
case GDK_VISUAL_GRAYSCALE:
|
||||||
g = (pixel & 0xff) / 255.0f;
|
components[0] = (pixel & 0xff) / 255.0f;
|
||||||
|
|
||||||
if (visual->depth == 1)
|
if (visual->depth == 1)
|
||||||
g = g == 0.0f ? 0.0f : 1.0f;
|
components[0] = components[0] == 0.0f ? 0.0f : 1.0f;
|
||||||
|
components[1] = 1.0f;
|
||||||
|
|
||||||
color = CGColorCreateGenericGray (g, 1.0f);
|
colorspace = CGColorSpaceCreateWithName (kCGColorSpaceGenericGray);
|
||||||
|
color = CGColorCreate (colorspace, components);
|
||||||
|
CGColorSpaceRelease (colorspace);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
r = (pixel >> 16 & 0xff) / 255.0;
|
components[0] = (pixel >> 16 & 0xff) / 255.0;
|
||||||
g = (pixel >> 8 & 0xff) / 255.0;
|
components[1] = (pixel >> 8 & 0xff) / 255.0;
|
||||||
b = (pixel & 0xff) / 255.0;
|
components[2] = (pixel & 0xff) / 255.0;
|
||||||
|
|
||||||
if (visual->depth == 32)
|
if (visual->depth == 32)
|
||||||
a = (pixel >> 24 & 0xff) / 255.0;
|
components[3] = (pixel >> 24 & 0xff) / 255.0;
|
||||||
else
|
else
|
||||||
a = 1.0;
|
components[3] = 1.0;
|
||||||
|
|
||||||
color = CGColorCreateGenericRGB (r, g, b, a);
|
colorspace = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
|
||||||
|
color = CGColorCreate (colorspace, components);
|
||||||
|
CGColorSpaceRelease (colorspace);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user