9f686f3639
Add a test and a GM for the factory, and a PNG file for it to decode. The PNG file is copyright-free, obtained from http://openclipart.org/detail/29213/paper-plane-by-ddoo In cmykjpeg, do not attempt to decode in the constructor, since it currently crashes on Mac (if you provide the correct resource path). Even when we fix this crash there is no need to do it in the constructor, since we create all of the gms in order to get their names (to determine whether to run them). Review URL: https://codereview.appspot.com/6847122 git-svn-id: http://skia.googlecode.com/svn/trunk@6618 2bbb7eff-a529-9590-31e7-b0007b416f81
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
/*
|
|
* Copyright 2012 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkBitmapFactory_DEFINED
|
|
#define SkBitmapFactory_DEFINED
|
|
|
|
class SkBitmap;
|
|
class SkData;
|
|
|
|
/**
|
|
* General purpose factory for decoding bitmaps.
|
|
*
|
|
* Currently only provides a way to decode a bitmap or its dimensions from an SkData. Future plans
|
|
* include options to provide a bitmap which caches the pixel data.
|
|
*/
|
|
class SkBitmapFactory {
|
|
|
|
public:
|
|
enum Constraints {
|
|
/**
|
|
* Only decode the bounds of the bitmap. No pixels will be allocated.
|
|
*/
|
|
kDecodeBoundsOnly_Constraint,
|
|
|
|
/**
|
|
* Decode the bounds and pixels of the bitmap.
|
|
*/
|
|
kDecodePixels_Constraint,
|
|
};
|
|
|
|
/**
|
|
* Decodes an SkData into an SkBitmap.
|
|
* @param SkBitmap Already created bitmap to encode into.
|
|
* @param SkData Encoded SkBitmap data.
|
|
* @param constraint Specifications for how to do the decoding.
|
|
* @return True on success. If false, passed in SkBitmap is unmodified.
|
|
*/
|
|
static bool DecodeBitmap(SkBitmap*, const SkData*,
|
|
Constraints constraint = kDecodePixels_Constraint);
|
|
};
|
|
|
|
#endif // SkBitmapFactory_DEFINED
|