This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Support bits/planes for ICON-resources proper


Hi,

patch reads bits/planes information from bitmap-header instead of
assuming all icon's would have 1 plane with 1 bit resolution.

 ChangeLog

 2014-10-27  Kai Tietz  <ktietz@redhat.com>

     * resrc.c (define_cursor): Gain icon's planes/bits information
     by the header-information.

 Tested for i686-pc-cygwin, x86_64-w64-mingw32.  Ok for apply?

 Regards,
 Kai

---
 binutils/resrc.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/binutils/resrc.c b/binutils/resrc.c
index 65f1c11..092bb22 100644
--- a/binutils/resrc.c
+++ b/binutils/resrc.c
@@ -826,15 +826,13 @@ define_cursor (rc_res_id id, const
rc_res_res_info *resinfo,
       r->res_info = *resinfo;
     }

-  fclose (e);
-  free (real_filename);
-
   /* Define a cursor group resource.  */

   first = NULL;
   pp = &first;
   for (i = 0; i < count; i++)
     {
+      long doff = 8;
       rc_group_cursor *cg;

       cg = (rc_group_cursor *) res_alloc (sizeof (rc_group_cursor));
@@ -842,10 +840,23 @@ define_cursor (rc_res_id id, const
rc_res_res_info *resinfo,
       cg->width = icondirs[i].width;
       cg->height = 2 * icondirs[i].height;

-      /* FIXME: What should these be set to?  */
-      cg->planes = 1;
-      cg->bits = 1;
+      if (fseek (e, icondirs[i].offset, SEEK_SET) != 0)
+    fatal (_("%s: fseek to %lu failed: %s"), real_filename,
+           (unsigned long) icondirs[i].offset, strerror (errno));
+
+      /* Get the planes/bits by the bitmap header.
+     See if we deal with a BITMAPCOREHEADER.  */
+      if (get_long (e, real_filename) != 12)
+    /* No, we deal with a BITMAPINFOHEADER.  */
+    doff = 12;
+
+      if (fseek (e, icondirs[i].offset + doff, SEEK_SET) != 0)
+    fatal (_("%s: fseek to %lu failed: %s"), real_filename,
+           (unsigned long) icondirs[i].offset + doff,
+           strerror (errno));

+      cg->planes = get_word (e, real_filename);
+      cg->bits = get_word (e, real_filename);
       cg->bytes = icondirs[i].bytes + 4;
       cg->index = first_cursor + i + 1;

@@ -853,6 +864,8 @@ define_cursor (rc_res_id id, const rc_res_res_info *resinfo,
       pp = &(*pp)->next;
     }

+  fclose (e);
+  free (real_filename);
   free (icondirs);

   r = define_standard_resource (&resources, RT_GROUP_CURSOR, id,
-- 
1.7.9


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]