summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/ChangeLog7
-rw-r--r--gdk-pixbuf/io-ico.c14
-rw-r--r--gdk-pixbuf/io-xbm.c8
-rw-r--r--gdk-pixbuf/io-xpm.c13
4 files changed, 40 insertions, 2 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index 68a2005e73..abfa050a0a 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,3 +1,10 @@
+2002-09-06 Matthias Clasen <maclas@gmx.de>
+
+ * io-xpm.c (pixbuf_create_from_xpm):
+ * io-xbm.c (gdk_pixbuf__xbm_image_load_real):
+ * io-ico.c (DecodeHeader): Attach hotspot coordinates to the
+ pixbuf as options "x_hot" and "y_hot".
+
2002-09-04 Matthias Clasen <maclas@gmx.de>
* io-tga.c (io_buffer_append):
diff --git a/gdk-pixbuf/io-ico.c b/gdk-pixbuf/io-ico.c
index 69fea54d1b..cb291dd13f 100644
--- a/gdk-pixbuf/io-ico.c
+++ b/gdk-pixbuf/io-ico.c
@@ -146,6 +146,9 @@ struct ico_progressive_state {
4 = 4 bpp colormapped
1 = 1 bit bitonal
*/
+ gboolean cursor;
+ gint x_hot;
+ gint y_hot;
struct headerpair Header; /* Decoded (BE->CPU) header */
@@ -199,6 +202,8 @@ static void DecodeHeader(guchar *Data, gint Bytes,
/* Step 1: The ICO header */
+ State->cursor = ((Data[3] << 8) + Data[2] == 2) ? TRUE : FALSE;
+
IconCount = (Data[5] << 8) + (Data[4]);
State->HeaderSize = 6 + IconCount*16;
@@ -238,6 +243,8 @@ static void DecodeHeader(guchar *Data, gint Bytes,
if (ThisScore>State->ImageScore) {
State->ImageScore = ThisScore;
+ State->x_hot = (Ptr[5] << 8) + Ptr[4];
+ State->y_hot = (Ptr[7] << 8) + Ptr[6];
State->DIBoffset = (Ptr[15]<<24)+(Ptr[14]<<16)+
(Ptr[13]<<8) + (Ptr[12]);
@@ -410,6 +417,13 @@ static void DecodeHeader(guchar *Data, gint Bytes,
_("Not enough memory to load icon"));
return;
}
+ if (State->cursor) {
+ gchar hot[10];
+ g_snprintf (hot, 10, "%d", State->x_hot);
+ gdk_pixbuf_set_option (State->pixbuf, "x_hot", hot);
+ g_snprintf (hot, 10, "%d", State->y_hot);
+ gdk_pixbuf_set_option (State->pixbuf, "y_hot", hot);
+ }
if (State->prepared_func != NULL)
/* Notify the client that we are ready to go */
diff --git a/gdk-pixbuf/io-xbm.c b/gdk-pixbuf/io-xbm.c
index 71e6e40393..0ec63755be 100644
--- a/gdk-pixbuf/io-xbm.c
+++ b/gdk-pixbuf/io-xbm.c
@@ -295,6 +295,14 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error)
return NULL;
}
+ if (x_hot != -1 && y_hot != -1) {
+ gchar hot[10];
+ g_snprintf (hot, 10, "%d", x_hot);
+ gdk_pixbuf_set_option (pixbuf, "x_hot", hot);
+ g_snprintf (hot, 10, "%d", y_hot);
+ gdk_pixbuf_set_option (pixbuf, "y_hot", hot);
+ }
+
pixels = gdk_pixbuf_get_pixels (pixbuf);
row_stride = gdk_pixbuf_get_rowstride (pixbuf);
diff --git a/gdk-pixbuf/io-xpm.c b/gdk-pixbuf/io-xpm.c
index ee9d44e385..fff93f91c5 100644
--- a/gdk-pixbuf/io-xpm.c
+++ b/gdk-pixbuf/io-xpm.c
@@ -1208,7 +1208,7 @@ static GdkPixbuf *
pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handle), gpointer handle,
GError **error)
{
- gint w, h, n_col, cpp;
+ gint w, h, n_col, cpp, x_hot, y_hot, items;
gint cnt, xcnt, ycnt, wbytes, n;
gint is_trans = FALSE;
const gchar *buffer;
@@ -1229,7 +1229,7 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
_("No XPM header found"));
return NULL;
}
- sscanf (buffer, "%d %d %d %d", &w, &h, &n_col, &cpp);
+ items = sscanf (buffer, "%d %d %d %d %d %d", &w, &h, &n_col, &cpp, &x_hot, &y_hot);
if (w <= 0) {
g_set_error (error,
GDK_PIXBUF_ERROR,
@@ -1355,6 +1355,15 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
g_free (colors);
g_free (name_buf);
+ if (items == 6) {
+ gchar hot[10];
+ g_snprintf (hot, 10, "%d", x_hot);
+ gdk_pixbuf_set_option (pixbuf, "x_hot", hot);
+ g_snprintf (hot, 10, "%d", y_hot);
+ gdk_pixbuf_set_option (pixbuf, "y_hot", hot);
+
+ }
+
return pixbuf;
}