• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2011 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 #ifndef SkImageEncoder_DEFINED
9 #define SkImageEncoder_DEFINED
10 
11 #include "SkTypes.h"
12 
13 class SkBitmap;
14 class SkWStream;
15 
16 class SkImageEncoder {
17 public:
18     enum Type {
19         kJPEG_Type,
20         kPNG_Type,
21         kWEBP_Type
22     };
23     static SkImageEncoder* Create(Type);
24 
25     virtual ~SkImageEncoder();
26 
27     /*  Quality ranges from 0..100 */
28     enum {
29         kDefaultQuality = 80
30     };
31 
32     bool encodeFile(const char file[], const SkBitmap&, int quality);
33     bool encodeStream(SkWStream*, const SkBitmap&, int quality);
34 
35     static bool EncodeFile(const char file[], const SkBitmap&, Type,
36                            int quality);
37     static bool EncodeStream(SkWStream*, const SkBitmap&, Type,
38                            int quality);
39 
40 protected:
41     virtual bool onEncode(SkWStream*, const SkBitmap&, int quality) = 0;
42 };
43 
44 #endif
45