use SkColorType instead of SkBitmap::Config in samplecode

BUG=skia:
R=reed@google.com

Author: reed@chromium.org

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

git-svn-id: http://skia.googlecode.com/svn/trunk@13473 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleEncode.cpp b/samplecode/SampleEncode.cpp
index 7af47a6..4769fbb 100644
--- a/samplecode/SampleEncode.cpp
+++ b/samplecode/SampleEncode.cpp
@@ -26,14 +26,13 @@
 
 #include "SkStream.h"
 
-static void make_image(SkBitmap* bm, SkBitmap::Config config, int configIndex) {
+static void make_image(SkBitmap* bm, SkColorType ct, int configIndex) {
     const int   width = 98;
     const int   height = 100;
+    const SkImageInfo info = SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType);
+
     SkBitmap    device;
-
-    device.setConfig(SkBitmap::kARGB_8888_Config, width, height);
-    device.allocPixels();
-
+    device.allocN32Pixels(width, height);
     SkCanvas    canvas(device);
     SkPaint     paint;
 
@@ -43,13 +42,12 @@
     canvas.drawCircle(SkIntToScalar(width)/2, SkIntToScalar(height)/2,
                       SkIntToScalar(width)/2, paint);
 
-    bm->setConfig(config, width, height);
-    switch (config) {
-        case SkBitmap::kARGB_8888_Config:
+    switch (ct) {
+        case kPMColor_SkColorType:
             bm->swap(device);
             break;
-        case SkBitmap::kRGB_565_Config: {
-            bm->allocPixels();
+        case kRGB_565_SkColorType: {
+            bm->allocPixels(info);
             for (int y = 0; y < height; y++) {
                 for (int x = 0; x < width; x++) {
                     *bm->getAddr16(x, y) = SkPixel32ToPixel16(*device.getAddr32(x, y));
@@ -57,7 +55,7 @@
             }
             break;
         }
-        case SkBitmap::kIndex8_Config: {
+        case kIndex_8_SkColorType: {
             SkPMColor colors[256];
             for (int i = 0; i < 256; i++) {
                 if (configIndex & 1) {
@@ -67,9 +65,8 @@
                 }
             }
             SkColorTable* ctable = new SkColorTable(colors, 256);
-            bm->allocPixels(ctable);
+            bm->allocPixels(info, NULL, ctable);
             ctable->unref();
-
             for (int y = 0; y < height; y++) {
                 for (int x = 0; x < width; x++) {
                     *bm->getAddr8(x, y) = SkGetPackedR32(*device.getAddr32(x, y));
@@ -78,16 +75,16 @@
             break;
         }
         default:
-            break;
+            SkASSERT(0);
     }
 }
 
 // configs to build the original bitmap in. Can be at most these 3
-static const SkBitmap::Config gConfigs[] = {
-    SkBitmap::kARGB_8888_Config,
-    SkBitmap::kRGB_565_Config,
-    SkBitmap::kIndex8_Config,   // opaque
-    SkBitmap::kIndex8_Config    // alpha
+static const SkColorType gColorTypes[] = {
+    kPMColor_SkColorType,
+    kRGB_565_SkColorType,
+    kIndex_8_SkColorType,   // opaque
+    kIndex_8_SkColorType    // alpha
 };
 
 static const char* const gConfigLabels[] = {
@@ -115,13 +112,12 @@
     int              fBitmapCount;
 
     EncodeView() {
-    #if 1
-        fBitmapCount = SK_ARRAY_COUNT(gConfigs);
+        fBitmapCount = SK_ARRAY_COUNT(gColorTypes);
         fBitmaps = new SkBitmap[fBitmapCount];
         fEncodedPNGs = new SkAutoDataUnref[fBitmapCount];
         fEncodedJPEGs = new SkAutoDataUnref[fBitmapCount];
         for (int i = 0; i < fBitmapCount; i++) {
-            make_image(&fBitmaps[i], gConfigs[i], i);
+            make_image(&fBitmaps[i], gColorTypes[i], i);
 
             for (size_t j = 0; j < SK_ARRAY_COUNT(gTypes); j++) {
                 SkAutoTDelete<SkImageEncoder> codec(
@@ -144,10 +140,6 @@
                 }
             }
         }
-    #else
-        fBitmaps = NULL;
-        fBitmapCount = 0;
-    #endif
         this->setBGColor(0xFFDDDDDD);
     }