Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (C) 2010 The Android Open Source Project | |
| 3 * | |
| 4 * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 * you may not use this file except in compliance with the License. | |
| 6 * You may obtain a copy of the License at | |
| 7 * | |
| 8 * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 * | |
| 10 * Unless required by applicable law or agreed to in writing, software | |
| 11 * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 * See the License for the specific language governing permissions and | |
| 14 * limitations under the License. | |
| 15 */ | |
| 16 | |
| 17 #include "SkBitmapRegionSampler.h" | |
| 18 | |
| 19 SkBitmapRegionSampler::SkBitmapRegionSampler(SkImageDecoder* decoder, int width, | |
| 20 int height) | |
| 21 : INHERITED(width, height) | |
| 22 , fDecoder(decoder) | |
| 23 {} | |
| 24 | |
| 25 /* | |
| 26 * This has several key differences from the Android version: | |
| 27 * Returns a Skia bitmap instead of an Android bitmap. | |
| 28 * Android version attempts to reuse a recycled bitmap. | |
| 29 * Removed the options object and used parameters for color type and | |
| 30 * sample size. | |
| 31 */ | |
| 32 SkBitmap* SkBitmapRegionSampler::decodeRegion(int start_x, int start_y, | |
| 33 int width, int height, | |
| 34 int sampleSize, | |
| 35 SkColorType prefColorType) { | |
| 36 | |
| 37 fDecoder->setDitherImage(true); | |
|
scroggo
2015/08/13 16:53:07
Why did you choose these settings?
msarett
2015/08/13 18:10:23
These are Android's default settings. Adding a co
| |
| 38 fDecoder->setPreferQualityOverSpeed(false); | |
| 39 fDecoder->setRequireUnpremultipliedColors(false); | |
| 40 fDecoder->setSampleSize(sampleSize); | |
| 41 SkIRect region; | |
|
scroggo
2015/08/13 16:53:07
nit: a blank line before this line would be helpfu
msarett
2015/08/13 18:10:23
Done.
| |
| 42 region.fLeft = start_x; | |
| 43 region.fTop = start_y; | |
| 44 region.fRight = start_x + width; | |
| 45 region.fBottom = start_y + height; | |
| 46 | |
| 47 SkAutoTDelete<SkBitmap> bitmap(new SkBitmap()); | |
| 48 if (!fDecoder->decodeSubset(bitmap.get(), region, prefColorType)) { | |
| 49 SkDebugf("Error: decodeRegion failed.\n"); | |
| 50 return NULL; | |
| 51 } | |
| 52 return bitmap.detach(); | |
| 53 } | |
| OLD | NEW |