diff --git a/dm/DM.cpp b/dm/DM.cpp
index 9dcdff1..fe09643 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -212,7 +212,12 @@
     // TODO (msarett): Add more scaling tests as we implement more flexible scaling.
     // TODO (msarett): Implement scaling tests for SkImageDecoder in order to compare with these
     //                 tests.  SkImageDecoder supports downscales by integer factors.
-    const float scales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f };
+    // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875
+    // 0.1, 0.16, 0.2 etc allow us to test SkScaledCodec with sampleSize 10, 6, 5, etc
+    // 0.4, 0.7 etc allow to test what happens when the client requests a scale that
+    // does not exactly match a sampleSize or native scaling capability
+    const float scales[] = { 0.1f, 0.125f, 0.166f, 0.2f, 0.25f, 0.333f, 0.375f, 0.4f, 0.5f, 0.6f,
+                             0.625f, 0.750f, 0.8f, 0.875f, 1.0f };
 
     for (float scale : scales) {
         if (scale != 1.0f && (path.endsWith(".webp") || path.endsWith(".WEBP"))) {
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index f555b9f..9826f97 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -27,6 +27,7 @@
 #include "SkScanlineDecoder.h"
 #include "SkStream.h"
 #include "SkXMLWriter.h"
+#include "SkScaledCodec.h"
 
 DEFINE_bool(multiPage, false, "For document-type backends, render the source"
             " into multiple pages");
@@ -84,9 +85,13 @@
     if (!encoded) {
         return SkStringPrintf("Couldn't read %s.", fPath.c_str());
     }
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
+    SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded));
     if (NULL == codec.get()) {
-        return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str());
+        // scaledCodec not supported, try normal codec
+        codec.reset(SkCodec::NewFromData(encoded));
+        if (NULL == codec.get()) {
+            return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str());
+        }
     }
 
     // Choose the color type to decode to
@@ -446,13 +451,16 @@
 
 SkISize CodecSrc::size() const {
     SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
-    if (NULL != codec) {
-        SkISize size = codec->getScaledDimensions(fScale);
-        return size;
-    } else {
-        return SkISize::Make(0, 0);
+    SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded));
+    if (NULL == codec) {
+        // scaledCodec not supported, try regular codec
+        codec.reset(SkCodec::NewFromData(encoded));
+        if (NULL == codec) {
+            return SkISize::Make(0, 0);
+        }
     }
+    SkISize size = codec->getScaledDimensions(fScale);
+    return size;
 }
 
 Name CodecSrc::name() const {
diff --git a/gyp/codec.gyp b/gyp/codec.gyp
index cc06945..b34c85e 100644
--- a/gyp/codec.gyp
+++ b/gyp/codec.gyp
@@ -47,6 +47,7 @@
         '../src/codec/SkJpegUtility_codec.cpp',
         '../src/codec/SkMaskSwizzler.cpp',
         '../src/codec/SkMasks.cpp',
+        '../src/codec/SkScaledCodec.cpp',
         '../src/codec/SkScanlineDecoder.cpp',
         '../src/codec/SkSwizzler.cpp',
         '../src/codec/SkWebpCodec.cpp',
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index a0bd18a..3465c1d 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -51,6 +51,8 @@
      *  Return a size that approximately supports the desired scale factor.
      *  The codec may not be able to scale efficiently to the exact scale
      *  factor requested, so return a size that approximates that scale.
+     *  The returned value is the codec's suggestion for the closest valid
+     *  scale that it can natively support
      */
     SkISize getScaledDimensions(float desiredScale) const {
         return this->onGetScaledDimensions(desiredScale);
diff --git a/include/codec/SkScaledCodec.h b/include/codec/SkScaledCodec.h
new file mode 100644
index 0000000..1bcdf08
--- /dev/null
+++ b/include/codec/SkScaledCodec.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkScaledCodec_DEFINED
+#define SkScaledCodec_DEFINED
+
+#include "SkCodec.h"
+#include "SkScanlineDecoder.h"
+
+class SkScanlineDecoder;
+class SkStream;
+
+/**
+ * This class implements scaling, by sampling scanlines in the y direction.
+ * x-wise sampling is implemented in the swizzler, when getScanlines() is called.
+ */
+class SkScaledCodec : public SkCodec {
+public:
+    static SkCodec* NewFromStream(SkStream*);
+    static SkCodec* NewFromData(SkData*);
+
+    virtual ~SkScaledCodec();
+
+    /**
+     * returns whether a destination's dimensions are supported for down sampling
+     */
+    static bool DimensionsSupportedForSampling(const SkImageInfo& srcInfo, 
+                                               const SkImageInfo& dstInfo) {
+        // heights must be equal as no native y sampling is supported
+        if (dstInfo.height() != srcInfo.height()) {
+            return false;
+        }
+        // only support down sampling, dstWidth cannot be larger that srcWidth
+        if(dstInfo.width() > srcInfo.width()) {
+            return false;
+        }
+        return true;   
+    }
+
+    static void ComputeSampleSize(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo,
+                                  int* sampleSizeX, int* sampleSizeY);
+
+protected:
+    /**
+     * Recommend a set of destination dimensions given a requested scale
+     */
+    SkISize onGetScaledDimensions(float desiredScale) const override;
+
+    Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMColor*, int*)
+            override;
+    SkEncodedFormat onGetEncodedFormat() const override {
+        return fScanlineDecoder->getEncodedFormat();
+    }
+
+    bool onReallyHasAlpha() const override {
+        return fScanlineDecoder->reallyHasAlpha();
+    }
+
+private:
+
+    SkAutoTDelete<SkScanlineDecoder> fScanlineDecoder;
+
+    explicit SkScaledCodec(SkScanlineDecoder*);
+
+    typedef SkCodec INHERITED;
+};
+#endif // SkScaledCodec_DEFINED
diff --git a/include/codec/SkScanlineDecoder.h b/include/codec/SkScanlineDecoder.h
index c233663..c547f67 100644
--- a/include/codec/SkScanlineDecoder.h
+++ b/include/codec/SkScanlineDecoder.h
@@ -46,6 +46,18 @@
     virtual ~SkScanlineDecoder() {}
 
     /**
+     *  Return a size that approximately supports the desired scale factor.
+     *  The codec may not be able to scale efficiently to the exact scale
+     *  factor requested, so return a size that approximates that scale.
+     *  The returned value is the codec's suggestion for the closest valid
+     *  scale that it can natively support
+     *  FIXME: share this with SkCodec
+     */
+    SkISize getScaledDimensions(float desiredScale) {
+        return this->onGetScaledDimensions(desiredScale);
+    }
+
+    /**
      *  Returns the default info, corresponding to the encoded data.
      */
     const SkImageInfo& getInfo() { return fSrcInfo; }
@@ -135,14 +147,44 @@
         return this->onReallyHasAlpha();
     }
 
+    /**
+     *  Format of the encoded data.
+     */
+    SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
+
+    /**
+     * returns true if the image must be scaled, in the y direction, after reading, not during.
+     * To scale afterwards, we first decode every line and then sample the lines we want afterwards.
+     * An example is interlaced pngs, where calling getScanlines once (regardless of the count
+     * used) needs to read the entire image, therefore it is inefficient to call
+     * getScanlines more than once. Instead, it should only ever be called with all the
+     * rows needed.
+     */
+    bool requiresPostYSampling() {
+        return this->onRequiresPostYSampling();
+    }
+
 protected:
     SkScanlineDecoder(const SkImageInfo& srcInfo)
         : fSrcInfo(srcInfo)
         , fDstInfo()
         , fCurrScanline(0) {}
 
+    virtual SkISize onGetScaledDimensions(float /* desiredScale */) {
+        // By default, scaling is not supported.
+        return this->getInfo().dimensions();
+    }
+
+    virtual SkEncodedFormat onGetEncodedFormat() const = 0;
+
     virtual bool onReallyHasAlpha() const { return false; }
 
