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 kWEBP_Type 15 }; 16 static SkImageEncoder* Create(Type); 17 18 virtual ~SkImageEncoder(); 19 20 /* Quality ranges from 0..100 */ 21 enum { 22 kDefaultQuality = 80 23 }; 24 25 bool encodeFile(const char file[], const SkBitmap&, int quality); 26 bool encodeStream(SkWStream*, const SkBitmap&, int quality); 27 28 static bool EncodeFile(const char file[], const SkBitmap&, Type, 29 int quality); 30 static bool EncodeStream(SkWStream*, const SkBitmap&, Type, 31 int quality); 32 33 protected: 34 virtual bool onEncode(SkWStream*, const SkBitmap&, int quality) = 0; 35 }; 36 37 #endif 38