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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 ColorFormat format, | 76 ColorFormat format, |
77 const Size& size, | 77 const Size& size, |
78 int row_byte_width, | 78 int row_byte_width, |
79 bool discard_transparency, | 79 bool discard_transparency, |
80 const std::vector<Comment>& comments, | 80 const std::vector<Comment>& comments, |
81 std::vector<unsigned char>* output); | 81 std::vector<unsigned char>* output); |
82 | 82 |
83 // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed | 83 // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed |
84 // to be kARGB_8888_Config, 32 bits per pixel. The params | 84 // to be kARGB_8888_Config, 32 bits per pixel. The params |
85 // |discard_transparency| and |output| are passed directly to Encode; refer to | 85 // |discard_transparency| and |output| are passed directly to Encode; refer to |
86 // Encode for more information. During the call, an SkAutoLockPixels lock | 86 // Encode for more information. |
87 // is held on |input|. | |
88 static bool EncodeBGRASkBitmap(const SkBitmap& input, | 87 static bool EncodeBGRASkBitmap(const SkBitmap& input, |
89 bool discard_transparency, | 88 bool discard_transparency, |
90 std::vector<unsigned char>* output); | 89 std::vector<unsigned char>* output); |
91 | 90 |
92 // Call PNGCodec::Encode on the supplied SkBitmap |input|. The difference | 91 // Call PNGCodec::Encode on the supplied SkBitmap |input|. The difference |
93 // between this and the previous method is that this restricts compression to | 92 // between this and the previous method is that this restricts compression to |
94 // zlib q1, which is just rle encoding. | 93 // zlib q1, which is just rle encoding. |
95 static bool FastEncodeBGRASkBitmap(const SkBitmap& input, | 94 static bool FastEncodeBGRASkBitmap(const SkBitmap& input, |
96 bool discard_transparency, | 95 bool discard_transparency, |
97 std::vector<unsigned char>* output); | 96 std::vector<unsigned char>* output); |
98 | 97 |
99 // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed | 98 // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed |
100 // to be kA8_Config, 8 bits per pixel. The bitmap is encoded as a grayscale | 99 // to be kA8_Config, 8 bits per pixel. The bitmap is encoded as a grayscale |
101 // PNG with alpha used for color intensity. The |output| param is passed | 100 // PNG with alpha used for color intensity. The |output| param is passed |
102 // directly to Encode; refer to Encode for more information. During the call, | 101 // directly to Encode; refer to Encode for more information. |
103 // an SkAutoLockPixels lock is held on |input|. | |
104 static bool EncodeA8SkBitmap(const SkBitmap& input, | 102 static bool EncodeA8SkBitmap(const SkBitmap& input, |
105 std::vector<unsigned char>* output); | 103 std::vector<unsigned char>* output); |
106 | 104 |
107 // Decodes the PNG data contained in input of length input_size. The | 105 // Decodes the PNG data contained in input of length input_size. The |
108 // decoded data will be placed in *output with the dimensions in *w and *h | 106 // decoded data will be placed in *output with the dimensions in *w and *h |
109 // on success (returns true). This data will be written in the 'format' | 107 // on success (returns true). This data will be written in the 'format' |
110 // format. On failure, the values of these output variables are undefined. | 108 // format. On failure, the values of these output variables are undefined. |
111 // | 109 // |
112 // This function may not support all PNG types, and it hasn't been tested | 110 // This function may not support all PNG types, and it hasn't been tested |
113 // with a large number of images, so assume a new format may not work. It's | 111 // with a large number of images, so assume a new format may not work. It's |
(...skipping 13 matching lines...) Expand all Loading... |
127 static bool Decode(const unsigned char* input, size_t input_size, | 125 static bool Decode(const unsigned char* input, size_t input_size, |
128 SkBitmap* bitmap); | 126 SkBitmap* bitmap); |
129 | 127 |
130 private: | 128 private: |
131 DISALLOW_COPY_AND_ASSIGN(PNGCodec); | 129 DISALLOW_COPY_AND_ASSIGN(PNGCodec); |
132 }; | 130 }; |
133 | 131 |
134 } // namespace gfx | 132 } // namespace gfx |
135 | 133 |
136 #endif // UI_GFX_CODEC_PNG_CODEC_H_ | 134 #endif // UI_GFX_CODEC_PNG_CODEC_H_ |
OLD | NEW |