+    /**
+     * returns true if the image type is hard to sample and must be scaled after reading, not during
+     * An example is interlaced pngs, where the entire image must be read for each decode
+     */
+    virtual bool onRequiresPostYSampling() { return false; }
+
     const SkImageInfo& dstInfo() const { return fDstInfo; }
 
 private:
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
index 08146fc..1dfd04e 100644
--- a/src/codec/SkBmpStandardCodec.cpp
+++ b/src/codec/SkBmpStandardCodec.cpp
@@ -237,7 +237,7 @@
 
     // Create swizzler
     fSwizzler.reset(SkSwizzler::CreateSwizzler(config,
-            colorPtr, dstInfo, opts.fZeroInitialized));
+            colorPtr, dstInfo, opts.fZeroInitialized, this->getInfo()));
 
     if (NULL == fSwizzler.get()) {
         return false;
diff --git a/src/codec/SkCodec_libgif.cpp b/src/codec/SkCodec_libgif.cpp
index 2e348cc..fa267e8 100644
--- a/src/codec/SkCodec_libgif.cpp
+++ b/src/codec/SkCodec_libgif.cpp
@@ -444,11 +444,12 @@
                     // Create the subset swizzler
                     swizzler.reset(SkSwizzler::CreateSwizzler(
                             SkSwizzler::kIndex, colorTable, subsetDstInfo,
-                            zeroInit));
+                            zeroInit, this->getInfo()));
                 } else {
                     // Create the fully dimensional swizzler
                     swizzler.reset(SkSwizzler::CreateSwizzler(
-                            SkSwizzler::kIndex, colorTable, dstInfo, zeroInit));
+                            SkSwizzler::kIndex, colorTable, dstInfo, 
+                            zeroInit, this->getInfo()));
                 }
 
                 // Stores output from dgiflib and input to the swizzler
diff --git a/src/codec/SkCodec_libpng.cpp b/src/codec/SkCodec_libpng.cpp
index c94f371..159aecd 100644
--- a/src/codec/SkCodec_libpng.cpp
+++ b/src/codec/SkCodec_libpng.cpp
@@ -11,6 +11,7 @@
 #include "SkColorTable.h"
 #include "SkBitmap.h"
 #include "SkMath.h"
+#include "SkScaledCodec.h"
 #include "SkScanlineDecoder.h"
 #include "SkSize.h"
 #include "SkStream.h"
@@ -462,7 +463,7 @@
     // Create the swizzler.  SkPngCodec retains ownership of the color table.
     const SkPMColor* colors = get_color_ptr(fColorTable.get());
     fSwizzler.reset(SkSwizzler::CreateSwizzler(fSrcConfig, colors, requestedInfo,
-            options.fZeroInitialized));
+                    options.fZeroInitialized, this->getInfo()));
     if (!fSwizzler) {
         // FIXME: CreateSwizzler could fail for another reason.
         return kUnimplemented;
@@ -582,8 +583,7 @@
 
     SkCodec::Result onStart(const SkImageInfo& dstInfo,
                             const SkCodec::Options& options,
-                            SkPMColor ctable[], int* ctableCount) override
-    {
+                            SkPMColor ctable[], int* ctableCount) override {
         if (!fCodec->rewindIfNeeded()) {
             return SkCodec::kCouldNotRewind;
         }
@@ -594,7 +594,9 @@
 
         // Check to see if scaling was requested.
         if (dstInfo.dimensions() != this->getInfo().dimensions()) {
-            return SkCodec::kInvalidScale;
+            if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstInfo)) {
+                return SkCodec::kInvalidScale;   
+            }
         }
 
         const SkCodec::Result result = fCodec->initializeSwizzler(dstInfo, options, ctable,
@@ -604,7 +606,7 @@
         }
 
         fHasAlpha = false;
-        fStorage.reset(dstInfo.width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig));
+        fStorage.reset(this->getInfo().width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig));
         fSrcRow = static_cast<uint8_t*>(fStorage.get());
 
         return SkCodec::kSuccess;
@@ -643,6 +645,11 @@
 
     bool onReallyHasAlpha() const override { return fHasAlpha; }
 
+    SkEncodedFormat onGetEncodedFormat() const override { 
+        return kPNG_SkEncodedFormat;
+    }
+
+
 private:
     SkAutoTDelete<SkPngCodec>   fCodec;
     bool                        fHasAlpha;
@@ -673,12 +680,14 @@
         }
 
         if (!conversion_possible(dstInfo, this->getInfo())) {
-            return SkCodec::kInvalidConversion;
+            return SkCodec::kInvalidConversion;    
         }
 
         // Check to see if scaling was requested.
         if (dstInfo.dimensions() != this->getInfo().dimensions()) {
-            return SkCodec::kInvalidScale;
+            if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstInfo)) {
+                return SkCodec::kInvalidScale;
+            }
         }
 
         const SkCodec::Result result = fCodec->initializeSwizzler(dstInfo, options, ctable,
@@ -690,7 +699,7 @@
         fHasAlpha = false;
         fCurrentRow = 0;
         fHeight = dstInfo.height();
-        fSrcRowBytes = dstInfo.width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig);
+        fSrcRowBytes = this->getInfo().width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig);
         fGarbageRow.reset(fSrcRowBytes);
         fGarbageRowPtr = static_cast<uint8_t*>(fGarbageRow.get());
         fCanSkipRewind = true;
@@ -753,6 +762,14 @@
 
     bool onReallyHasAlpha() const override { return fHasAlpha; }
 
+    bool onRequiresPostYSampling() override {
+        return true;
+    }
+
+    SkEncodedFormat onGetEncodedFormat() const override { 
+        return kPNG_SkEncodedFormat;
+    }
+
 private:
     SkAutoTDelete<SkPngCodec>   fCodec;
     bool                        fHasAlpha;
diff --git a/src/codec/SkCodec_libpng.h b/src/codec/SkCodec_libpng.h
index 8904022..e880749 100644
--- a/src/codec/SkCodec_libpng.h
+++ b/src/codec/SkCodec_libpng.h
@@ -37,6 +37,7 @@
     SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedFormat; }
     bool onRewind() override;
     bool onReallyHasAlpha() const override { return fReallyHasAlpha; }
+
 private:
     png_structp                 fPng_ptr;
     png_infop                   fInfo_ptr;
@@ -52,7 +53,6 @@
 
     SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop, int);
 
-
     // Helper to set up swizzler and color table. Also calls png_read_update_info.
     Result initializeSwizzler(const SkImageInfo& requestedInfo, const Options&,
                               SkPMColor*, int* ctableCount);
diff --git a/src/codec/SkCodec_wbmp.cpp b/src/codec/SkCodec_wbmp.cpp
index 6f98294..3081a3b 100644
--- a/src/codec/SkCodec_wbmp.cpp
+++ b/src/codec/SkCodec_wbmp.cpp
@@ -9,6 +9,7 @@
 #include "SkCodecPriv.h"
 #include "SkColorPriv.h"
 #include "SkColorTable.h"
+#include "SkScaledCodec.h"
 #include "SkStream.h"
 #include "SkCodec_wbmp.h"
 
@@ -80,8 +81,8 @@
         case kIndex_8_SkColorType:
         case kN32_SkColorType:
         case kGray_8_SkColorType:
-            return SkSwizzler::CreateSwizzler(
-                    SkSwizzler::kBit, ctable, info, opts.fZeroInitialized);
+            return SkSwizzler::CreateSwizzler(SkSwizzler::kBit, ctable, info, opts.fZeroInitialized, 
+                                              this->getInfo());
         default:
             return NULL;
     }
@@ -201,7 +202,9 @@
             return SkCodec::kUnimplemented;
         }
         if (dstInfo.dimensions() != this->getInfo().dimensions()) {
-            return SkCodec::kInvalidScale;
+            if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstInfo)) {
+                return SkCodec::kInvalidScale;
+            }
         }
 
         if (!valid_alpha(dstInfo.alphaType(), this->getInfo().alphaType())) {
@@ -220,12 +223,16 @@
         fSwizzler.reset(fCodec->initializeSwizzler(dstInfo,
                 get_color_ptr(fColorTable.get()), options));
         if (NULL == fSwizzler.get()) {
-            return SkCodec::kInvalidInput;
+            return SkCodec::kInvalidConversion;
         }
 
         return SkCodec::kSuccess;
     }
 
