OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The Android Open Source Project | 2 * Copyright 2009 The Android Open Source Project |
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 "SkImageEncoder.h" | 8 #include "SkImageEncoder.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkStream.h" | 10 #include "SkStream.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 SkData* SkImageEncoder::EncodeData(const SkImageInfo& info, const void* pixels,
size_t rowBytes, | 54 SkData* SkImageEncoder::EncodeData(const SkImageInfo& info, const void* pixels,
size_t rowBytes, |
55 Type t, int quality) { | 55 Type t, int quality) { |
56 SkBitmap bm; | 56 SkBitmap bm; |
57 if (!bm.installPixels(info, const_cast<void*>(pixels), rowBytes)) { | 57 if (!bm.installPixels(info, const_cast<void*>(pixels), rowBytes)) { |
58 return nullptr; | 58 return nullptr; |
59 } | 59 } |
60 SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t)); | 60 SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t)); |
61 return enc.get() ? enc.get()->encodeData(bm, quality) : nullptr; | 61 return enc.get() ? enc.get()->encodeData(bm, quality) : nullptr; |
62 } | 62 } |
63 | |
64 SkData* SkImageEncoder::EncodeData(const SkPixmap& pmap, Type t, int quality) { | |
65 return EncodeData(pmap.info(), pmap.addr(), pmap.rowBytes(), t, quality); | |
66 } | |
67 | |
68 SkData* SkImageEncoder::ReencodeData(SkData* encoded, Type t) { | |
69 SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t)); | |
70 return enc.get() ? enc.get()->onReencodeData(encoded) : nullptr; | |
71 } | |
72 | |
OLD | NEW |