/src/skia/tools/DecodeUtils.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2023 Google LLC |
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 "tools/DecodeUtils.h" |
9 | | |
10 | | #include "include/core/SkBitmap.h" |
11 | | #include "include/core/SkColorSpace.h" |
12 | | #include "include/core/SkData.h" |
13 | | #include "include/core/SkImageGenerator.h" |
14 | | #include "include/core/SkImageInfo.h" |
15 | | #include "src/image/SkImageGeneratorPriv.h" |
16 | | |
17 | | #include <memory> |
18 | | #include <utility> |
19 | | |
20 | | namespace ToolUtils { |
21 | | |
22 | 0 | bool DecodeDataToBitmap(sk_sp<SkData> data, SkBitmap* dst) { |
23 | 0 | std::unique_ptr<SkImageGenerator> gen(SkImageGenerators::MakeFromEncoded(std::move(data))); |
24 | 0 | return gen && dst->tryAllocPixels(gen->getInfo()) && |
25 | 0 | gen->getPixels( |
26 | 0 | gen->getInfo().makeColorSpace(nullptr), dst->getPixels(), dst->rowBytes()); |
27 | 0 | } |
28 | | |
29 | | } // namespace ToolUtils |