+    SkEncodedFormat onGetEncodedFormat() const {
+        return kWBMP_SkEncodedFormat;
+    }
+
 private:
     SkAutoTDelete<SkWbmpCodec>   fCodec;
     SkAutoTUnref<SkColorTable>   fColorTable;
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 83656da..c094d50 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -11,6 +11,7 @@
 #include "SkJpegUtility_codec.h"
 #include "SkCodecPriv.h"
 #include "SkColorPriv.h"
+#include "SkScaledCodec.h"
 #include "SkScanlineDecoder.h"
 #include "SkStream.h"
 #include "SkTemplates.h"
@@ -149,6 +150,14 @@
 {}
 
 /*
+ * Return the row bytes of a particular image type and width
+ */
+static int get_row_bytes(const j_decompress_ptr dinfo) {
+    int colorBytes = (dinfo->out_color_space == JCS_RGB565) ? 2 : dinfo->out_color_components;
+    return dinfo->output_width * colorBytes;
+
+}
+/*
  * Return a valid set of output dimensions for this decoder, given an input scale
  */
 SkISize SkJpegCodec::onGetScaledDimensions(float desiredScale) const {
@@ -258,10 +267,10 @@
 }
 
 /*
- * Checks if we can scale to the requested dimensions and scales the dimensions
- * if possible
+ * Checks if we can natively scale to the requested dimensions and natively scales the 
+ * dimensions if possible
  */
-bool SkJpegCodec::scaleToDimensions(uint32_t dstWidth, uint32_t dstHeight) {
+bool SkJpegCodec::nativelyScaleToDimensions(uint32_t dstWidth, uint32_t dstHeight) {
     // libjpeg-turbo can scale to 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, and 1/1
     fDecoderMgr->dinfo()->scale_denom = 8;
     fDecoderMgr->dinfo()->scale_num = 8;
@@ -273,7 +282,10 @@
         if (1 == fDecoderMgr->dinfo()->scale_num ||
                 dstWidth > fDecoderMgr->dinfo()->output_width ||
                 dstHeight > fDecoderMgr->dinfo()->output_height) {
-            return fDecoderMgr->returnFalse("could not scale to requested dimensions");
+            // reset native scale settings on failure because this may be supported by the swizzler 
+            this->fDecoderMgr->dinfo()->scale_num = 8;
+            chromium_jpeg_calc_output_dimensions(this->fDecoderMgr->dinfo());
+            return false;
         }
 
         // Try the next scale
@@ -313,7 +325,7 @@
     }
 
     // Perform the necessary scaling
-    if (!this->scaleToDimensions(dstInfo.width(), dstInfo.height())) {
+    if (!this->nativelyScaleToDimensions(dstInfo.width(), dstInfo.height())) {
         return fDecoderMgr->returnFailure("cannot scale to requested dims", kInvalidScale);
     }
 
@@ -381,6 +393,47 @@
         , fOpts()
     {}
 
+    /*
+    * Return a valid set of output dimensions for this decoder, given an input scale
+    */  
+    SkISize onGetScaledDimensions(float desiredScale) override {
+        return fCodec->onGetScaledDimensions(desiredScale);
+    }
+
+    /*
+     * Create the swizzler based on the encoded format.
+     * The swizzler is only used for sampling in the x direction.
+     */
+
+    SkCodec::Result initializeSwizzler(const SkImageInfo& info, const SkCodec::Options& options) {
+        SkSwizzler::SrcConfig srcConfig;
+        switch (info.colorType()) {
+            case kGray_8_SkColorType:
+                srcConfig = SkSwizzler::kGray;
+                break;
+            case kRGBA_8888_SkColorType:
+                srcConfig = SkSwizzler::kRGBX;
+                break;
+            case kBGRA_8888_SkColorType:
+                srcConfig = SkSwizzler::kBGRX;
+                break;
+            case kRGB_565_SkColorType:
+                srcConfig = SkSwizzler::kRGB_565;
+                break;
+            default:
+                //would have exited before now if the colorType was supported by jpeg
+                SkASSERT(false);
+        }
+
+        fSwizzler.reset(SkSwizzler::CreateSwizzler(srcConfig, NULL, info, options.fZeroInitialized, 
+                                                   this->getInfo()));
+        if (!fSwizzler) {
+            // FIXME: CreateSwizzler could fail for another reason.
+            return SkCodec::kUnimplemented;
+        }
+        return SkCodec::kSuccess;
+    }
+
     SkCodec::Result onStart(const SkImageInfo& dstInfo, const SkCodec::Options& options,
                             SkPMColor ctable[], int* ctableCount) override {
 
@@ -401,8 +454,23 @@
         }
 
         // Perform the necessary scaling
-        if (!fCodec->scaleToDimensions(dstInfo.width(), dstInfo.height())) {
-            return SkCodec::kInvalidScale;
+        if (!fCodec->nativelyScaleToDimensions(dstInfo.width(), dstInfo.height())) {
+            // full native scaling to dstInfo dimensions not supported
+
+            if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstInfo)) {
+                return SkCodec::kInvalidScale;
+            }
+            // create swizzler for sampling
+            SkCodec::Result result = this->initializeSwizzler(dstInfo, options);
+            if (SkCodec::kSuccess != result) {
+                SkCodecPrintf("failed to initialize the swizzler.\n");
+                return result;
+            }
+            fStorage.reset(get_row_bytes(fCodec->fDecoderMgr->dinfo()));
+            fSrcRow = static_cast<uint8_t*>(fStorage.get());
+        } else {
+            fSrcRow = NULL;
+            fSwizzler.reset(NULL);
         }
 
         // Now, given valid output dimensions, we can start the decompress
@@ -433,9 +501,16 @@
         if (setjmp(fCodec->fDecoderMgr->getJmpBuf())) {
             return fCodec->fDecoderMgr->returnFailure("setjmp", SkCodec::kInvalidInput);
         }
-
         // Read rows one at a time
-        JSAMPLE* dstRow = (JSAMPLE*) dst;
+        JSAMPLE* dstRow;
+        if (fSwizzler) {
+            // write data to storage row, then sample using swizzler         
+            dstRow = fSrcRow;
+        } else {
+            // write data directly to dst
+            dstRow = (JSAMPLE*) dst;
+        }
+
         for (int y = 0; y < count; y++) {
             // Read row of the image
             uint32_t rowsDecoded =
@@ -452,13 +527,17 @@
 
             // Convert to RGBA if necessary
             if (JCS_CMYK == fCodec->fDecoderMgr->dinfo()->out_color_space) {
-                convert_CMYK_to_RGBA(dstRow, this->dstInfo().width());
+                convert_CMYK_to_RGBA(dstRow, fCodec->fDecoderMgr->dinfo()->output_width);
             }
 
-            // Move to the next row
-            dstRow = SkTAddOffset<JSAMPLE>(dstRow, rowBytes);
+            if(fSwizzler) {
+                // use swizzler to sample row
+                fSwizzler->swizzle(dst, dstRow);
+                dst = SkTAddOffset<JSAMPLE>(dst, rowBytes);
+            } else {
+                dstRow = SkTAddOffset<JSAMPLE>(dstRow, rowBytes);
+            }
         }
-
         return SkCodec::kSuccess;
     }
 
@@ -466,7 +545,7 @@
 // TODO (msarett): Make this a member function and avoid reallocating the
 //                 memory buffer on each call to skip.
 #define chromium_jpeg_skip_scanlines(dinfo, count)                           \
-    SkAutoMalloc storage(dinfo->output_width * dinfo->out_color_components); \
+    SkAutoMalloc storage(get_row_bytes(dinfo));                              \
     uint8_t* storagePtr = static_cast<uint8_t*>(storage.get());              \
     for (int y = 0; y < count; y++) {                                        \
         chromium_jpeg_read_scanlines(dinfo, &storagePtr, 1);                 \
@@ -484,13 +563,16 @@
         return SkCodec::kSuccess;
     }
 
