| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "ui/ui_api.h" | 13 #include "ui/base/ui_export.h" |
| 14 | 14 |
| 15 class SkBitmap; | 15 class SkBitmap; |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 | 18 |
| 19 class Size; | 19 class Size; |
| 20 | 20 |
| 21 // Interface for encoding and decoding PNG data. This is a wrapper around | 21 // Interface for encoding and decoding PNG data. This is a wrapper around |
| 22 // libpng, which has an inconvenient interface for callers. This is currently | 22 // libpng, which has an inconvenient interface for callers. This is currently |
| 23 // designed for use in tests only (where we control the files), so the handling | 23 // designed for use in tests only (where we control the files), so the handling |
| 24 // isn't as robust as would be required for a browser (see Decode() for more). | 24 // isn't as robust as would be required for a browser (see Decode() for more). |
| 25 // WebKit has its own more complicated PNG decoder which handles, among other | 25 // WebKit has its own more complicated PNG decoder which handles, among other |
| 26 // things, partially downloaded data. | 26 // things, partially downloaded data. |
| 27 class UI_API PNGCodec { | 27 class UI_EXPORT PNGCodec { |
| 28 public: | 28 public: |
| 29 enum ColorFormat { | 29 enum ColorFormat { |
| 30 // 3 bytes per pixel (packed), in RGB order regardless of endianness. | 30 // 3 bytes per pixel (packed), in RGB order regardless of endianness. |
| 31 // This is the native JPEG format. | 31 // This is the native JPEG format. |
| 32 FORMAT_RGB, | 32 FORMAT_RGB, |
| 33 | 33 |
| 34 // 4 bytes per pixel, in RGBA order in memory regardless of endianness. | 34 // 4 bytes per pixel, in RGBA order in memory regardless of endianness. |
| 35 FORMAT_RGBA, | 35 FORMAT_RGBA, |
| 36 | 36 |
| 37 // 4 bytes per pixel, in BGRA order in memory regardless of endianness. | 37 // 4 bytes per pixel, in BGRA order in memory regardless of endianness. |
| 38 // This is the default Windows DIB order. | 38 // This is the default Windows DIB order. |
| 39 FORMAT_BGRA, | 39 FORMAT_BGRA, |
| 40 | 40 |
| 41 // 4 bytes per pixel, in pre-multiplied kARGB_8888_Config format. For use | 41 // 4 bytes per pixel, in pre-multiplied kARGB_8888_Config format. For use |
| 42 // with directly writing to a skia bitmap. | 42 // with directly writing to a skia bitmap. |
| 43 FORMAT_SkBitmap | 43 FORMAT_SkBitmap |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // Represents a comment in the tEXt ancillary chunk of the png. | 46 // Represents a comment in the tEXt ancillary chunk of the png. |
| 47 struct UI_API Comment { | 47 struct UI_EXPORT Comment { |
| 48 Comment(const std::string& k, const std::string& t); | 48 Comment(const std::string& k, const std::string& t); |
| 49 ~Comment(); | 49 ~Comment(); |
| 50 | 50 |
| 51 std::string key; | 51 std::string key; |
| 52 std::string text; | 52 std::string text; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // Calls PNGCodec::EncodeWithCompressionLevel with the default compression | 55 // Calls PNGCodec::EncodeWithCompressionLevel with the default compression |
| 56 // level. | 56 // level. |
| 57 static bool Encode(const unsigned char* input, | 57 static bool Encode(const unsigned char* input, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 static SkBitmap* CreateSkBitmapFromBGRAFormat( | 126 static SkBitmap* CreateSkBitmapFromBGRAFormat( |
| 127 std::vector<unsigned char>& bgra, int width, int height); | 127 std::vector<unsigned char>& bgra, int width, int height); |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 DISALLOW_COPY_AND_ASSIGN(PNGCodec); | 130 DISALLOW_COPY_AND_ASSIGN(PNGCodec); |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 } // namespace gfx | 133 } // namespace gfx |
| 134 | 134 |
| 135 #endif // UI_GFX_CODEC_PNG_CODEC_H_ | 135 #endif // UI_GFX_CODEC_PNG_CODEC_H_ |
| OLD | NEW |