3 * Copyright (C) 2005 Imendio AB
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
25 #include "gdkprivate-quartz.h"
27 static GObjectClass *parent_class;
30 _gdk_quartz_copy_to_image (GdkDrawable *drawable,
39 /* FIXME: Implement */
44 gdk_image_finalize (GObject *object)
46 GdkImage *image = GDK_IMAGE (object);
50 G_OBJECT_CLASS (parent_class)->finalize (object);
54 gdk_image_class_init (GdkImageClass *klass)
56 GObjectClass *object_class = G_OBJECT_CLASS (klass);
58 parent_class = g_type_class_peek_parent (klass);
60 object_class->finalize = gdk_image_finalize;
64 gdk_image_get_type (void)
66 static GType object_type = 0;
70 static const GTypeInfo object_info =
72 sizeof (GdkImageClass),
74 (GBaseFinalizeFunc) NULL,
75 (GClassInitFunc) gdk_image_class_init,
76 NULL, /* class_finalize */
77 NULL, /* class_data */
80 (GInstanceInitFunc) NULL,
83 object_type = g_type_register_static (G_TYPE_OBJECT,
93 gdk_image_new_bitmap (GdkVisual *visual, gpointer data, gint width, gint height)
95 /* We don't implement this function because it's broken, deprecated and
96 * tricky to implement. */
97 g_warning ("This function is unimplemented");
103 _gdk_image_new_for_depth (GdkScreen *screen,
113 depth = visual->depth;
115 g_assert (depth == 24 || depth == 32);
117 image = g_object_new (gdk_image_get_type (), NULL);
119 image->visual = visual;
120 image->width = width;
121 image->height = height;
122 image->depth = depth;
124 image->byte_order = (G_BYTE_ORDER == G_LITTLE_ENDIAN) ? GDK_LSB_FIRST : GDK_MSB_FIRST;
126 /* We only support images with bpp 4 */
128 image->bpl = image->width * image->bpp;
129 image->bits_per_pixel = image->bpp * 8;
131 image->mem = g_malloc (image->bpl * image->height);
132 memset (image->mem, 0x00, image->bpl * image->height);
138 gdk_image_get_pixel (GdkImage *image,
144 g_return_val_if_fail (image != NULL, 0);
145 g_return_val_if_fail (x >= 0 && x < image->width, 0);
146 g_return_val_if_fail (y >= 0 && y < image->height, 0);
148 ptr = image->mem + y * image->bpl + x * image->bpp;
150 return *(guint32 *)ptr;
154 gdk_image_put_pixel (GdkImage *image,
161 ptr = image->mem + y * image->bpl + x * image->bpp;
163 *(guint32 *)ptr = pixel;
167 _gdk_windowing_get_bits_for_depth (GdkDisplay *display,
170 if (depth == 24 || depth == 32)
173 g_assert_not_reached ();