summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorRichard Hult <richard@imendio.com>2006-07-10 09:54:21 +0000
committerRichard Hult <rhult@src.gnome.org>2006-07-10 09:54:21 +0000
commit4904b590306c2d2858de8900f6a373cef9a75438 (patch)
tree625ca5bec6a2a09a00ecb8f31e7edbc0cf33ae01 /gdk
parent451543039ad323c4593cf584d0651fafbe5ba5e3 (diff)
downloadgtk+-4904b590306c2d2858de8900f6a373cef9a75438.tar.gz
Account for alignment when reading xbm data. (#346721, patch by Dave
2006-07-10 Richard Hult <richard@imendio.com> * gdk/quartz/gdkpixmap-quartz.c: (gdk_bitmap_create_from_data): Account for alignment when reading xbm data. (#346721, patch by Dave Vasilevsky)
Diffstat (limited to 'gdk')
-rw-r--r--gdk/quartz/gdkpixmap-quartz.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/gdk/quartz/gdkpixmap-quartz.c b/gdk/quartz/gdkpixmap-quartz.c
index 825df810a0..addeb42f17 100644
--- a/gdk/quartz/gdkpixmap-quartz.c
+++ b/gdk/quartz/gdkpixmap-quartz.c
@@ -201,7 +201,7 @@ gdk_bitmap_create_from_data (GdkDrawable *window,
{
GdkPixmap *pixmap;
GdkPixmapImplQuartz *impl;
- int x, y;
+ int x, y, bpl;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
@@ -212,19 +212,21 @@ gdk_bitmap_create_from_data (GdkDrawable *window,
g_assert (CGImageGetBytesPerRow (impl->image) == width);
+ /* Bytes per line: Each line consumes an integer number of bytes, possibly
+ * ignoring any excess bits. */
+ bpl = (width + 7) / 8;
for (y = 0; y < height; y++)
{
- guchar *ptr = impl->data + y * width;
- gint idx;
-
+ guchar *dst = impl->data + y * width;
+ const gchar *src = data + (y * bpl);
for (x = 0; x < width; x++)
{
- if ((data[(y * width + x) / 8] >> x % 8) & 1)
- *ptr = 0xff;
+ if ((src[x / 8] >> x % 8) & 1)
+ *dst = 0xff;
else
- *ptr = 0;
+ *dst = 0;
- ptr++;
+ dst++;
}
}