summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
authorMatthias Clasen <maclas@gmx.de>2003-06-28 20:04:18 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2003-06-28 20:04:18 +0000
commit4d3c01795c052f1d66bb697731f0245912dcd69b (patch)
tree172be2da4e90525e007337fd63f8ddad9ba6628a /gdk-pixbuf
parent323bcc614d46abc4eb4095664ee524a1ab25cfce (diff)
downloadgdk-pixbuf-4d3c01795c052f1d66bb697731f0245912dcd69b.tar.gz
Stop discriminating against 32bpp ICOs a): Use the byte size of the image
2003-06-28 Matthias Clasen <maclas@gmx.de> * io-ico.c (DecodeHeader): Stop discriminating against 32bpp ICOs a): Use the byte size of the image as a heuristic when selecting the bitmap to load - this lets us select 32bpp bitmaps which come after a 8bpp bitmap. (OneLineTransp): Stop discriminating against 32bpp ICOs b): Don't overwrite the alpha channel of 32bpp ICOs. (gdk_pixbuf__ico_image_load_increment): Stop decoding the header unnecessarily.
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/ChangeLog9
-rw-r--r--gdk-pixbuf/io-ico.c22
2 files changed, 18 insertions, 13 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index 9f6efbd3c..ecd6c68ff 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,3 +1,12 @@
+2003-06-28 Matthias Clasen <maclas@gmx.de>
+
+ * io-ico.c (DecodeHeader): Stop discriminating against 32bpp ICOs a): Use the byte
+ size of the image as a heuristic when selecting the bitmap to load - this lets us
+ select 32bpp bitmaps which come after a 8bpp bitmap.
+ (OneLineTransp): Stop discriminating against 32bpp ICOs b): Don't overwrite the
+ alpha channel of 32bpp ICOs.
+ (gdk_pixbuf__ico_image_load_increment): Stop decoding the header unnecessarily.
+
Fri Jun 27 03:56:59 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* io-gif-animation.c (gdk_pixbuf_gif_anim_frame_composite): Make
diff --git a/gdk-pixbuf/io-ico.c b/gdk-pixbuf/io-ico.c
index 4fdb9bae7..5adf43f21 100644
--- a/gdk-pixbuf/io-ico.c
+++ b/gdk-pixbuf/io-ico.c
@@ -191,9 +191,8 @@ static void DecodeHeader(guchar *Data, gint Bytes,
GError **error)
{
/* For ICO's we have to be very clever. There are multiple images possible
- in an .ICO. For now, we select (in order of priority):
- 1) The one with the highest number of colors
- 2) The largest one
+ in an .ICO. As a simple heuristic, we select the image which occupies the
+ largest number of bytes.
*/
gint IconCount = 0; /* The number of icon-versions in the file */
@@ -231,18 +230,11 @@ static void DecodeHeader(guchar *Data, gint Bytes,
State->DIBoffset = 0;
Ptr = Data + 6;
for (I=0;I<IconCount;I++) {
- int ThisWidth, ThisHeight,ThisColors;
int ThisScore;
- ThisWidth = Ptr[0];
- ThisHeight = Ptr[1];
- ThisColors = (Ptr[2]);
- if (ThisColors==0)
- ThisColors=256; /* Yes, this is in the spec, ugh */
-
- ThisScore = ThisColors*1024+ThisWidth*ThisHeight;
+ ThisScore = (Ptr[11] << 24) + (Ptr[10] << 16) + (Ptr[9] << 8) + (Ptr[8]);
- if (ThisScore>State->ImageScore) {
+ if (ThisScore>=State->ImageScore) {
State->ImageScore = ThisScore;
State->x_hot = (Ptr[5] << 8) + Ptr[4];
State->y_hot = (Ptr[7] << 8) + Ptr[6];
@@ -691,6 +683,10 @@ static void OneLineTransp(struct ico_progressive_state *context)
gint X;
guchar *Pixels;
+ /* Ignore the XOR mask for XP style 32-bpp icons with alpha */
+ if (context->Header.depth == 32)
+ return;
+
X = 0;
if (context->Header.Negative == 0)
Pixels = (context->pixbuf->pixels +
@@ -827,7 +823,7 @@ gdk_pixbuf__ico_image_load_increment(gpointer data,
}
- if (context->HeaderDone >= 6) {
+ if (context->HeaderDone >= 6 && context->pixbuf == NULL) {
GError *decode_err = NULL;
DecodeHeader(context->HeaderBuf,
context->HeaderDone, context, &decode_err);