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

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

Issue 1501303002: SkPixelSerializer: support indexed pixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-12-06 (Sunday) 17:21:55 EST Created 5 years 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
« no previous file with comments | « no previous file | include/core/SkPixelSerializer.h » ('j') | src/images/SkImageEncoder.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkImageEncoder_DEFINED 8 #ifndef SkImageEncoder_DEFINED
9 #define SkImageEncoder_DEFINED 9 #define SkImageEncoder_DEFINED
10 10
11 #include "SkImageInfo.h" 11 #include "SkImageInfo.h"
12 #include "SkTRegistry.h" 12 #include "SkTRegistry.h"
13 13
14 class SkBitmap; 14 class SkBitmap;
15 class SkPixelSerializer;
16 class SkPixmap;
15 class SkData; 17 class SkData;
16 class SkWStream; 18 class SkWStream;
17 19
18 class SkImageEncoder { 20 class SkImageEncoder {
19 public: 21 public:
20 // TODO (scroggo): Merge with SkEncodedFormat. 22 // TODO (scroggo): Merge with SkEncodedFormat.
21 enum Type { 23 enum Type {
22 kUnknown_Type, 24 kUnknown_Type,
23 kBMP_Type, 25 kBMP_Type,
24 kGIF_Type, 26 kGIF_Type,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 * Encode bitmap 'bm' in the desired format, writing results to 59 * Encode bitmap 'bm' in the desired format, writing results to
58 * stream 'stream', at quality level 'quality' (which can be in 60 * stream 'stream', at quality level 'quality' (which can be in
59 * range 0-100). Returns false on failure. 61 * range 0-100). Returns false on failure.
60 */ 62 */
61 bool encodeStream(SkWStream* stream, const SkBitmap& bm, int quality); 63 bool encodeStream(SkWStream* stream, const SkBitmap& bm, int quality);
62 64
63 static SkData* EncodeData(const SkImageInfo&, const void* pixels, size_t row Bytes, 65 static SkData* EncodeData(const SkImageInfo&, const void* pixels, size_t row Bytes,
64 Type, int quality); 66 Type, int quality);
65 static SkData* EncodeData(const SkBitmap&, Type, int quality); 67 static SkData* EncodeData(const SkBitmap&, Type, int quality);
66 68
69 static SkData* EncodeData(const SkPixmap&, Type, int quality);
70
67 static bool EncodeFile(const char file[], const SkBitmap&, Type, 71 static bool EncodeFile(const char file[], const SkBitmap&, Type,
68 int quality); 72 int quality);
69 static bool EncodeStream(SkWStream*, const SkBitmap&, Type, 73 static bool EncodeStream(SkWStream*, const SkBitmap&, Type,
70 int quality); 74 int quality);
71 75
76 /** Uses SkImageEncoder to serialize images that are not already
77 encoded as SkImageEncoder::kPNG_Type images. */
78 static SkPixelSerializer* CreatePixelSerializer();
79
72 protected: 80 protected:
73 /** 81 /**
74 * Encode bitmap 'bm' in the desired format, writing results to 82 * Encode bitmap 'bm' in the desired format, writing results to
75 * stream 'stream', at quality level 'quality' (which can be in 83 * stream 'stream', at quality level 'quality' (which can be in
76 * range 0-100). 84 * range 0-100).
77 * 85 *
78 * This must be overridden by each SkImageEncoder implementation. 86 * This must be overridden by each SkImageEncoder implementation.
79 */ 87 */
80 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) = 0; 88 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) = 0;
81 }; 89 };
(...skipping 21 matching lines...) Expand all
103 DECLARE_ENCODER_CREATOR(WEBPImageEncoder); 111 DECLARE_ENCODER_CREATOR(WEBPImageEncoder);
104 112
105 #ifdef SK_BUILD_FOR_IOS 113 #ifdef SK_BUILD_FOR_IOS
106 DECLARE_ENCODER_CREATOR(PNGImageEncoder_IOS); 114 DECLARE_ENCODER_CREATOR(PNGImageEncoder_IOS);
107 #endif 115 #endif
108 116
109 // Typedef to make registering encoder callback easier 117 // Typedef to make registering encoder callback easier
110 // This has to be defined outside SkImageEncoder. :( 118 // This has to be defined outside SkImageEncoder. :(
111 typedef SkTRegistry<SkImageEncoder*(*)(SkImageEncoder::Type)> SkImageEncoder_Enc odeReg; 119 typedef SkTRegistry<SkImageEncoder*(*)(SkImageEncoder::Type)> SkImageEncoder_Enc odeReg;
112 #endif 120 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPixelSerializer.h » ('j') | src/images/SkImageEncoder.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698