diff options
-rw-r--r-- | skia/ext/image_operations.cc | 4 | ||||
-rw-r--r-- | skia/ext/image_operations_unittest.cc | 17 |
2 files changed, 11 insertions, 10 deletions
diff --git a/skia/ext/image_operations.cc b/skia/ext/image_operations.cc index 9b0beb1..a86f99e 100644 --- a/skia/ext/image_operations.cc +++ b/skia/ext/image_operations.cc @@ -388,12 +388,12 @@ SkBitmap ImageOperations::CreateMaskedBitmap(const SkBitmap& rgb, SkAutoLockPixels lock_alpha(alpha); SkAutoLockPixels lock_masked(masked); - for (int y = 0; y < rgb.height(); y++) { + for (int y = 0; y < masked.height(); y++) { uint32* rgb_row = rgb.getAddr32(0, y); uint32* alpha_row = alpha.getAddr32(0, y); uint32* dst_row = masked.getAddr32(0, y); - for (int x = 0; x < rgb.width(); x++) { + for (int x = 0; x < masked.width(); x++) { uint32 alpha_pixel = alpha_row[x]; SkColor rgb_pixel = SkUnPreMultiply::PMColorToColor(rgb_row[x]); diff --git a/skia/ext/image_operations_unittest.cc b/skia/ext/image_operations_unittest.cc index 40e63bd..5066683 100644 --- a/skia/ext/image_operations_unittest.cc +++ b/skia/ext/image_operations_unittest.cc @@ -202,19 +202,20 @@ TEST(ImageOperations, CreateMaskedBitmap) { SkBitmap alpha; alpha.setConfig(SkBitmap::kARGB_8888_Config, src_w, src_h); alpha.allocPixels(); - - unsigned char* src_data = - reinterpret_cast<unsigned char*>(alpha.getAddr32(0, 0)); - for (int i = 0; i < src_w * src_h; i++) { - src_data[i * 4] = SkColorSetARGB(i + 128 % 255, - i + 128 % 255, - i + 64 % 255, - i + 0 % 255); + for (int y = 0, i = 0; y < src_h; y++) { + for (int x = 0; x < src_w; x++) { + *alpha.getAddr32(x, y) = SkColorSetARGB(i + 128 % 255, + i + 128 % 255, + i + 64 % 255, + i + 0 % 255); + i++; + } } SkBitmap masked = skia::ImageOperations::CreateMaskedBitmap(src, alpha); SkAutoLockPixels src_lock(src); + SkAutoLockPixels alpha_lock(alpha); SkAutoLockPixels masked_lock(masked); for (int y = 0; y < src_h; y++) { for (int x = 0; x < src_w; x++) { |