| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GFX_CODEC_PNG_CODEC_H_ | 5 #ifndef UI_GFX_CODEC_PNG_CODEC_H_ |
| 6 #define UI_GFX_CODEC_PNG_CODEC_H_ | 6 #define UI_GFX_CODEC_PNG_CODEC_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "ui/gfx/gfx_export.h" | 14 #include "ui/gfx/codec/codec_export.h" |
| 15 | 15 |
| 16 class SkBitmap; | 16 class SkBitmap; |
| 17 | 17 |
| 18 namespace gfx { | 18 namespace gfx { |
| 19 | 19 |
| 20 class Size; | 20 class Size; |
| 21 | 21 |
| 22 // Interface for encoding and decoding PNG data. This is a wrapper around | 22 // Interface for encoding and decoding PNG data. This is a wrapper around |
| 23 // libpng, which has an inconvenient interface for callers. This is currently | 23 // libpng, which has an inconvenient interface for callers. This is currently |
| 24 // designed for use in tests only (where we control the files), so the handling | 24 // designed for use in tests only (where we control the files), so the handling |
| 25 // isn't as robust as would be required for a browser (see Decode() for more). | 25 // isn't as robust as would be required for a browser (see Decode() for more). |
| 26 // WebKit has its own more complicated PNG decoder which handles, among other | 26 // WebKit has its own more complicated PNG decoder which handles, among other |
| 27 // things, partially downloaded data. | 27 // things, partially downloaded data. |
| 28 class GFX_EXPORT PNGCodec { | 28 class CODEC_EXPORT PNGCodec { |
| 29 public: | 29 public: |
| 30 enum ColorFormat { | 30 enum ColorFormat { |
| 31 // 3 bytes per pixel (packed), in RGB order regardless of endianness. | 31 // 3 bytes per pixel (packed), in RGB order regardless of endianness. |
| 32 // This is the native JPEG format. | 32 // This is the native JPEG format. |
| 33 FORMAT_RGB, | 33 FORMAT_RGB, |
| 34 | 34 |
| 35 // 4 bytes per pixel, in RGBA order in memory regardless of endianness. | 35 // 4 bytes per pixel, in RGBA order in memory regardless of endianness. |
| 36 FORMAT_RGBA, | 36 FORMAT_RGBA, |
| 37 | 37 |
| 38 // 4 bytes per pixel, in BGRA order in memory regardless of endianness. | 38 // 4 bytes per pixel, in BGRA order in memory regardless of endianness. |
| 39 // This is the default Windows DIB order. | 39 // This is the default Windows DIB order. |
| 40 FORMAT_BGRA, | 40 FORMAT_BGRA, |
| 41 | 41 |
| 42 // SkBitmap format. For Encode() kARGB_8888_Config (4 bytes per pixel) and | 42 // SkBitmap format. For Encode() kARGB_8888_Config (4 bytes per pixel) and |
| 43 // kA8_Config (1 byte per pixel) formats are supported. kA8_Config gets | 43 // kA8_Config (1 byte per pixel) formats are supported. kA8_Config gets |
| 44 // encoded into a grayscale PNG treating alpha as the color intensity. | 44 // encoded into a grayscale PNG treating alpha as the color intensity. |
| 45 // For Decode() kARGB_8888_Config is always used. | 45 // For Decode() kARGB_8888_Config is always used. |
| 46 FORMAT_SkBitmap | 46 FORMAT_SkBitmap |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // Represents a comment in the tEXt ancillary chunk of the png. | 49 // Represents a comment in the tEXt ancillary chunk of the png. |
| 50 struct GFX_EXPORT Comment { | 50 struct CODEC_EXPORT Comment { |
| 51 Comment(const std::string& k, const std::string& t); | 51 Comment(const std::string& k, const std::string& t); |
| 52 ~Comment(); | 52 ~Comment(); |
| 53 | 53 |
| 54 std::string key; | 54 std::string key; |
| 55 std::string text; | 55 std::string text; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // Encodes the given raw 'input' data, with each pixel being represented as | 58 // Encodes the given raw 'input' data, with each pixel being represented as |
| 59 // given in 'format'. The encoded PNG data will be written into the supplied | 59 // given in 'format'. The encoded PNG data will be written into the supplied |
| 60 // vector and true will be returned on success. On failure (false), the | 60 // vector and true will be returned on success. On failure (false), the |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 static bool Decode(const unsigned char* input, size_t input_size, | 127 static bool Decode(const unsigned char* input, size_t input_size, |
| 128 SkBitmap* bitmap); | 128 SkBitmap* bitmap); |
| 129 | 129 |
| 130 private: | 130 private: |
| 131 DISALLOW_COPY_AND_ASSIGN(PNGCodec); | 131 DISALLOW_COPY_AND_ASSIGN(PNGCodec); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 } // namespace gfx | 134 } // namespace gfx |
| 135 | 135 |
| 136 #endif // UI_GFX_CODEC_PNG_CODEC_H_ | 136 #endif // UI_GFX_CODEC_PNG_CODEC_H_ |
| OLD | NEW |