Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: webkit/support/webkit_support_gfx.h

Issue 6696085: Add the ability to write comments to PNGCodec::Encode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: strdup Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/codec/png_codec_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 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 WEBKIT_SUPPORT_WEBKIT_SUPPORT_GFX_H_ 5 #ifndef WEBKIT_SUPPORT_WEBKIT_SUPPORT_GFX_H_
6 #define WEBKIT_SUPPORT_WEBKIT_SUPPORT_GFX_H_ 6 #define WEBKIT_SUPPORT_WEBKIT_SUPPORT_GFX_H_
7 7
8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "ui/gfx/codec/png_codec.h" 11 #include "ui/gfx/codec/png_codec.h"
12 #include "ui/gfx/size.h"
11 13
12 namespace webkit_support { 14 namespace webkit_support {
13 15
14 // Decode a PNG into an RGBA pixel array. 16 // Decode a PNG into an RGBA pixel array.
15 inline bool DecodePNG(const unsigned char* input, size_t input_size, 17 inline bool DecodePNG(const unsigned char* input, size_t input_size,
16 std::vector<unsigned char>* output, 18 std::vector<unsigned char>* output,
17 int* width, int* height) { 19 int* width, int* height) {
18 return gfx::PNGCodec::Decode(input, input_size, gfx::PNGCodec::FORMAT_RGBA, 20 return gfx::PNGCodec::Decode(input, input_size, gfx::PNGCodec::FORMAT_RGBA,
19 output, width, height); 21 output, width, height);
20 } 22 }
21 23
22 // Encode an RGBA pixel array into a PNG. 24 // Encode an RGBA pixel array into a PNG.
23 inline bool EncodeRGBAPNG(const unsigned char* input, int width, int height, 25 inline bool EncodeRGBAPNG(const unsigned char* input,
26 int width,
27 int height,
24 int row_byte_width, 28 int row_byte_width,
25 std::vector<unsigned char>* output) { 29 std::vector<unsigned char>* output) {
26 return gfx::PNGCodec::Encode(input, gfx::PNGCodec::FORMAT_RGBA, width, 30 return gfx::PNGCodec::Encode(input, gfx::PNGCodec::FORMAT_RGBA,
27 height, row_byte_width, false, output); 31 gfx::Size(width, height), row_byte_width, false,
darin (slow to review) 2011/07/09 06:24:45 FYI: this had the side effect of making DumpRender
32 std::vector<gfx::PNGCodec::Comment>(), output);
28 } 33 }
29 34
30 // Encode an BGRA pixel array into a PNG. 35 // Encode an BGRA pixel array into a PNG.
31 inline bool EncodeBGRAPNG(const unsigned char* input, int width, int height, 36 inline bool EncodeBGRAPNG(const unsigned char* input,
32 int row_byte_width, bool discard_transparency, 37 int width,
38 int height,
39 int row_byte_width,
40 bool discard_transparency,
33 std::vector<unsigned char>* output) { 41 std::vector<unsigned char>* output) {
34 return gfx::PNGCodec::Encode(input, gfx::PNGCodec::FORMAT_BGRA, width, 42 return gfx::PNGCodec::Encode(input, gfx::PNGCodec::FORMAT_BGRA,
35 height, row_byte_width, discard_transparency, 43 gfx::Size(width, height), row_byte_width, discard_transparency,
36 output); 44 std::vector<gfx::PNGCodec::Comment>(), output);
45 }
46
47 inline bool EncodeBGRAPNGWithChecksum(const unsigned char* input,
48 int width,
49 int height,
50 int row_byte_width,
51 bool discard_transparency,
52 const std::string& checksum,
53 std::vector<unsigned char>* output) {
54 std::vector<gfx::PNGCodec::Comment> comments;
55 comments.push_back(gfx::PNGCodec::Comment("checksum", checksum));
56 return gfx::PNGCodec::Encode(input, gfx::PNGCodec::FORMAT_BGRA,
57 gfx::Size(width, height), row_byte_width, discard_transparency,
58 comments, output);
37 } 59 }
38 60
39 } // namespace webkit_support 61 } // namespace webkit_support
40 62
41 #endif // WEBKIT_SUPPORT_WEBKIT_SUPPORT_GFX_H_ 63 #endif // WEBKIT_SUPPORT_WEBKIT_SUPPORT_GFX_H_
OLDNEW
« no previous file with comments | « ui/gfx/codec/png_codec_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698