OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_IMAGE_IMAGE_UTIL_H_ | 5 #ifndef UI_GFX_IMAGE_IMAGE_UTIL_H_ |
6 #define UI_GFX_IMAGE_IMAGE_UTIL_H_ | 6 #define UI_GFX_IMAGE_IMAGE_UTIL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "ui/base/ui_export.h" | 11 #include "ui/base/ui_export.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 class Image; | 14 class Image; |
15 } | 15 } |
16 | 16 |
17 namespace gfx { | 17 namespace gfx { |
18 | 18 |
19 // Creates an image from the given PNG-encoded input. The caller owns the | 19 // Creates an image from the given PNG-encoded input. The caller owns the |
20 // returned Image. If there was an error creating the image, returns NULL. | 20 // returned Image. If there was an error creating the image, returns NULL. |
21 UI_EXPORT Image* ImageFromPNGEncodedData(const unsigned char* input, | 21 UI_EXPORT Image* ImageFromPNGEncodedData(const unsigned char* input, |
22 size_t input_size); | 22 size_t input_size); |
23 | 23 |
| 24 // Fills the |dst| vector with PNG-encoded bytes based on the given Image. |
| 25 // Returns true if the Image was encoded successfully. |
| 26 UI_EXPORT bool PNGEncodedDataFromImage(const Image& image, |
| 27 std::vector<unsigned char>* dst); |
| 28 |
24 // Creates an image from the given JPEG-encoded input. The caller owns the | 29 // Creates an image from the given JPEG-encoded input. The caller owns the |
25 // returned Image. If there was an error creating the image, returns an | 30 // returned Image. If there was an error creating the image, returns an |
26 // IsEmpty() Image. | 31 // IsEmpty() Image. |
27 UI_EXPORT Image ImageFromJPEGEncodedData(const unsigned char* input, | 32 UI_EXPORT Image ImageFromJPEGEncodedData(const unsigned char* input, |
28 size_t input_size); | 33 size_t input_size); |
29 | 34 |
30 // Fills the |dst| vector with PNG-encoded bytes based on the given Image. | |
31 // Returns true if the Image was encoded successfully. | |
32 UI_EXPORT bool PNGEncodedDataFromImage(const Image& image, | |
33 std::vector<unsigned char>* dst); | |
34 | |
35 // Fills the |dst| vector with JPEG-encoded bytes based on the given Image. | 35 // Fills the |dst| vector with JPEG-encoded bytes based on the given Image. |
36 // |quality| determines the compression level, 0 == lowest, 100 == highest. | 36 // |quality| determines the compression level, 0 == lowest, 100 == highest. |
37 // Returns true if the Image was encoded successfully. | 37 // Returns true if the Image was encoded successfully. |
38 UI_EXPORT bool JPEGEncodedDataFromImage(const Image& image, | 38 UI_EXPORT bool JPEGEncodedDataFromImage(const Image& image, |
39 int quality, | 39 int quality, |
40 std::vector<unsigned char>* dst); | 40 std::vector<unsigned char>* dst); |
41 | 41 |
42 } | 42 } |
43 | 43 |
44 #endif // UI_GFX_IMAGE_IMAGE_UTIL_H_ | 44 #endif // UI_GFX_IMAGE_IMAGE_UTIL_H_ |
OLD | NEW |