• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef SkImageEncoder_DEFINED
2 #define SkImageEncoder_DEFINED
3 
4 #include "SkTypes.h"
5 
6 class SkBitmap;
7 class SkWStream;
8 
9 class SkImageEncoder {
10 public:
11     enum Type {
12         kJPEG_Type,
13         kPNG_Type
14     };
15     static SkImageEncoder* Create(Type);
16 
17     virtual ~SkImageEncoder();
18 
19     /*  Quality ranges from 0..100 */
20     enum {
21         kDefaultQuality = 80
22     };
23 
24     bool encodeFile(const char file[], const SkBitmap&, int quality);
25     bool encodeStream(SkWStream*, const SkBitmap&, int quality);
26 
27     static bool EncodeFile(const char file[], const SkBitmap&, Type,
28                            int quality);
29     static bool EncodeStream(SkWStream*, const SkBitmap&, Type,
30                            int quality);
31 
32 protected:
33     virtual bool onEncode(SkWStream*, const SkBitmap&, int quality) = 0;
34 };
35 
36 #endif
37