| 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> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 CODEC_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. | |
| 32 // This is the native JPEG format. | |
| 33 FORMAT_RGB, | |
| 34 | |
| 35 // 4 bytes per pixel, in RGBA order in memory regardless of endianness. | 31 // 4 bytes per pixel, in RGBA order in memory regardless of endianness. |
| 36 FORMAT_RGBA, | 32 FORMAT_RGBA, |
| 37 | 33 |
| 38 // 4 bytes per pixel, in BGRA order in memory regardless of endianness. | 34 // 4 bytes per pixel, in BGRA order in memory regardless of endianness. |
| 39 // This is the default Windows DIB order. | 35 // This is the default Windows DIB order. |
| 40 FORMAT_BGRA, | 36 FORMAT_BGRA, |
| 41 | 37 |
| 42 // SkBitmap format. For Encode() kARGB_8888_Config (4 bytes per pixel) and | 38 // 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 | 39 // kA8_Config (1 byte per pixel) formats are supported. kA8_Config gets |
| 44 // encoded into a grayscale PNG treating alpha as the color intensity. | 40 // encoded into a grayscale PNG treating alpha as the color intensity. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 static bool Decode(const unsigned char* input, size_t input_size, | 121 static bool Decode(const unsigned char* input, size_t input_size, |
| 126 SkBitmap* bitmap); | 122 SkBitmap* bitmap); |
| 127 | 123 |
| 128 private: | 124 private: |
| 129 DISALLOW_COPY_AND_ASSIGN(PNGCodec); | 125 DISALLOW_COPY_AND_ASSIGN(PNGCodec); |
| 130 }; | 126 }; |
| 131 | 127 |
| 132 } // namespace gfx | 128 } // namespace gfx |
| 133 | 129 |
| 134 #endif // UI_GFX_CODEC_PNG_CODEC_H_ | 130 #endif // UI_GFX_CODEC_PNG_CODEC_H_ |
| OLD | NEW |