]> git.saurik.com Git - wxWidgets.git/commitdiff
...
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 12 Apr 1999 13:44:52 +0000 (13:44 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 12 Apr 1999 13:44:52 +0000 (13:44 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2100 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/imaggif.cpp

index 887e94e9242470a30fbf9161d08663e0c430898c..0d83a397c946d3b550af60ee419670ade3f29323 100644 (file)
@@ -40,13 +40,14 @@ FOLLOWING CODE IS BY G.R.G. :
   Guillermo Rodriguez Garcia
   <guille@iies.es>
 
-  Version: 2.0
+  Version: 2.1
 *************************************************************************/
 
 typedef struct
 {
     int w;                  /* width */
     int h;                  /* height */
+    int transparent;        /* transparent color (-1 = none) */
     unsigned char *p;       /* bitmap */
     unsigned char *pal;     /* palette */
 } IMAGEN;
@@ -60,7 +61,7 @@ typedef struct
   Guillermo Rodriguez Garcia
   <guille@iies.es>
 
-  Version: 2.0
+  Version: 2.1
 *************************************************************************/
 
 
@@ -94,12 +95,19 @@ class gifDecoder
         int readgif(IMAGEN *img);
        
     private:
-        int mygetc() {return (unsigned char)f -> GetC();}
+        unsigned char mygetc();
           // This is NEEDED! GetC is char (signed) why we need unsigned value
           // from here
 };
 
 
+unsigned char gifDecoder::mygetc()
+{
+    unsigned char c;
+    f -> Read(&c, 1);
+    return c;
+}
+
 
 /* getcode:
  *  Reads the next code from the file, with size 'bits'
@@ -303,13 +311,26 @@ int gifDecoder::readgif(IMAGEN *img)
         f -> Read(pal, 3 * ncolors);
     }
 
-    /* skip extensions */
-    while (mygetc() == 0x21)            /* separator */
-    {
-        mygetc();                       /* function code */
+    /* assume no transparent color */
+    img->transparent = -1;
 
-        while ((i = mygetc()) != 0)      /* byte count */
-            f -> SeekI(i, wxFromCurrent);
+    /* skip most extensions */
+    while (mygetc() == 0x21)               /* separator */
+    {
+        wxLogDebug("ugh");
+        if (mygetc() == 0xF9)              /* graphic control ext. */
+        {
+           wxLogDebug("...");
+            f->Read(buf, 6);
+           wxLogDebug("buf[1] is %i (%i)", buf[1], buf[1] & 0x01);
+            if (buf[1] & 0x01) {
+           wxLogDebug("setting transparen %i", buf[4]);
+                img->transparent = buf[4];
+           }
+        }
+        else
+            while ((i = mygetc()) != 0)    /* byte count */
+                f->SeekI(i, wxFromCurrent);
     }
 
     /* read image descriptor block (IDB) */
@@ -392,6 +413,13 @@ bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream )
         *(ptr++) = pal[3 * (*src) + 2];
     }
 
+    if (igif.transparent != -1) {
+        wxLogDebug("oko");
+        image->SetMaskColour(pal[3 * (igif.transparent) + 0], pal[3 * (igif.transparent) + 0], pal[3 * (igif.transparent) + 0]);
+        image->SetMask(TRUE);
+    }
+
+    wxLogDebug("(unsigned int)%i", (unsigned int)-1);
     free(igif.pal);
     free(igif.p);
     return TRUE;
@@ -404,3 +432,8 @@ bool wxGIFHandler::SaveFile( wxImage *image, wxOutputStream& stream )
 }
 
 
+
+
+
+
+