-#ifndef TURBO_HAS_SKIP
-#undef chromium_jpeg_skip_scanlines
-#endif
+    SkEncodedFormat onGetEncodedFormat() const override {
+        return kJPEG_SkEncodedFormat;
+    }
 
 private:
     SkAutoTDelete<SkJpegCodec> fCodec;
+    SkAutoMalloc               fStorage;    // Only used if sampling is needed
+    uint8_t*                   fSrcRow;     // Only used if sampling is needed
     SkCodec::Options           fOpts;
+    SkAutoTDelete<SkSwizzler>  fSwizzler;
 
     typedef SkScanlineDecoder INHERITED;
 };
@@ -502,6 +584,7 @@
     }
 
     const SkImageInfo& srcInfo = codec->getInfo();
+
     // Return the new scanline decoder
     return SkNEW_ARGS(SkJpegScanlineDecoder, (srcInfo, codec.detach()));
 }
diff --git a/src/codec/SkJpegCodec.h b/src/codec/SkJpegCodec.h
index 62a5bbc..fac7d96 100644
--- a/src/codec/SkJpegCodec.h
+++ b/src/codec/SkJpegCodec.h
@@ -110,19 +110,13 @@
     bool setOutputColorSpace(const SkImageInfo& dst);
 
     /*
-     * Checks if we can scale to the requested dimensions and scales the dimensions
-     * if possible
+     * Checks if we can natively scale to the requested dimensions and natively scales the 
+     * dimensions if possible
      */
-    bool scaleToDimensions(uint32_t width, uint32_t height);
-
-    /*
-     * Create the swizzler based on the encoded format
-     */
-    void initializeSwizzler(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes,
-            const Options& options);
+    bool nativelyScaleToDimensions(uint32_t width, uint32_t height); 
 
     SkAutoTDelete<JpegDecoderMgr> fDecoderMgr;
-
+    
     friend class SkJpegScanlineDecoder;
 
     typedef SkCodec INHERITED;
diff --git a/src/codec/SkScaledCodec.cpp b/src/codec/SkScaledCodec.cpp
new file mode 100644
index 0000000..e0158b6
--- /dev/null
+++ b/src/codec/SkScaledCodec.cpp
@@ -0,0 +1,261 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkCodecPriv.h"
+#include "SkScaledCodec.h"
+#include "SkStream.h"
+#include "SkWebpCodec.h"
+
+
+SkCodec* SkScaledCodec::NewFromStream(SkStream* stream) {
+    bool isWebp = SkWebpCodec::IsWebp(stream);
+    if (!stream->rewind()) {
+        return NULL;
+    }
+    if (isWebp) {
+        // Webp codec supports scaling and subsetting natively
+        return SkWebpCodec::NewFromStream(stream);  
+    }
+
+    SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(SkScanlineDecoder::NewFromStream(stream));
+    if (NULL == scanlineDecoder) {
+        return NULL;
+    }
+
+    // wrap in new SkScaledCodec
+    return SkNEW_ARGS(SkScaledCodec, (scanlineDecoder.detach()));
+}
+
+SkCodec* SkScaledCodec::NewFromData(SkData* data) {
+    if (!data) {
+        return NULL;
+    }
+    return NewFromStream(SkNEW_ARGS(SkMemoryStream, (data)));
+}
+
+SkScaledCodec::SkScaledCodec(SkScanlineDecoder* scanlineDecoder)
+    : INHERITED(scanlineDecoder->getInfo(), NULL)
+    , fScanlineDecoder(scanlineDecoder)
+{}
+
+SkScaledCodec::~SkScaledCodec() {}
+
+// returns a scaled dimension based on the original dimension and the sampleSize
+// NOTE: we round down here for scaled dimension to match the behavior of SkImageDecoder
+static int get_scaled_dimension(int srcDimension, int sampleSize) {
+    if (sampleSize > srcDimension) {
+        return 1;
+    }
+    return srcDimension / sampleSize;
+}
+
+static SkISize best_scaled_dimensions(const SkISize& origDims, const SkISize& nativeDims, 
+                                      const SkISize& scaledCodecDims, float desiredScale) {
+    if (nativeDims == scaledCodecDims) {
+        // does not matter which to return if equal. Return here to skip below calculations
+        return nativeDims;
+    }
+    float idealWidth = origDims.width() * desiredScale;
+    float idealHeight = origDims.height() * desiredScale;
+
+    // calculate difference between native dimensions and ideal dimensions
+    float nativeWDiff = SkTAbs(idealWidth - nativeDims.width());
+    float nativeHDiff = SkTAbs(idealHeight - nativeDims.height());
+    float nativeDiff = (nativeWDiff + nativeHDiff) / 2;
+
+    // calculate difference between scaledCodec dimensions and ideal dimensions
+    float scaledCodecWDiff = SkTAbs(idealWidth - scaledCodecDims.width());
+    float scaledCodecHDiff = SkTAbs(idealHeight - scaledCodecDims.height());
+    float scaledCodecDiff = (scaledCodecWDiff + scaledCodecHDiff) / 2;
+
+    // return dimensions closest to ideal dimensions.
+    // If the differences are equal, return nativeDims, as native scaling is more efficient.
+    return nativeDiff > scaledCodecDiff ? scaledCodecDims : nativeDims;
+
+} 
+/*
+ * Return a valid set of output dimensions for this decoder, given an input scale
+ */
+SkISize SkScaledCodec::onGetScaledDimensions(float desiredScale) const {
+    SkISize nativeDimensions = fScanlineDecoder->getScaledDimensions(desiredScale);
+    // support scaling down by integer numbers. Ex: 1/2, 1/3, 1/4 ...
+    SkISize scaledCodecDimensions;
+    if (desiredScale > 0.5f) {
+        // sampleSize = 1
+        scaledCodecDimensions = fScanlineDecoder->getInfo().dimensions();
+    }
+    // sampleSize determines the step size between samples
+    // Ex: sampleSize = 2, sample every second pixel in x and y directions
+    int sampleSize = int(1 / desiredScale);
+
+    int scaledWidth = get_scaled_dimension(this->getInfo().width(), sampleSize);
+    int scaledHeight = get_scaled_dimension(this->getInfo().height(), sampleSize);
+
+    // Return the calculated output dimensions for the given scale
+    scaledCodecDimensions = SkISize::Make(scaledWidth, scaledHeight);
+
+    return best_scaled_dimensions(this->getInfo().dimensions(), nativeDimensions, 
+                                  scaledCodecDimensions, desiredScale);
+}
+
+// check if scaling to dstInfo size from srcInfo size using sampleSize is possible
+static bool scaling_supported(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo,
+                              int* sampleX, int* sampleY) {
+    SkScaledCodec::ComputeSampleSize(dstInfo, srcInfo, sampleX, sampleY);
+    const int dstWidth = dstInfo.width();
+    const int dstHeight = dstInfo.height();
+    const int srcWidth = srcInfo.width();
+    const int srcHeight = srcInfo.height();
+     // only support down sampling, not up sampling
+    if (dstWidth > srcWidth || dstHeight  > srcHeight) {
+        return false;
+    }
+    // check that srcWidth is scaled down by an integer value
+    if (get_scaled_dimension(srcWidth, *sampleX) != dstWidth) {
+        return false;
+    }
+    // check that src height is scaled down by an integer value
+    if (get_scaled_dimension(srcHeight, *sampleY) != dstHeight) {
+        return false;
+    }
+    // sampleX and sampleY should be equal unless the original sampleSize requested was larger
+    // than srcWidth or srcHeight. If so, the result of this is dstWidth or dstHeight = 1.
+    // This functionality allows for tall thin images to still be scaled down by scaling factors.
+    if (*sampleX != *sampleY){
+        if (1 != dstWidth && 1 != dstHeight) {
+            return false;
+        }
+    }
+    return true;
+}
+
+// calculates sampleSize in x and y direction
+void SkScaledCodec::ComputeSampleSize(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo,
+                                      int* sampleXPtr, int* sampleYPtr) {
+    int srcWidth = srcInfo.width();
+    int dstWidth = dstInfo.width();
+    int srcHeight = srcInfo.height();
+    int dstHeight = dstInfo.height();
+
+    int sampleX = srcWidth / dstWidth;
+    int sampleY = srcHeight / dstHeight;
+
+    // only support down sampling, not up sampling
+    SkASSERT(dstWidth <= srcWidth);
+    SkASSERT(dstHeight <= srcHeight);
+
+    // sampleX and sampleY should be equal unless the original sampleSize requested was
+    // larger than srcWidth or srcHeight.
+    // If so, the result of this is dstWidth or dstHeight = 1. This functionality
+    // allows for tall thin images to still be scaled down by scaling factors.
+
+    if (sampleX != sampleY){
+        if (1 != dstWidth && 1 != dstHeight) {
+
+            // rounding during onGetScaledDimensions can cause different sampleSizes
+            // Ex: srcWidth = 79, srcHeight = 20, sampleSize = 10
+            // dstWidth = 7, dstHeight = 2, sampleX = 79/7 = 11, sampleY = 20/2 = 10
+            // correct for this rounding by comparing width to sampleY and height to sampleX
+
+            if (get_scaled_dimension(srcWidth, sampleY) == dstWidth) {
+                sampleX = sampleY;
+            } else if (get_scaled_dimension(srcHeight, sampleX) == dstHeight) {
+                sampleY = sampleX;
+            }
+        }
+    }
+
+    if (sampleXPtr) {
+        *sampleXPtr = sampleX;
+    }
+    if (sampleYPtr) {
+        *sampleYPtr = sampleY;
+    }
+}
+
+// TODO: Implement subsetting in onGetPixels which works when and when not sampling 
+
+SkCodec::Result SkScaledCodec::onGetPixels(const SkImageInfo& requestedInfo, void* dst,
+                                           size_t rowBytes, const Options& options,
+                                           SkPMColor ctable[], int* ctableCount) {
+
+    if (options.fSubset) {
+        // Subsets are not supported.
+        return kUnimplemented;
+    } 
+
+    Result result = fScanlineDecoder->start(requestedInfo, &options, ctable, ctableCount);
+    if (kSuccess == result) {
+        // native decode supported
+        return fScanlineDecoder->getScanlines(dst, requestedInfo.height(), rowBytes);
+
+    }
+
+    if (kInvalidScale != result) {
+        // no scaling requested
+        return result;
+    }
+    
+    // scaling requested
+    int sampleX;
+    int sampleY;
+    if (!scaling_supported(requestedInfo, fScanlineDecoder->getInfo(), &sampleX, &sampleY)) {
+        return kInvalidScale;
+    }
+    // set first sample pixel in y direction
+    int Y0 = sampleY >> 1;
+
+    int dstHeight = requestedInfo.height();
+    int srcHeight = fScanlineDecoder->getInfo().height();
+    
+    SkImageInfo info = requestedInfo;
+    // use original height as scanlineDecoder does not support y sampling natively
+    info = info.makeWH(requestedInfo.width(), srcHeight);
+
+    // update scanlineDecoder with new info
+    result = fScanlineDecoder->start(info, &options, ctable, ctableCount);
+    if (kSuccess != result) {
+        return result;
+    }
+    
+    const bool requiresPostYSampling = fScanlineDecoder->requiresPostYSampling();
+
+    if (requiresPostYSampling) {
+        SkAutoMalloc storage(srcHeight * rowBytes);
+        uint8_t* storagePtr = static_cast<uint8_t*>(storage.get());
+        result = fScanlineDecoder->getScanlines(storagePtr, srcHeight, rowBytes);
+        if (kSuccess != result) {
+            return result;
+        }
+        storagePtr += Y0 * rowBytes;
+        for (int y = 0; y < dstHeight; y++) {
+            memcpy(dst, storagePtr, rowBytes);
+            storagePtr += sampleY * rowBytes;
+            dst = SkTAddOffset<void>(dst, rowBytes);
+        }
+    } else {
+        // does not require post y sampling
+        result = fScanlineDecoder->skipScanlines(Y0);
+        if (kSuccess != result) {
+            return result;
+        }
+        for (int y = 0; y < dstHeight; y++) {
+            result = fScanlineDecoder->getScanlines(dst, 1, rowBytes);
+            if (kSuccess != result) {
+                return result;
+            }
+            if (y < dstHeight - 1) {
+                result = fScanlineDecoder->skipScanlines(sampleY - 1);
+                if (kSuccess != result) {
+                    return result;
+                }
+            }
+            dst = SkTAddOffset<void>(dst, rowBytes);
+        }
+    }
+    return kSuccess;
+}
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp
index b2b7f92..4427761 100644
--- a/src/codec/SkSwizzler.cpp
+++ b/src/codec/SkSwizzler.cpp
@@ -7,6 +7,7 @@
 
 #include "SkCodecPriv.h"
 #include "SkColorPriv.h"
