mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-23 20:30:15 +00:00
Attach hotspot coordinates to the pixbuf as options "x_hot" and "y_hot".
* 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".
This commit is contained in:
parent
7830d701ce
commit
ab97160067
@ -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):
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user