Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "webkit/support/webkit_support_gfx.h" | |
| 6 | |
| 7 #include "ui/gfx/codec/png_codec.h" | |
| 8 #include "ui/gfx/size.h" | |
| 9 | |
| 10 namespace webkit_support { | |
| 11 | |
| 12 // Decode a PNG into an RGBA pixel array. | |
|
rvargas (doing something else)
2011/07/16 01:37:35
The comments are already on the header. (and below
| |
| 13 bool DecodePNG(const unsigned char* input, size_t input_size, | |
| 14 std::vector<unsigned char>* output, | |
| 15 int* width, int* height) { | |
| 16 return gfx::PNGCodec::Decode(input, input_size, gfx::PNGCodec::FORMAT_RGBA, | |
| 17 output, width, height); | |
| 18 } | |
| 19 | |
| 20 // Encode an RGBA pixel array into a PNG. | |
| 21 bool EncodeRGBAPNG(const unsigned char* input, | |
| 22 int width, | |
| 23 int height, | |
| 24 int row_byte_width, | |
| 25 std::vector<unsigned char>* output) { | |
| 26 return gfx::PNGCodec::Encode(input, gfx::PNGCodec::FORMAT_RGBA, | |
| 27 gfx::Size(width, height), row_byte_width, false, | |
| 28 std::vector<gfx::PNGCodec::Comment>(), output); | |
| 29 } | |
| 30 | |
| 31 // Encode an BGRA pixel array into a PNG. | |
| 32 bool EncodeBGRAPNG(const unsigned char* input, | |
| 33 int width, | |
| 34 int height, | |
| 35 int row_byte_width, | |
| 36 bool discard_transparency, | |
| 37 std::vector<unsigned char>* output) { | |
| 38 return gfx::PNGCodec::Encode(input, gfx::PNGCodec::FORMAT_BGRA, | |
| 39 gfx::Size(width, height), row_byte_width, discard_transparency, | |
| 40 std::vector<gfx::PNGCodec::Comment>(), output); | |
| 41 } | |
| 42 | |
| 43 bool EncodeBGRAPNGWithChecksum(const unsigned char* input, | |
| 44 int width, | |
| 45 int height, | |
| 46 int row_byte_width, | |
| 47 bool discard_transparency, | |
| 48 const std::string& checksum, | |
| 49 std::vector<unsigned char>* output) { | |
| 50 std::vector<gfx::PNGCodec::Comment> comments; | |
| 51 comments.push_back(gfx::PNGCodec::Comment("checksum", checksum)); | |
| 52 return gfx::PNGCodec::Encode(input, gfx::PNGCodec::FORMAT_BGRA, | |
| 53 gfx::Size(width, height), row_byte_width, discard_transparency, | |
| 54 comments, output); | |
| 55 } | |
| 56 | |
| 57 } // namespace webkit_support | |
| OLD | NEW |