| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 4 * | 3 * |
| 5 * 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 |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 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 "SkImageInfo.h" |
| 12 #include "SkTRegistry.h" | 12 #include "SkTRegistry.h" |
| 13 | 13 |
| 14 class SkBitmap; | 14 class SkBitmap; |
| 15 class SkData; | 15 class SkData; |
| 16 class SkWStream; | 16 class SkWStream; |
| 17 | 17 |
| 18 class SkImageEncoder { | 18 class SkImageEncoder { |
| 19 public: | 19 public: |
| 20 enum Type { | 20 enum Type { |
| 21 kUnknown_Type, | 21 kUnknown_Type, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 52 */ | 52 */ |
| 53 bool encodeFile(const char file[], const SkBitmap& bm, int quality); | 53 bool encodeFile(const char file[], const SkBitmap& bm, int quality); |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Encode bitmap 'bm' in the desired format, writing results to | 56 * Encode bitmap 'bm' in the desired format, writing results to |
| 57 * stream 'stream', at quality level 'quality' (which can be in | 57 * stream 'stream', at quality level 'quality' (which can be in |
| 58 * range 0-100). Returns false on failure. | 58 * range 0-100). Returns false on failure. |
| 59 */ | 59 */ |
| 60 bool encodeStream(SkWStream* stream, const SkBitmap& bm, int quality); | 60 bool encodeStream(SkWStream* stream, const SkBitmap& bm, int quality); |
| 61 | 61 |
| 62 static SkData* EncodeData(const SkImageInfo&, const void* pixels, size_t row
Bytes, |
| 63 Type, int quality); |
| 62 static SkData* EncodeData(const SkBitmap&, Type, int quality); | 64 static SkData* EncodeData(const SkBitmap&, Type, int quality); |
| 65 |
| 63 static bool EncodeFile(const char file[], const SkBitmap&, Type, | 66 static bool EncodeFile(const char file[], const SkBitmap&, Type, |
| 64 int quality); | 67 int quality); |
| 65 static bool EncodeStream(SkWStream*, const SkBitmap&, Type, | 68 static bool EncodeStream(SkWStream*, const SkBitmap&, Type, |
| 66 int quality); | 69 int quality); |
| 67 | 70 |
| 68 protected: | 71 protected: |
| 69 /** | 72 /** |
| 70 * Encode bitmap 'bm' in the desired format, writing results to | 73 * Encode bitmap 'bm' in the desired format, writing results to |
| 71 * stream 'stream', at quality level 'quality' (which can be in | 74 * stream 'stream', at quality level 'quality' (which can be in |
| 72 * range 0-100). | 75 * range 0-100). |
| (...skipping 28 matching lines...) Expand all Loading... |
| 101 DECLARE_ENCODER_CREATOR(WEBPImageEncoder); | 104 DECLARE_ENCODER_CREATOR(WEBPImageEncoder); |
| 102 | 105 |
| 103 #ifdef SK_BUILD_FOR_IOS | 106 #ifdef SK_BUILD_FOR_IOS |
| 104 DECLARE_ENCODER_CREATOR(PNGImageEncoder_IOS); | 107 DECLARE_ENCODER_CREATOR(PNGImageEncoder_IOS); |
| 105 #endif | 108 #endif |
| 106 | 109 |
| 107 // Typedef to make registering encoder callback easier | 110 // Typedef to make registering encoder callback easier |
| 108 // This has to be defined outside SkImageEncoder. :( | 111 // This has to be defined outside SkImageEncoder. :( |
| 109 typedef SkTRegistry<SkImageEncoder*(*)(SkImageEncoder::Type)> SkImageEncoder_Enc
odeReg; | 112 typedef SkTRegistry<SkImageEncoder*(*)(SkImageEncoder::Type)> SkImageEncoder_Enc
odeReg; |
| 110 #endif | 113 #endif |
| OLD | NEW |