+#include "SkScaledCodec.h"
 #include "SkSwizzler.h"
 #include "SkTemplates.h"
 #include "SkUtils.h"
@@ -19,114 +20,116 @@
     return (((uint16_t) maxAlpha) << 8) | zeroAlpha;
 }
 
+// samples the row. Does not do anything else but sampling
+static SkSwizzler::ResultAlpha sample565(void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src,
+        int width, int deltaSrc, int offset, const SkPMColor ctable[]){
+
+    src += offset;
+    uint16_t* SK_RESTRICT dst = (uint16_t*) dstRow;
+    for (int x = 0; x < width; x++) {
+        dst[x] = src[1] << 8 | src[0];
+        src += deltaSrc;
+    }
+    // 565 is always opaque
+    return SkSwizzler::kOpaque_ResultAlpha;
+}
+
 // kBit
 // These routines exclusively choose between white and black
 
 #define GRAYSCALE_BLACK 0
 #define GRAYSCALE_WHITE 0xFF
 
+
+// same as swizzle_bit_to_index and swizzle_bit_to_n32 except for value assigned to dst[x]
 static SkSwizzler::ResultAlpha swizzle_bit_to_grayscale(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int /*bitsPerPixel*/, const SkPMColor* /*ctable*/) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor* /*ctable*/) {
+
     uint8_t* SK_RESTRICT dst = (uint8_t*) dstRow;
 
-    // Determine how many full bytes are in the row
-    int bytesInRow = width >> 3;
-    int i;
-    for (i = 0; i < bytesInRow; i++) {
-        U8CPU currByte = src[i];
-        for (int j = 0; j < 8; j++) {
-            dst[j] = ((currByte >> (7 - j)) & 1) ? GRAYSCALE_WHITE : GRAYSCALE_BLACK;
-        }
-        dst += 8;
+    // increment src by byte offset and bitIndex by bit offset
+    src += offset / 8;
+    int bitIndex = offset % 8;
+    uint8_t currByte = *src;
+
+    dst[0] = ((currByte >> (7-bitIndex)) & 1) ? GRAYSCALE_WHITE : GRAYSCALE_BLACK;
+
+    for (int x = 1; x < dstWidth; x++) {
+        int bitOffset = bitIndex + deltaSrc;
+        bitIndex = bitOffset % 8;
+        currByte = *(src += bitOffset / 8);
+        dst[x] = ((currByte >> (7-bitIndex)) & 1) ? GRAYSCALE_WHITE : GRAYSCALE_BLACK;
     }
 
-    // Finish the remaining bits
-    width &= 7;
-    if (width > 0) {
-        U8CPU currByte = src[i];
-        for (int j = 0; j < width; j++) {
-            dst[j] = ((currByte >> 7) & 1) ? GRAYSCALE_WHITE : GRAYSCALE_BLACK;
-            currByte <<= 1;
-        }
-    }
     return SkSwizzler::kOpaque_ResultAlpha;
 }
 
 #undef GRAYSCALE_BLACK
 #undef GRAYSCALE_WHITE
 
+// same as swizzle_bit_to_grayscale and swizzle_bit_to_n32 except for value assigned to dst[x]
 static SkSwizzler::ResultAlpha swizzle_bit_to_index(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int /*bitsPerPixel*/, const SkPMColor* /*ctable*/) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor* /*ctable*/) {
     uint8_t* SK_RESTRICT dst = (uint8_t*) dstRow;
 
-    // Determine how many full bytes are in the row
-    int bytesInRow = width >> 3;
-    int i;
-    for (i = 0; i < bytesInRow; i++) {
-        U8CPU currByte = src[i];
-        for (int j = 0; j < 8; j++) {
-            dst[j] = (currByte >> (7 - j)) & 1;
-        }
-        dst += 8;
+    // increment src by byte offset and bitIndex by bit offset
+    src += offset / 8;
+    int bitIndex = offset % 8;
+    uint8_t currByte = *src;
+
+    dst[0] = ((currByte >> (7-bitIndex)) & 1);
+
+    for (int x = 1; x < dstWidth; x++) {
+        int bitOffset = bitIndex + deltaSrc;
+        bitIndex = bitOffset % 8;
+        currByte = *(src += bitOffset / 8);
+        dst[x] = ((currByte >> (7-bitIndex)) & 1);
     }
 
-    // Finish the remaining bits
-    width &= 7;
-    if (width > 0) {
-        U8CPU currByte = src[i];
-        for (int j = 0; j < width; j++) {
-            dst[j] = ((currByte >> 7) & 1);
-            currByte <<= 1;
-        }
-    }
     return SkSwizzler::kOpaque_ResultAlpha;
 }
 
+// same as swizzle_bit_to_grayscale and swizzle_bit_to_index except for value assigned to dst[x]
 static SkSwizzler::ResultAlpha swizzle_bit_to_n32(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int /*bitsPerPixel*/, const SkPMColor* /*ctable*/) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor* /*ctable*/) {
     SkPMColor* SK_RESTRICT dst = (SkPMColor*) dstRow;
 
-    // Determine how many full bytes are in the row
-    int bytesInRow = width >> 3;
-    int i;
-    for (i = 0; i < bytesInRow; i++) {
-        U8CPU currByte = src[i];
-        for (int j = 0; j < 8; j++) {
-            dst[j] = ((currByte >> (7 - j)) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
-        }
-        dst += 8;
+    // increment src by byte offset and bitIndex by bit offset
+    src += offset / 8;
+    int bitIndex = offset % 8;
+    uint8_t currByte = *src;
+
+    dst[0] = ((currByte >> (7 - bitIndex)) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
+
+    for (int x = 1; x < dstWidth; x++) {
+        int bitOffset = bitIndex + deltaSrc;
+        bitIndex = bitOffset % 8;
+        currByte = *(src += bitOffset / 8);
+        dst[x] = ((currByte >> (7 - bitIndex)) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
     }
 
-    // Finish the remaining bits
-    width &= 7;
-    if (width > 0) {
-        U8CPU currByte = src[i];
-        for (int j = 0; j < width; j++) {
-            dst[j] = ((currByte >> 7) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
-            currByte <<= 1;
-        }
-    }
     return SkSwizzler::kOpaque_ResultAlpha;
 }
 
 // kIndex1, kIndex2, kIndex4
 
 static SkSwizzler::ResultAlpha swizzle_small_index_to_index(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bitsPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int bitsPerPixel, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     uint8_t* SK_RESTRICT dst = (uint8_t*) dstRow;
     INIT_RESULT_ALPHA;
     const uint32_t pixelsPerByte = 8 / bitsPerPixel;
-    const size_t rowBytes = compute_row_bytes_ppb(width, pixelsPerByte);
+    const size_t rowBytes = compute_row_bytes_ppb(dstWidth, pixelsPerByte);
     const uint8_t mask = (1 << bitsPerPixel) - 1;
     int x = 0;
     for (uint32_t byte = 0; byte < rowBytes; byte++) {
         uint8_t pixelData = src[byte];
-        for (uint32_t p = 0; p < pixelsPerByte && x < width; p++) {
+        for (uint32_t p = 0; p < pixelsPerByte && x < dstWidth; p++) {
             uint8_t index = (pixelData >> (8 - bitsPerPixel)) & mask;
             UPDATE_RESULT_ALPHA(ctable[index] >> SK_A32_SHIFT);
             dst[x] = index;
@@ -138,18 +141,19 @@
 }
 
 static SkSwizzler::ResultAlpha swizzle_small_index_to_n32(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bitsPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int bitsPerPixel, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     SkPMColor* SK_RESTRICT dst = (SkPMColor*) dstRow;
     INIT_RESULT_ALPHA;
     const uint32_t pixelsPerByte = 8 / bitsPerPixel;
-    const size_t rowBytes = compute_row_bytes_ppb(width, pixelsPerByte);
+    const size_t rowBytes = compute_row_bytes_ppb(dstWidth, pixelsPerByte);
     const uint8_t mask = (1 << bitsPerPixel) - 1;
     int x = 0;
     for (uint32_t byte = 0; byte < rowBytes; byte++) {
         uint8_t pixelData = src[byte];
-        for (uint32_t p = 0; p < pixelsPerByte && x < width; p++) {
+        for (uint32_t p = 0; p < pixelsPerByte && x < dstWidth; p++) {
             uint8_t index = (pixelData >> (8 - bitsPerPixel)) & mask;
             SkPMColor c = ctable[index];
             UPDATE_RESULT_ALPHA(c >> SK_A32_SHIFT);
@@ -164,58 +168,75 @@
 // kIndex
 
 static SkSwizzler::ResultAlpha swizzle_index_to_index(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     uint8_t* SK_RESTRICT dst = (uint8_t*) dstRow;
-    memcpy(dst, src, width);
+    INIT_RESULT_ALPHA;
     // TODO (msarett): Should we skip the loop here and guess that the row is opaque/not opaque?
     //                 SkScaledBitmap sampler just guesses that it is opaque.  This is dangerous
     //                 and probably wrong since gif and bmp (rarely) may have alpha.
-    INIT_RESULT_ALPHA;
-    for (int x = 0; x < width; x++) {
-        UPDATE_RESULT_ALPHA(ctable[src[x]] >> SK_A32_SHIFT);
-    }
-    return COMPUTE_RESULT_ALPHA;
-}
-
-static SkSwizzler::ResultAlpha swizzle_index_to_n32(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
-
-    SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
-    INIT_RESULT_ALPHA;
-    for (int x = 0; x < width; x++) {
-        SkPMColor c = ctable[src[x]];
-        UPDATE_RESULT_ALPHA(c >> SK_A32_SHIFT);
-        dst[x] = c;
-    }
-    return COMPUTE_RESULT_ALPHA;
-}
-
-static SkSwizzler::ResultAlpha swizzle_index_to_n32_skipZ(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
-
-    SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
-    INIT_RESULT_ALPHA;
-    for (int x = 0; x < width; x++) {
-        SkPMColor c = ctable[src[x]];
-        UPDATE_RESULT_ALPHA(c >> SK_A32_SHIFT);
-        if (c != 0) {
-            dst[x] = c;
+    if (1 == deltaSrc) {
+        // A non-zero offset is only used when sampling, meaning that deltaSrc will be
+        // greater than 1. The below loop relies on the fact that src remains unchanged.
+        SkASSERT(0 == offset);
+        memcpy(dst, src, dstWidth);
+        for (int x = 0; x < dstWidth; x++) {
+            UPDATE_RESULT_ALPHA(ctable[src[x]] >> SK_A32_SHIFT);
+        }
+    } else {
+        for (int x = 0; x < dstWidth; x++) {
+            dst[x] = *src;
+            UPDATE_RESULT_ALPHA(ctable[*src] >> SK_A32_SHIFT);
+            src += deltaSrc;
         }
     }
     return COMPUTE_RESULT_ALPHA;
 }
 
+static SkSwizzler::ResultAlpha swizzle_index_to_n32(
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
+
+    src += offset;
+    SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
+    INIT_RESULT_ALPHA;
+    for (int x = 0; x < dstWidth; x++) {
+        SkPMColor c = ctable[*src];
+        UPDATE_RESULT_ALPHA(c >> SK_A32_SHIFT);
+        dst[x] = c;
+        src += deltaSrc;
+    }
+    return COMPUTE_RESULT_ALPHA;
+}
+
+static SkSwizzler::ResultAlpha swizzle_index_to_n32_skipZ(
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
+
+    src += offset;
+    SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
+    INIT_RESULT_ALPHA;
+    for (int x = 0; x < dstWidth; x++) {
+        SkPMColor c = ctable[*src];
+        UPDATE_RESULT_ALPHA(c >> SK_A32_SHIFT);
+        if (c != 0) {
+            dst[x] = c;
+        }
+        src += deltaSrc;
+    }
+    return COMPUTE_RESULT_ALPHA;
+}
+
 static SkSwizzler::ResultAlpha swizzle_index_to_565(
-      void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-      int bytesPerPixel, const SkPMColor ctable[]) {
+      void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+      int bytesPerPixel, int offset, const SkPMColor ctable[]) {
     // FIXME: Support dithering? Requires knowing y, which I think is a bigger
     // change.
+    src += offset;
     uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         dst[x] = SkPixel32ToPixel16(ctable[*src]);
         src += bytesPerPixel;
     }
@@ -228,29 +249,42 @@
 // kGray
 
 static SkSwizzler::ResultAlpha swizzle_gray_to_n32(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
-    for (int x = 0; x < width; x++) {
-        dst[x] = SkPackARGB32NoCheck(0xFF, src[x], src[x], src[x]);
+    for (int x = 0; x < dstWidth; x++) {
+        dst[x] = SkPackARGB32NoCheck(0xFF, *src, *src, *src);
+        src += deltaSrc;
     }
     return SkSwizzler::kOpaque_ResultAlpha;
 }
 
 static SkSwizzler::ResultAlpha swizzle_gray_to_gray(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
-    memcpy(dstRow, src, width);
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
+
+    src += offset;
+    uint8_t* SK_RESTRICT dst = (uint8_t*) dstRow;
+    if (1 == deltaSrc) {
+        memcpy(dstRow, src, dstWidth);
+    } else {
+        for (int x = 0; x < dstWidth; x++) {
+            dst[x] = src[0];
+            src += deltaSrc;
+        }
+    }
     return SkSwizzler::kOpaque_ResultAlpha;
 }
 
 static SkSwizzler::ResultAlpha swizzle_gray_to_565(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int bytesPerPixel, int offset, const SkPMColor ctable[]) {
     // FIXME: Support dithering?
+    src += offset;
     uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         dst[x] = SkPack888ToRGB16(src[0], src[0], src[0]);
         src += bytesPerPixel;
     }
@@ -260,13 +294,14 @@
 // kBGRX
 
 static SkSwizzler::ResultAlpha swizzle_bgrx_to_n32(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         dst[x] = SkPackARGB32NoCheck(0xFF, src[2], src[1], src[0]);
-        src += bytesPerPixel;
+        src += deltaSrc;
     }
     return SkSwizzler::kOpaque_ResultAlpha;
 }
@@ -274,54 +309,58 @@
 // kBGRA
 
 static SkSwizzler::ResultAlpha swizzle_bgra_to_n32_unpremul(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
     INIT_RESULT_ALPHA;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         uint8_t alpha = src[3];
         UPDATE_RESULT_ALPHA(alpha);
         dst[x] = SkPackARGB32NoCheck(alpha, src[2], src[1], src[0]);
-        src += bytesPerPixel;
+        src += deltaSrc;
     }
     return COMPUTE_RESULT_ALPHA;
 }
 
 static SkSwizzler::ResultAlpha swizzle_bgra_to_n32_premul(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
     INIT_RESULT_ALPHA;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         uint8_t alpha = src[3];
         UPDATE_RESULT_ALPHA(alpha);
         dst[x] = SkPreMultiplyARGB(alpha, src[2], src[1], src[0]);
-        src += bytesPerPixel;
+        src += deltaSrc;
     }
     return COMPUTE_RESULT_ALPHA;
 }
 
 // kRGBX
 static SkSwizzler::ResultAlpha swizzle_rgbx_to_n32(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         dst[x] = SkPackARGB32(0xFF, src[0], src[1], src[2]);
-        src += bytesPerPixel;
+        src += deltaSrc;
     }
     return SkSwizzler::kOpaque_ResultAlpha;
 }
 
 static SkSwizzler::ResultAlpha swizzle_rgbx_to_565(
-       void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-       int bytesPerPixel, const SkPMColor ctable[]) {
+       void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+       int bytesPerPixel, int offset, const SkPMColor ctable[]) {
     // FIXME: Support dithering?
+    src += offset;
     uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         dst[x] = SkPack888ToRGB16(src[0], src[1], src[2]);
         src += bytesPerPixel;
     }
@@ -331,48 +370,51 @@
 
 // kRGBA
 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_premul(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
     INIT_RESULT_ALPHA;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         unsigned alpha = src[3];
         UPDATE_RESULT_ALPHA(alpha);
         dst[x] = SkPreMultiplyARGB(alpha, src[0], src[1], src[2]);
-        src += bytesPerPixel;
+        src += deltaSrc;
     }
     return COMPUTE_RESULT_ALPHA;
 }
 
 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_unpremul(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     uint32_t* SK_RESTRICT dst = reinterpret_cast<uint32_t*>(dstRow);
     INIT_RESULT_ALPHA;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         unsigned alpha = src[3];
         UPDATE_RESULT_ALPHA(alpha);
         dst[x] = SkPackARGB32NoCheck(alpha, src[0], src[1], src[2]);
-        src += bytesPerPixel;
+        src += deltaSrc;
     }
     return COMPUTE_RESULT_ALPHA;
 }
 
 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_premul_skipZ(
-        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
-        int bytesPerPixel, const SkPMColor ctable[]) {
+        void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
+        int deltaSrc, int offset, const SkPMColor ctable[]) {
 
+    src += offset;
     SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
     INIT_RESULT_ALPHA;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         unsigned alpha = src[3];
         UPDATE_RESULT_ALPHA(alpha);
         if (0 != alpha) {
             dst[x] = SkPreMultiplyARGB(alpha, src[0], src[1], src[2]);
         }
-        src += bytesPerPixel;
+        src += deltaSrc;
     }
     return COMPUTE_RESULT_ALPHA;
 }
@@ -385,11 +427,12 @@
     decide whether to switch to unpremul default.
 static bool swizzle_rgba_to_n32_unpremul_skipZ(void* SK_RESTRICT dstRow,
                                                const uint8_t* SK_RESTRICT src,
-                                               int width, int bitsPerPixel,
+                                               int dstWidth, int bitsPerPixel, int offset,
                                                const SkPMColor[]) {
+    src += offset;
     SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
     unsigned alphaMask = 0xFF;
-    for (int x = 0; x < width; x++) {
+    for (int x = 0; x < dstWidth; x++) {
         unsigned alpha = src[3];
         // NOTE: We cheat here. The caller requested unpremul and skip zeroes. It's possible
         // the color components are not zero, but we skip them anyway, meaning they'll remain
@@ -406,9 +449,10 @@
 
 SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc,
                                        const SkPMColor* ctable,
-                                       const SkImageInfo& info,
-                                       SkCodec::ZeroInitialized zeroInit) {
-    if (info.colorType() == kUnknown_SkColorType || kUnknown == sc) {
+                                       const SkImageInfo& dstInfo, 
+                                       SkCodec::ZeroInitialized zeroInit, 
+                                       const SkImageInfo& srcInfo) {
+    if (dstInfo.colorType() == kUnknown_SkColorType || kUnknown == sc) {
         return NULL;
     }
     if ((kIndex == sc || kIndex4 == sc || kIndex2 == sc || kIndex1 == sc)
@@ -416,9 +460,10 @@
         return NULL;
     }
     RowProc proc = NULL;
+
     switch (sc) {
         case kBit:
-            switch (info.colorType()) {
+            switch (dstInfo.colorType()) {
                 case kN32_SkColorType:
                     proc = &swizzle_bit_to_n32;
                     break;
@@ -435,7 +480,7 @@
         case kIndex1:
         case kIndex2:
         case kIndex4:
-            switch (info.colorType()) {
+            switch (dstInfo.colorType()) {
                 case kN32_SkColorType:
                     proc = &swizzle_small_index_to_n32;
                     break;
@@ -447,7 +492,7 @@
             }
             break;
         case kIndex:
-            switch (info.colorType()) {
+            switch (dstInfo.colorType()) {
                 case kN32_SkColorType:
                     // We assume the color premultiplied ctable (or not) as desired.
                     if (SkCodec::kYes_ZeroInitialized == zeroInit) {
@@ -469,7 +514,7 @@
             }
             break;
         case kGray:
-            switch (info.colorType()) {
+            switch (dstInfo.colorType()) {
                 case kN32_SkColorType:
                     proc = &swizzle_gray_to_n32;
                     break;
@@ -485,7 +530,7 @@
             break;
         case kBGR:
         case kBGRX:
-            switch (info.colorType()) {
+            switch (dstInfo.colorType()) {
                 case kN32_SkColorType:
                     proc = &swizzle_bgrx_to_n32;
                     break;
@@ -494,9 +539,9 @@
             }
             break;
         case kBGRA:
-            switch (info.colorType()) {
+            switch (dstInfo.colorType()) {
                 case kN32_SkColorType:
-                    switch (info.alphaType()) {
+                    switch (dstInfo.alphaType()) {
                         case kUnpremul_SkAlphaType:
                             proc = &swizzle_bgra_to_n32_unpremul;
                             break;
@@ -513,7 +558,7 @@
             break;
         case kRGBX:
             // TODO: Support other swizzles.
-            switch (info.colorType()) {
+            switch (dstInfo.colorType()) {
                 case kN32_SkColorType:
                     proc = &swizzle_rgbx_to_n32;
                     break;
@@ -524,9 +569,9 @@
             }
             break;
         case kRGBA:
-            switch (info.colorType()) {
+            switch (dstInfo.colorType()) {
                 case kN32_SkColorType:
-                    if (info.alphaType() == kUnpremul_SkAlphaType) {
+                    if (dstInfo.alphaType() == kUnpremul_SkAlphaType) {
                         // Respect zeroInit?
                         proc = &swizzle_rgba_to_n32_unpremul;
                     } else {
@@ -542,7 +587,7 @@
             }
             break;
         case kRGB:
-            switch (info.colorType()) {
+            switch (dstInfo.colorType()) {
                 case kN32_SkColorType:
                     proc = &swizzle_rgbx_to_n32;
                     break;
@@ -550,6 +595,14 @@
                     break;
             }
             break;
+        case kRGB_565:
+            switch (dstInfo.colorType()) {
+                case kRGB_565_SkColorType:
+                    proc = &sample565;
+                    break;
+                default:
+                    break;
+            }
         default:
             break;
     }
@@ -558,22 +611,31 @@
     }
 
     // Store deltaSrc in bytes if it is an even multiple, otherwise use bits
-    int deltaSrc = SkIsAlign8(BitsPerPixel(sc)) ? BytesPerPixel(sc) :
-            BitsPerPixel(sc);
-    return SkNEW_ARGS(SkSwizzler, (proc, ctable, deltaSrc, info));
+    int deltaSrc = SkIsAlign8(BitsPerPixel(sc)) ? BytesPerPixel(sc) : BitsPerPixel(sc);
+
+    // get sampleX based on srcInfo and dstInfo dimensions
+    int sampleX;
+    SkScaledCodec::ComputeSampleSize(dstInfo, srcInfo, &sampleX, NULL);
+    
+    return SkNEW_ARGS(SkSwizzler, (proc, ctable, deltaSrc, dstInfo, sampleX));
 }
 
 SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable,
-                       int deltaSrc, const SkImageInfo& info)
+                       int deltaSrc, const SkImageInfo& info, int sampleX)
     : fRowProc(proc)
     , fColorTable(ctable)
     , fDeltaSrc(deltaSrc)
     , fDstInfo(info)
-{}
+    , fSampleX(sampleX)
+    , fX0(sampleX == 1 ? 0 : sampleX >> 1)
+{
+    // check that fX0 is less than original width
+    SkASSERT(fX0 >= 0 && fX0 < fDstInfo.width() * fSampleX);
+}
 
 SkSwizzler::ResultAlpha SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) {
     SkASSERT(NULL != dst && NULL != src);
-    return fRowProc(dst, src, fDstInfo.width(), fDeltaSrc, fColorTable);
+    return fRowProc(dst, src, fDstInfo.width(), fSampleX * fDeltaSrc, fX0 * fDeltaSrc, fColorTable);
 }
 
 void SkSwizzler::Fill(void* dstStartRow, const SkImageInfo& dstInfo, size_t dstRowBytes,
diff --git a/src/codec/SkSwizzler.h b/src/codec/SkSwizzler.h
index 2fab7f6..b7132ce 100644
--- a/src/codec/SkSwizzler.h
+++ b/src/codec/SkSwizzler.h
@@ -117,16 +117,22 @@
     /**
      *  Create a new SkSwizzler.
      *  @param SrcConfig Description of the format of the source.
-     *  @param SkImageInfo dimensions() describe both the src and the dst.
-     *              Other fields describe the dst.
+     *  @param dstInfo describes the destination.
      *  @param ZeroInitialized Whether dst is zero-initialized. The
                                implementation may choose to skip writing zeroes
      *                         if set to kYes_ZeroInitialized.
+     *  @param srcInfo is the info of the source. Used to calculate the width samplesize.
+     *                  Width sampling is supported by the swizzler, by skipping pixels when 
+                        swizzling the row. Height sampling is not supported by the swizzler, 
+                        but is implemented in SkScaledCodec.
+                        Sampling in Y can be done by a client with a scanline decoder, 
+                        but sampling in X allows the swizzler to skip swizzling pixels and
+                        reading from and writing to memory.
      *  @return A new SkSwizzler or NULL on failure.
      */
     static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable,
-                                      const SkImageInfo&, SkCodec::ZeroInitialized);
-
+                                      const SkImageInfo& dstInfo, SkCodec::ZeroInitialized, 
+                                      const SkImageInfo& srcInfo);
     /**
      * Fill the remainder of the destination with a single color
      *
@@ -181,14 +187,16 @@
      *  Method for converting raw data to Skia pixels.
      *  @param dstRow Row in which to write the resulting pixels.
      *  @param src Row of src data, in format specified by SrcConfig
-     *  @param width Width in pixels
+     *  @param dstWidth Width in pixels of the destination
      *  @param deltaSrc if bitsPerPixel % 8 == 0, deltaSrc is bytesPerPixel
      *                  else, deltaSrc is bitsPerPixel
      *  @param ctable Colors (used for kIndex source).
+     *  @param offset The offset before the first pixel to sample.
+                        Is in bytes or bits based on what deltaSrc is in.
      */
     typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow,
                                    const uint8_t* SK_RESTRICT src,
-                                   int width, int deltaSrc,
+                                   int dstWidth, int deltaSrc, int offset,
                                    const SkPMColor ctable[]);
 
     const RowProc       fRowProc;
@@ -199,9 +207,10 @@
                                           //     deltaSrc is bitsPerPixel
     const SkImageInfo   fDstInfo;
     int                 fCurrY;
+    const int           fX0;              // first X coord to sample
+    const int           fSampleX;         // step between X samples
 
-    SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc,
-               const SkImageInfo& info);
-
+    SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, const SkImageInfo& info, 
+               int sampleX);
 };
 #endif // SkSwizzler_DEFINED
diff --git a/tools/dm_flags.py b/tools/dm_flags.py
index 40673c7..9019b02 100755
--- a/tools/dm_flags.py
+++ b/tools/dm_flags.py
@@ -138,6 +138,12 @@
     blacklist.extend('gpu image subset _ msaa image subset _'.split(' '))
     blacklist.extend('msaa16 gm _ tilemodesProcess'.split(' '))
 
+  # the 32-bit GCE bots run out of memory in DM when running these large images
+  if 'x86' in bot and not 'x86-64' in bot:
+    blacklist.extend('_ image _ interlaced1.png'.split(' '))
+    blacklist.extend('_ image _ interlaced2.png'.split(' '))
+    blacklist.extend('_ image _ interlaced3.png'.split(' '))
+
   if blacklist:
     args.append('--blacklist')
     args.extend(blacklist)
