[gtk+/gtk-2-22] Refactor to use API that's available in OS X 10.4 as well
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-22] Refactor to use API that's available in OS X 10.4 as well
- Date: Sun, 27 Jun 2010 08:49:08 +0000 (UTC)
commit 3770d914ec3ac30248f8d187ccc9f5369d3a5fcc
Author: Kristian Rietveld <kris gtk org>
Date: Sun Jun 27 10:22:36 2010 +0200
Refactor to use API that's available in OS X 10.4 as well
gdk/quartz/gdkcolor-quartz.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/gdk/quartz/gdkcolor-quartz.c b/gdk/quartz/gdkcolor-quartz.c
index cb5dd2a..fb5eb8a 100644
--- a/gdk/quartz/gdkcolor-quartz.c
+++ b/gdk/quartz/gdkcolor-quartz.c
@@ -200,8 +200,9 @@ CGColorRef
_gdk_quartz_colormap_get_cgcolor_from_pixel (GdkDrawable *drawable,
guint32 pixel)
{
- CGFloat r, g, b, a;
+ CGFloat components[4] = { 0.0f, };
CGColorRef color;
+ CGColorSpaceRef colorspace;
const GdkVisual *visual;
GdkColormap *colormap;
@@ -215,25 +216,30 @@ _gdk_quartz_colormap_get_cgcolor_from_pixel (GdkDrawable *drawable,
{
case GDK_VISUAL_STATIC_GRAY:
case GDK_VISUAL_GRAYSCALE:
- g = (pixel & 0xff) / 255.0f;
+ components[0] = (pixel & 0xff) / 255.0f;
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;
default:
- r = (pixel >> 16 & 0xff) / 255.0;
- g = (pixel >> 8 & 0xff) / 255.0;
- b = (pixel & 0xff) / 255.0;
+ components[0] = (pixel >> 16 & 0xff) / 255.0;
+ components[1] = (pixel >> 8 & 0xff) / 255.0;
+ components[2] = (pixel & 0xff) / 255.0;
if (visual->depth == 32)
- a = (pixel >> 24 & 0xff) / 255.0;
+ components[3] = (pixel >> 24 & 0xff) / 255.0;
else
- a = 1.0;
+ components[3] = 1.0;
- color = CGColorCreateGenericRGB (r, g, b, a);
+ colorspace = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
+ color = CGColorCreate (colorspace, components);
+ CGColorSpaceRelease (colorspace);
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]