Chromium Code Reviews| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 // multiplied. | 60 // multiplied. |
| 61 // | 61 // |
| 62 // size: dimensions of the image | 62 // size: dimensions of the image |
| 63 // row_byte_width: the width in bytes of each row. This may be greater than | 63 // row_byte_width: the width in bytes of each row. This may be greater than |
| 64 // w * bytes_per_pixel if there is extra padding at the end of each row | 64 // w * bytes_per_pixel if there is extra padding at the end of each row |
| 65 // (often, each row is padded to the next machine word). | 65 // (often, each row is padded to the next machine word). |
| 66 // discard_transparency: when true, and when the input data format includes | 66 // discard_transparency: when true, and when the input data format includes |
| 67 // alpha values, these alpha values will be discarded and only RGB will be | 67 // alpha values, these alpha values will be discarded and only RGB will be |
| 68 // written to the resulting file. Otherwise, alpha values in the input | 68 // written to the resulting file. Otherwise, alpha values in the input |
| 69 // will be preserved. | 69 // will be preserved. |
| 70 // discard_color: when true, color images will be converted to grayscale | |
| 71 // (can be used in combination with discard_transparency) | |
| 70 // comments: comments to be written in the png's metadata. | 72 // comments: comments to be written in the png's metadata. |
| 71 static bool Encode(const unsigned char* input, | 73 static bool Encode(const unsigned char* input, |
| 72 ColorFormat format, | 74 ColorFormat format, |
| 73 const Size& size, | 75 const Size& size, |
| 74 int row_byte_width, | 76 int row_byte_width, |
| 75 bool discard_transparency, | 77 bool discard_transparency, |
| 76 const std::vector<Comment>& comments, | 78 const std::vector<Comment>& comments, |
| 77 std::vector<unsigned char>* output); | 79 std::vector<unsigned char>* output, |
| 80 bool discard_color = false); | |
|
sadrul
2014/01/15 21:43:06
default parameter values are not allowed in chromi
| |
| 78 | 81 |
| 79 // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed | 82 // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed |
| 80 // to be BGRA, 32 bits per pixel. The params |discard_transparency| and | 83 // to be BGRA, 32 bits per pixel. The params |discard_transparency|, |
| 81 // |output| are passed directly to Encode; refer to Encode for more | 84 // |discard_color|, and |output| are passed directly to Encode; refer to |
| 82 // information. During the call, an SkAutoLockPixels lock is held on |input|. | 85 // Encode for more information. During the call, an SkAutoLockPixels lock |
| 86 // is held on |input|. | |
| 83 static bool EncodeBGRASkBitmap(const SkBitmap& input, | 87 static bool EncodeBGRASkBitmap(const SkBitmap& input, |
| 84 bool discard_transparency, | 88 bool discard_transparency, |
| 85 std::vector<unsigned char>* output); | 89 std::vector<unsigned char>* output, |
| 90 bool discard_color = false); | |
| 86 | 91 |
| 87 // Call PNGCodec::Encode on the supplied SkBitmap |input|. The difference | 92 // Call PNGCodec::Encode on the supplied SkBitmap |input|. The difference |
| 88 // between this and the previous method is that this restricts compression to | 93 // between this and the previous method is that this restricts compression to |
| 89 // zlib q1, which is just rle encoding. | 94 // zlib q1, which is just rle encoding. |
| 90 static bool FastEncodeBGRASkBitmap(const SkBitmap& input, | 95 static bool FastEncodeBGRASkBitmap(const SkBitmap& input, |
| 91 bool discard_transparency, | 96 bool discard_transparency, |
| 92 std::vector<unsigned char>* output); | 97 std::vector<unsigned char>* output, |
| 98 bool discard_color = false); | |
| 93 | 99 |
| 94 // Decodes the PNG data contained in input of length input_size. The | 100 // Decodes the PNG data contained in input of length input_size. The |
| 95 // decoded data will be placed in *output with the dimensions in *w and *h | 101 // decoded data will be placed in *output with the dimensions in *w and *h |
| 96 // on success (returns true). This data will be written in the 'format' | 102 // on success (returns true). This data will be written in the 'format' |
| 97 // format. On failure, the values of these output variables are undefined. | 103 // format. On failure, the values of these output variables are undefined. |
| 98 // | 104 // |
| 99 // This function may not support all PNG types, and it hasn't been tested | 105 // This function may not support all PNG types, and it hasn't been tested |
| 100 // with a large number of images, so assume a new format may not work. It's | 106 // with a large number of images, so assume a new format may not work. It's |
| 101 // really designed to be able to read in something written by Encode() above. | 107 // really designed to be able to read in something written by Encode() above. |
| 102 static bool Decode(const unsigned char* input, size_t input_size, | 108 static bool Decode(const unsigned char* input, size_t input_size, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 114 static bool Decode(const unsigned char* input, size_t input_size, | 120 static bool Decode(const unsigned char* input, size_t input_size, |
| 115 SkBitmap* bitmap); | 121 SkBitmap* bitmap); |
| 116 | 122 |
| 117 private: | 123 private: |
| 118 DISALLOW_COPY_AND_ASSIGN(PNGCodec); | 124 DISALLOW_COPY_AND_ASSIGN(PNGCodec); |
| 119 }; | 125 }; |
| 120 | 126 |
| 121 } // namespace gfx | 127 } // namespace gfx |
| 122 | 128 |
| 123 #endif // UI_GFX_CODEC_PNG_CODEC_H_ | 129 #endif // UI_GFX_CODEC_PNG_CODEC_H_ |
| OLD | NEW |