This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] windres: fix storage of icons
- From: "Martin Fuchs" <martin-fuchs at gmx dot net>
- To: <binutils at sources dot redhat dot com>
- Date: Sat, 20 Sep 2003 08:27:18 +0100
- Subject: [PATCH] windres: fix storage of icons
- References: <20030916083223.9120gmx1@mx018-rz3.gmx.net>
Hello,
the following patch corrects the storage of icons through windres.
What can I do to let it commit to the binutils CVS?
I wanted to use icons with several integrated formats (16 colors, 256 colors and true color with alpha channel), and had to see, that windres did not specify the color attributes correctly in the icon group of the generated resource file. So I looked into the source code and found this comment:
/* For some reason, at least in some files the planes and bits
are zero. We instead set them from the color. This is
copied from rcl. */
Well, may be there are icons with 0 for the plane and bit number. But this is not the case for all icons. And there are also icons with 0 as color count. It seems, this is allways the case for colors with 256 or more colors. So now I look first, if there are plane and bit number attributes. If yes, use them. If not, then look at the color count attribute and calculate the bit count.
Changelog
2003-09-16 Martin Fuchs <martin-fuchs@gmx.net> * resrc.c (define_icon): fix storage of color attributes 'planes' and 'bit count' in icon groups.
Index: resrc.c
===================================================================
RCS file: /cvs/src/src/binutils/resrc.c,v
retrieving revision 1.23
diff -u -p -d -r1.23 resrc.c
--- resrc.c 14 Sep 2003 12:20:16 -0000 1.23
+++ resrc.c 16 Sep 2003 07:52:50 -0000
@@ -1039,11 +1039,21 @@ define_icon (struct res_id id, const str
cg->width = icondirs[i].width;
cg->height = icondirs[i].height;
cg->colors = icondirs[i].colorcount;
+
+ if (icondirs[i].u.icon.planes)
+ cg->planes = icondirs[i].u.icon.planes;
+ else
+ cg->planes = 1;
- cg->planes = 1;
- cg->bits = 0;
- while ((1 << cg->bits) < cg->colors)
- ++cg->bits;
+ if (icondirs[i].u.icon.bits)
+ cg->bits = icondirs[i].u.icon.bits;
+ else
+ {
+ cg->bits = 0;
+
+ while ((1L << cg->bits) < cg->colors)
+ ++cg->bits;
+ }
cg->bytes = icondirs[i].bytes;
cg->index = first_icon + i + 1;
--
Martin Fuchs
martin-fuchs@gmx.net