Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: include/images/SkImageEncoder.h

Issue 15002004: add encodeData() to SkImageEncoder, and add encoding to SkImage (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #ifndef SkImageEncoder_DEFINED 8 #ifndef SkImageEncoder_DEFINED
9 #define SkImageEncoder_DEFINED 9 #define SkImageEncoder_DEFINED
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 12
13 class SkBitmap; 13 class SkBitmap;
14 class SkData;
14 class SkWStream; 15 class SkWStream;
15 16
16 class SkImageEncoder { 17 class SkImageEncoder {
17 public: 18 public:
18 enum Type { 19 enum Type {
19 kUnknown_Type, 20 kUnknown_Type,
20 kBMP_Type, 21 kBMP_Type,
21 kGIF_Type, 22 kGIF_Type,
22 kICO_Type, 23 kICO_Type,
23 kJPEG_Type, 24 kJPEG_Type,
24 kPNG_Type, 25 kPNG_Type,
25 kWBMP_Type, 26 kWBMP_Type,
26 kWEBP_Type, 27 kWEBP_Type,
27 }; 28 };
28 static SkImageEncoder* Create(Type); 29 static SkImageEncoder* Create(Type);
29 30
30 virtual ~SkImageEncoder(); 31 virtual ~SkImageEncoder();
31 32
32 /* Quality ranges from 0..100 */ 33 /* Quality ranges from 0..100 */
33 enum { 34 enum {
34 kDefaultQuality = 80 35 kDefaultQuality = 80
35 }; 36 };
36 37
37 /** 38 /**
39 * Encode bitmap 'bm', returning the results in an SkData, at quality level
40 * 'quality' (which can be in range 0-100). If the bitmap cannot be
41 * encoded, return null. On success, the caller is responsible for
42 * calling unref() on the data when they are finished.
43 */
44 SkData* encodeData(const SkBitmap&, int quality);
45
46 /**
38 * Encode bitmap 'bm' in the desired format, writing results to 47 * Encode bitmap 'bm' in the desired format, writing results to
39 * file 'file', at quality level 'quality' (which can be in range 48 * file 'file', at quality level 'quality' (which can be in range
40 * 0-100). 49 * 0-100). Returns false on failure.
41 *
42 * Calls the particular implementation's onEncode() method to
43 * actually do the encoding.
44 */ 50 */
45 bool encodeFile(const char file[], const SkBitmap& bm, int quality); 51 bool encodeFile(const char file[], const SkBitmap& bm, int quality);
46 52
47 /** 53 /**
48 * Encode bitmap 'bm' in the desired format, writing results to 54 * Encode bitmap 'bm' in the desired format, writing results to
49 * stream 'stream', at quality level 'quality' (which can be in 55 * stream 'stream', at quality level 'quality' (which can be in
50 * range 0-100). 56 * range 0-100). Returns false on failure.
51 *
52 * Calls the particular implementation's onEncode() method to
53 * actually do the encoding.
54 */ 57 */
55 bool encodeStream(SkWStream* stream, const SkBitmap& bm, int quality); 58 bool encodeStream(SkWStream* stream, const SkBitmap& bm, int quality);
56 59
60 static SkData* EncodeData(const SkBitmap&, Type, int quality);
57 static bool EncodeFile(const char file[], const SkBitmap&, Type, 61 static bool EncodeFile(const char file[], const SkBitmap&, Type,
58 int quality); 62 int quality);
59 static bool EncodeStream(SkWStream*, const SkBitmap&, Type, 63 static bool EncodeStream(SkWStream*, const SkBitmap&, Type,
60 int quality); 64 int quality);
61 65
62 protected: 66 protected:
63 /** 67 /**
64 * Encode bitmap 'bm' in the desired format, writing results to 68 * Encode bitmap 'bm' in the desired format, writing results to
65 * stream 'stream', at quality level 'quality' (which can be in 69 * stream 'stream', at quality level 'quality' (which can be in
66 * range 0-100). 70 * range 0-100).
(...skipping 20 matching lines...) Expand all
87 /** An ARGBImageEncoder will always write out 91 /** An ARGBImageEncoder will always write out
88 * bitmap.width() * bitmap.height() * 4 92 * bitmap.width() * bitmap.height() * 4
89 * bytes. 93 * bytes.
90 */ 94 */
91 DECLARE_ENCODER_CREATOR(ARGBImageEncoder); 95 DECLARE_ENCODER_CREATOR(ARGBImageEncoder);
92 DECLARE_ENCODER_CREATOR(JPEGImageEncoder); 96 DECLARE_ENCODER_CREATOR(JPEGImageEncoder);
93 DECLARE_ENCODER_CREATOR(PNGImageEncoder); 97 DECLARE_ENCODER_CREATOR(PNGImageEncoder);
94 DECLARE_ENCODER_CREATOR(WEBPImageEncoder); 98 DECLARE_ENCODER_CREATOR(WEBPImageEncoder);
95 99
96 #endif 100 #endif
OLDNEW
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698