aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/images/SkBitmapFactory.h
blob: 6779dc24c3beaa279c664200093db091fd8d36bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * 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