Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: src/utils/SkBitmapRegionSampler.cpp

Issue 1288963002: Provides multiple implementations of Android's SkBitmapRegionDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkBitmapRegionSampler.h"
9
10 SkBitmapRegionSampler::SkBitmapRegionSampler(SkImageDecoder* decoder, int width,
11 int height)
12 : INHERITED(width, height)
13 , fDecoder(decoder)
14 {}
15
16 /*
17 * This has several key differences from the Android version:
18 * Returns a Skia bitmap instead of an Android bitmap.
19 * Android version attempts to reuse a recycled bitmap.
20 * Removed the options object and used parameters for color type and
21 * sample size.
22 */
23 SkBitmap* SkBitmapRegionSampler::decodeRegion(int start_x, int start_y,
24 int width, int height,
25 int sampleSize,
26 SkColorType prefColorType) {
27 // Match Android's default settings
28 fDecoder->setDitherImage(true);
29 fDecoder->setPreferQualityOverSpeed(false);
30 fDecoder->setRequireUnpremultipliedColors(false);
31 fDecoder->setSampleSize(sampleSize);
32
33 SkIRect region;
34 region.fLeft = start_x;
35 region.fTop = start_y;
36 region.fRight = start_x + width;
37 region.fBottom = start_y + height;
38
39 SkAutoTDelete<SkBitmap> bitmap(new SkBitmap());
40 if (!fDecoder->decodeSubset(bitmap.get(), region, prefColorType)) {
41 SkDebugf("Error: decodeRegion failed.\n");
42 return nullptr;
43 }
44 return bitmap.detach();
45 }
OLDNEW
« src/utils/SkBitmapRegionCanvas.cpp ('K') | « src/utils/SkBitmapRegionSampler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698