Commit 4d3c0179 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen
Browse files

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.
parent 323bcc61
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
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment