[Scummvm-cvs-logs] SF.net SVN: scummvm:[45183] scummvm/trunk/backends/platform/dc

marcus_c at users.sourceforge.net marcus_c at users.sourceforge.net
Sat Oct 17 13:35:49 CEST 2009


Revision: 45183
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45183&view=rev
Author:   marcus_c
Date:     2009-10-17 11:35:49 +0000 (Sat, 17 Oct 2009)

Log Message:
-----------
Made find_unused_pixel() take the transparency mask into account, not
counting palette colours of masked pixels as used.  Fixes transparency
on the new default icon.

Modified Paths:
--------------
    scummvm/trunk/backends/platform/dc/icon.cpp
    scummvm/trunk/backends/platform/dc/icon.h

Modified: scummvm/trunk/backends/platform/dc/icon.cpp
===================================================================
--- scummvm/trunk/backends/platform/dc/icon.cpp	2009-10-17 11:24:57 UTC (rev 45182)
+++ scummvm/trunk/backends/platform/dc/icon.cpp	2009-10-17 11:35:49 UTC (rev 45183)
@@ -120,14 +120,21 @@
   ta_commit_list(&myvertex);
 }
 
-int Icon::find_unused_pixel()
+int Icon::find_unused_pixel(const unsigned char *mask)
 {
   int use[16];
   memset(use, 0, sizeof(use));
-  for (int n=0; n<32*32/2; n++) {
-    unsigned char pix = bitmap[n];
-    use[pix&0xf]++;
-    use[pix>>4]++;
+  unsigned char *p = bitmap;
+  for (int n=0; n<32*32/2/4; n++) {
+    unsigned char mbits = ~*mask++;
+    for (int i=0; i<4; i++) {
+      unsigned char pix = *p++;
+      if(mbits & 64)
+	use[pix&0xf]++;
+      if(mbits & 128)
+	use[pix>>4]++;
+      mbits <<= 2;
+    }
   }
   for (int i=0; i<16; i++)
     if (!use[i])
@@ -165,10 +172,10 @@
     palette[i] |= 0xff000000;
   for (int i=hdr.used; i<16; i++)
     palette[i] = 0;
-  int unused = find_unused_pixel();
+  const unsigned char *mask =
+    ((const unsigned char *)data)+hdr.size+(hdr.used<<2)+32*32/2;
+  int unused = find_unused_pixel(mask);
   if (unused >= 0) {
-    const unsigned char *mask =
-      ((const unsigned char *)data)+hdr.size+(hdr.used<<2)+32*32/2;
     unsigned char *pix = bitmap;
     for (int y=0; y<32; y++)
       for (int x=0; x<32/8; x++) {

Modified: scummvm/trunk/backends/platform/dc/icon.h
===================================================================
--- scummvm/trunk/backends/platform/dc/icon.h	2009-10-17 11:24:57 UTC (rev 45182)
+++ scummvm/trunk/backends/platform/dc/icon.h	2009-10-17 11:35:49 UTC (rev 45183)
@@ -33,7 +33,7 @@
   unsigned int palette[16];
   void *texture;
 
-  int find_unused_pixel();
+  int find_unused_pixel(const unsigned char *);
   bool load_image1(const void *data, int len, int offs);
   bool load_image2(const void *data, int len);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list