Home | History | Annotate | Download | only in images
      1 /*
      2  * Copyright 2012 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 #ifndef SkBitmapFactory_DEFINED
      9 #define SkBitmapFactory_DEFINED
     10 
     11 class SkBitmap;
     12 class SkData;
     13 
     14 /**
     15  *  General purpose factory for decoding bitmaps.
     16  *
     17  *  Currently only provides a way to decode a bitmap or its dimensions from an SkData. Future plans
     18  *  include options to provide a bitmap which caches the pixel data.
     19  */
     20 class SkBitmapFactory {
     21 
     22 public:
     23     enum Constraints {
     24         /**
     25          *  Only decode the bounds of the bitmap. No pixels will be allocated.
     26          */
     27         kDecodeBoundsOnly_Constraint,
     28 
     29         /**
     30          *  Decode the bounds and pixels of the bitmap.
     31          */
     32         kDecodePixels_Constraint,
     33     };
     34 
     35     /**
     36      *  Decodes an SkData into an SkBitmap.
     37      *  @param SkBitmap Already created bitmap to encode into.
     38      *  @param SkData Encoded SkBitmap data.
     39      *  @param constraint Specifications for how to do the decoding.
     40      *  @return True on success. If false, passed in SkBitmap is unmodified.
     41      */
     42     static bool DecodeBitmap(SkBitmap*, const SkData*,
     43                              Constraints constraint = kDecodePixels_Constraint);
     44 };
     45 
     46 #endif // SkBitmapFactory_DEFINED
     47