OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2013 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 "SkDecodingImageGenerator.h" |
| 9 |
| 10 #include "SkBitmapFactory.h" |
| 11 #include "SkData.h" |
| 12 #include "SkImageDecoder.h" |
| 13 |
| 14 SkDecodingImageGenerator::SkDecodingImageGenerator(SkData* data) |
| 15 : fData(data) { |
| 16 SkASSERT(fData != NULL); |
| 17 fData->ref(); |
| 18 } |
| 19 |
| 20 SkDecodingImageGenerator::~SkDecodingImageGenerator() { |
| 21 fData->unref(); |
| 22 } |
| 23 |
| 24 SkData* SkDecodingImageGenerator::refEncodedData() { |
| 25 fData->ref(); |
| 26 return fData; |
| 27 } |
| 28 |
| 29 bool SkDecodingImageGenerator::getInfo(SkImageInfo* info) { |
| 30 return SkImageDecoder::DecodeMemoryToTarget(fData->data(), |
| 31 fData->size(), |
| 32 info, NULL); |
| 33 } |
| 34 |
| 35 bool SkDecodingImageGenerator::getPixels(const SkImageInfo& info, |
| 36 void* pixels, |
| 37 size_t rowBytes) { |
| 38 SkBitmapFactory::Target target = {pixels, rowBytes}; |
| 39 SkImageInfo tmpInfo = info; |
| 40 return SkImageDecoder::DecodeMemoryToTarget(fData->data(), |
| 41 fData->size(), |
| 42 &tmpInfo, &target); |
| 43 } |
OLD | NEW |