add one-channel output support to webp encoder
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 23 Apr 2014 21:55:28 +0000 (21:55 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 23 Apr 2014 21:55:28 +0000 (21:55 +0000)
BUG=
R=halcanary@google.com

Author: humper@google.com

Review URL: https://codereview.chromium.org/249853003

git-svn-id: http://skia.googlecode.com/svn/trunk@14340 2bbb7eff-a529-9590-31e7-b0007b416f81

src/images/SkImageDecoder_libwebp.cpp

index 49d5bd1..5174806 100644 (file)
@@ -547,6 +547,15 @@ static void Index8_To_RGB(const uint8_t* in, uint8_t* rgb, int width,
   }
 }
 
+static void Alpha8_To_RGB(const uint8_t* in, uint8_t* rgb, int width,
+                          const SkPMColor* SK_RESTRICT ctable) {
+  const uint8_t* SK_RESTRICT src = (const uint8_t*)in;
+  for (int i = 0; i < width; ++i) {
+      rgb[0] = rgb[1] = rgb[2] = *src++;
+      rgb += 3;
+  }
+}
+
 static ScanlineImporter ChooseImporter(const SkBitmap::Config& config,
                                        bool  hasAlpha,
                                        int*  bpp) {
@@ -573,6 +582,9 @@ static ScanlineImporter ChooseImporter(const SkBitmap::Config& config,
         case SkBitmap::kIndex8_Config:
             *bpp = 3;
             return Index8_To_RGB;
+        case SkBitmap::kA8_Config:
+            *bpp = 3;
+            return Alpha8_To_RGB;
         default:
             return NULL;
     }