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

Side by Side Diff: samplecode/DecodeFile.h

Issue 1812323003: Remove uses of SkImageDecoder from samplecode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | samplecode/SampleAll.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 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 "SkBitmap.h"
9 #include "SkCodec.h"
10 #include "SkData.h"
11
12 inline bool decode_file(const char* filename, SkBitmap* bitmap,
13 SkColorType colorType = kN32_SkColorType, bool requireUnpremul = false) {
14 SkASSERT(kIndex_8_SkColorType != colorType);
15 SkAutoTUnref<SkData> data(SkData::NewFromFileName(filename));
16 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
17 if (!codec) {
18 return false;
19 }
20
21 SkImageInfo info = codec->getInfo().makeColorType(colorType);
22 if (requireUnpremul && kPremul_SkAlphaType == info.alphaType()) {
23 info = info.makeAlphaType(kUnpremul_SkAlphaType);
24 }
25
26 if (!bitmap->tryAllocPixels(info)) {
27 return false;
28 }
29
30 return SkCodec::kSuccess == codec->getPixels(info, bitmap->getPixels(), bitm ap->rowBytes());
31 }
OLDNEW
« no previous file with comments | « no previous file | samplecode/SampleAll.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698