Index: src/utils/SkBitmapTransformer.cpp |
=================================================================== |
--- src/utils/SkBitmapTransformer.cpp (revision 8826) |
+++ src/utils/SkBitmapTransformer.cpp (working copy) |
@@ -85,3 +85,30 @@ |
fBitmap.unlockPixels(); |
return true; |
} |
+ |
+bool SkBitmapTransformer::copyRowToPixelBuffer(int row, void *dstBuffer, |
+ size_t dstBufferSize) const { |
+ if (!this->isValid(true)) { |
+ return false; |
+ } |
+ if ((row < 0) || (row >= this->numRows())) { |
+ // EPOGER: add unit test for this check |
+ SkDEBUGF(("row %d must be within range [0,%d]\n", row, numRows()-1)); |
+ return false; |
+ } |
+ size_t bytesNeeded = this->bytesNeededPerRow(); |
+ if (dstBufferSize < bytesNeeded) { |
+ SkDEBUGF(("dstBufferSize %d must be >= %d\n", dstBufferSize, bytesNeeded)); |
+ return false; |
+ } |
+ |
+ fBitmap.lockPixels(); |
+ int width = fBitmap.width(); |
+ size_t srcRowBytes = fBitmap.rowBytes(); |
+ const char *srcBytes = const_cast<const char *>(static_cast<char*>(fBitmap.getPixels())); |
+ char *dstBytes = static_cast<char *>(dstBuffer); |
+ srcBytes += srcRowBytes * row; |
+ transform_scanline(srcBytes, width, dstBytes); |
+ fBitmap.unlockPixels(); |
+ return true; |
+} |