| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBitmapRegionSampler.h" | 8 #include "SkBitmapRegionSampler.h" |
| 9 #include "SkCodecPriv.h" |
| 9 | 10 |
| 10 SkBitmapRegionSampler::SkBitmapRegionSampler(SkImageDecoder* decoder, int width,
| 11 SkBitmapRegionSampler::SkBitmapRegionSampler(SkImageDecoder* decoder, int width,
|
| 11 int height) | 12 int height) |
| 12 : INHERITED(width, height) | 13 : INHERITED(width, height) |
| 13 , fDecoder(decoder) | 14 , fDecoder(decoder) |
| 14 {} | 15 {} |
| 15 | 16 |
| 16 /* | 17 /* |
| 17 * Three differences from the Android version: | 18 * Three differences from the Android version: |
| 18 * Returns a Skia bitmap instead of an Android bitmap. | 19 * Returns a Skia bitmap instead of an Android bitmap. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 36 } | 37 } |
| 37 | 38 |
| 38 SkIRect region; | 39 SkIRect region; |
| 39 region.fLeft = start_x; | 40 region.fLeft = start_x; |
| 40 region.fTop = start_y; | 41 region.fTop = start_y; |
| 41 region.fRight = start_x + width; | 42 region.fRight = start_x + width; |
| 42 region.fBottom = start_y + height; | 43 region.fBottom = start_y + height; |
| 43 | 44 |
| 44 SkAutoTDelete<SkBitmap> bitmap(new SkBitmap()); | 45 SkAutoTDelete<SkBitmap> bitmap(new SkBitmap()); |
| 45 if (!fDecoder->decodeSubset(bitmap.get(), region, prefColorType)) { | 46 if (!fDecoder->decodeSubset(bitmap.get(), region, prefColorType)) { |
| 46 SkDebugf("Error: decodeRegion failed.\n"); | 47 SkCodecPrintf("Error: decodeRegion failed.\n"); |
| 47 return nullptr; | 48 return nullptr; |
| 48 } | 49 } |
| 49 return bitmap.detach(); | 50 return bitmap.detach(); |
| 50 } | 51 } |
| OLD | NEW |