• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef CodecPriv_DEFINED
8 #define CodecPriv_DEFINED
9 
10 #include "SkBitmap.h"
11 #include "SkCodec.h"
12 #include "SkData.h"
13 
decode_memory(const void * mem,size_t size,SkBitmap * bm)14 inline bool decode_memory(const void* mem, size_t size, SkBitmap* bm) {
15     std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(SkData::MakeWithoutCopy(mem, size)));
16     if (!codec) {
17         return false;
18     }
19 
20     bm->allocPixels(codec->getInfo());
21     const SkCodec::Result result = codec->getPixels(codec->getInfo(), bm->getPixels(),
22             bm->rowBytes());
23     return result == SkCodec::kSuccess || result == SkCodec::kIncompleteInput;
24 }
25 #endif  // CodecPriv_DEFINED
26