gdk_pixdata_deserialize byte order problem
- From: "Joern P. Meier" <mail ionflux org>
- To: gtk-devel-list gnome org
- Subject: gdk_pixdata_deserialize byte order problem
- Date: Thu, 17 May 2007 17:17:06 +0200
Hi,
I had some problems with icons from the built-in cache not being loaded
on Mac/PPC. I traced the problem to gdk_pixdata_deserialize (in
gdk-pixdata.c) and noticed that the magic word was reversed.
In gdk_pixdata_serialize, g_htonl is used for header fields:
*istream++ = g_htonl (GDK_PIXBUF_MAGIC_NUMBER);
*istream++ = g_htonl (GDK_PIXDATA_HEADER_LENGTH + length);
*istream++ = g_htonl (pixdata->pixdata_type);
*istream++ = g_htonl (pixdata->rowstride);
*istream++ = g_htonl (pixdata->width);
*istream++ = g_htonl (pixdata->height);
However, in gdk_pixdata_deserialize, get_uint32 is used:
stream = get_uint32 (stream, &pixdata->pixdata_type);
stream = get_uint32 (stream, &pixdata->rowstride);
stream = get_uint32 (stream, &pixdata->width);
stream = get_uint32 (stream, &pixdata->height);
which seems to store values in network byte order:
*result = (stream[0] << 24) + (stream[1] << 16) + (stream[2] << 8) +
stream[3];
I was able to fix it by adding a call to g_ntohl in get_uint32.
Cheers,
Jörn
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]