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

Side by Side Diff: ui/gfx/codec/png_codec.h

Issue 136453009: Fix for Issue 331895: Make gesturenav screenshot greyscale (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing memory leak Created 6 years, 10 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
OLDNEW
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 19 matching lines...) Expand all
30 // This is the native JPEG format. 30 // This is the native JPEG format.
31 FORMAT_RGB, 31 FORMAT_RGB,
32 32
33 // 4 bytes per pixel, in RGBA order in memory regardless of endianness. 33 // 4 bytes per pixel, in RGBA order in memory regardless of endianness.
34 FORMAT_RGBA, 34 FORMAT_RGBA,
35 35
36 // 4 bytes per pixel, in BGRA order in memory regardless of endianness. 36 // 4 bytes per pixel, in BGRA order in memory regardless of endianness.
37 // This is the default Windows DIB order. 37 // This is the default Windows DIB order.
38 FORMAT_BGRA, 38 FORMAT_BGRA,
39 39
40 // 4 bytes per pixel, in pre-multiplied kARGB_8888_Config format. For use 40 // SkBitmap format. For Encode() kARGB_8888_Config (4 bytes per pixel) and
41 // with directly writing to a skia bitmap. 41 // kA8_Config (1 byte per pixel) formats are supported. kA8_Config gets
42 // encoded into a grayscale PNG treating alpha as the color intensity.
43 // For Decode() kARGB_8888_Config is always used.
42 FORMAT_SkBitmap 44 FORMAT_SkBitmap
43 }; 45 };
44 46
45 // Represents a comment in the tEXt ancillary chunk of the png. 47 // Represents a comment in the tEXt ancillary chunk of the png.
46 struct GFX_EXPORT Comment { 48 struct GFX_EXPORT Comment {
47 Comment(const std::string& k, const std::string& t); 49 Comment(const std::string& k, const std::string& t);
48 ~Comment(); 50 ~Comment();
49 51
50 std::string key; 52 std::string key;
51 std::string text; 53 std::string text;
(...skipping 18 matching lines...) Expand all
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);
78 80
79 // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed 81 // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed
80 // to be BGRA, 32 bits per pixel. The params |discard_transparency| and 82 // to be kARGB_8888_Config, 32 bits per pixel. The params
81 // |output| are passed directly to Encode; refer to Encode for more 83 // |discard_transparency| and |output| are passed directly to Encode; refer to
82 // information. During the call, an SkAutoLockPixels lock is held on |input|. 84 // Encode for more information. During the call, an SkAutoLockPixels lock
85 // is held on |input|.
83 static bool EncodeBGRASkBitmap(const SkBitmap& input, 86 static bool EncodeBGRASkBitmap(const SkBitmap& input,
84 bool discard_transparency, 87 bool discard_transparency,
85 std::vector<unsigned char>* output); 88 std::vector<unsigned char>* output);
86 89
87 // Call PNGCodec::Encode on the supplied SkBitmap |input|. The difference 90 // Call PNGCodec::Encode on the supplied SkBitmap |input|. The difference
88 // between this and the previous method is that this restricts compression to 91 // between this and the previous method is that this restricts compression to
89 // zlib q1, which is just rle encoding. 92 // zlib q1, which is just rle encoding.
90 static bool FastEncodeBGRASkBitmap(const SkBitmap& input, 93 static bool FastEncodeBGRASkBitmap(const SkBitmap& input,
91 bool discard_transparency, 94 bool discard_transparency,
92 std::vector<unsigned char>* output); 95 std::vector<unsigned char>* output);
93 96
97 // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed
98 // to be kA8_Config, 8 bits per pixel. The bitmap is encoded as a grayscale
99 // PNG with alpha used for color intensity. The |output| param is passed
100 // directly to Encode; refer to Encode for more information. During the call,
101 // an SkAutoLockPixels lock is held on |input|.
102 static bool EncodeA8SkBitmap(const SkBitmap& input,
103 std::vector<unsigned char>* output);
104
94 // 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
95 // 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
96 // 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'
97 // format. On failure, the values of these output variables are undefined. 108 // format. On failure, the values of these output variables are undefined.
98 // 109 //
99 // 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
100 // 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
101 // really designed to be able to read in something written by Encode() above. 112 // 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, 113 static bool Decode(const unsigned char* input, size_t input_size,
103 ColorFormat format, std::vector<unsigned char>* output, 114 ColorFormat format, std::vector<unsigned char>* output,
(...skipping 10 matching lines...) Expand all
114 static bool Decode(const unsigned char* input, size_t input_size, 125 static bool Decode(const unsigned char* input, size_t input_size,
115 SkBitmap* bitmap); 126 SkBitmap* bitmap);
116 127
117 private: 128 private:
118 DISALLOW_COPY_AND_ASSIGN(PNGCodec); 129 DISALLOW_COPY_AND_ASSIGN(PNGCodec);
119 }; 130 };
120 131
121 } // namespace gfx 132 } // namespace gfx
122 133
123 #endif // UI_GFX_CODEC_PNG_CODEC_H_ 134 #endif // UI_GFX_CODEC_PNG_CODEC_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_entry_screenshot_manager.cc ('k') | ui/gfx/codec/png_codec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698