[aseprite] 69/250: Fix saving/loading .gif files w/completely opaque images but with local transparent index

Tobias Hansen thansen at moszumanska.debian.org
Sun Dec 20 15:27:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 3dfd6de4f0ca528bdf3df41b16f8c0e3dbeb33a4
Author: David Capello <davidcapello at gmail.com>
Date:   Tue Sep 22 14:39:47 2015 -0300

    Fix saving/loading .gif files w/completely opaque images but with local transparent index
    
    There are .gif files that specified a local transparent index
    but the frame pixels don't use that index (i.e. the frame is completely
    opaque anyway). The same happens when we use a transparent layer but the
    transparent color is not used (i.e. the layer is completely opaque anyway).
    With this patch we fix loading/saving correctly this kind of files/sprites.
    
    Fix #800
---
 src/app/file/gif_format.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/app/file/gif_format.cpp b/src/app/file/gif_format.cpp
index c9654a6..eef01bf 100644
--- a/src/app/file/gif_format.cpp
+++ b/src/app/file/gif_format.cpp
@@ -434,6 +434,14 @@ private:
     // Get the list of used palette entries
     PalettePicks usedEntries(ncolors);
     if (isLocalColormap) {
+      // With this we avoid discarding the transparent index when a
+      // frame indicates that it uses a specific index as transparent
+      // but the image is completely opaque anyway.
+      if (m_localTransparentIndex >= 0 &&
+          m_localTransparentIndex < ncolors) {
+        usedEntries[m_localTransparentIndex] = true;
+      }
+
       for (const auto& i : LockImageBits<IndexedTraits>(frameImage)) {
         if (i >= 0 && i < ncolors)
           usedEntries[i] = true;
@@ -1021,6 +1029,18 @@ private:
     // Convert the frameBounds area of m_currentImage (RGB) to frameImage (Indexed)
     // bool needsTransparent = false;
     PalettePicks usedColors(framePalette->size());
+
+    // If the sprite needs a transparent color we mark it as used so
+    // the palette includes a spot for it. It doesn't matter if the
+    // image doesn't use the transparent index, if the sprite isn't
+    // opaque we need the transparent index anyway.
+    if (m_transparentIndex >= 0) {
+      int i = m_transparentIndex;
+      if (i >= usedColors.size())
+        usedColors.resize(i+1);
+      usedColors[i] = true;
+    }
+
     {
       LockImageBits<RgbTraits> bits(m_currentImage, frameBounds);
       auto it = bits.begin();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list