OLD | NEW |
---|---|
1 // Copyright (c) 2009 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 PRINTING_IMAGE_H_ | 5 #ifndef PRINTING_IMAGE_H_ |
6 #define PRINTING_IMAGE_H_ | 6 #define PRINTING_IMAGE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "printing/native_metafile.h" | 13 #include "printing/metafile.h" |
Lei Zhang
2011/04/11 02:51:10
forward declare instead?
vandebo (ex-Chrome)
2011/04/11 06:16:08
Done.
| |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
15 | 15 |
16 class FilePath; | 16 class FilePath; |
17 | 17 |
18 namespace printing { | 18 namespace printing { |
19 | 19 |
20 // Lightweight raw-bitmap management. The image, once initialized, is immutable. | 20 // Lightweight raw-bitmap management. The image, once initialized, is immutable. |
21 // The main purpose is testing image contents. | 21 // The main purpose is testing image contents. |
22 class Image { | 22 class Image { |
23 public: | 23 public: |
24 // Creates the image from the given file on disk. Uses extension to | 24 // Creates the image from the given file on disk. Uses extension to |
25 // defer file type. PNG and EMF (on Windows) currently supported. | 25 // defer file type. PNG and EMF (on Windows) currently supported. |
26 // If image loading fails size().IsEmpty() will be true. | 26 // If image loading fails size().IsEmpty() will be true. |
27 explicit Image(const FilePath& path); | 27 explicit Image(const FilePath& path); |
28 | 28 |
29 // Creates the image from the metafile. Deduces bounds based on bounds in | 29 // Creates the image from the metafile. Deduces bounds based on bounds in |
30 // metafile. If loading fails size().IsEmpty() will be true. | 30 // metafile. If loading fails size().IsEmpty() will be true. |
31 explicit Image(const NativeMetafile& metafile); | 31 explicit Image(const Metafile& metafile); |
32 | 32 |
33 // Copy constructor. | 33 // Copy constructor. |
34 explicit Image(const Image& image); | 34 explicit Image(const Image& image); |
35 | 35 |
36 ~Image(); | 36 ~Image(); |
37 | 37 |
38 const gfx::Size& size() const { | 38 const gfx::Size& size() const { |
39 return size_; | 39 return size_; |
40 } | 40 } |
41 | 41 |
(...skipping 24 matching lines...) Expand all Loading... | |
66 | 66 |
67 private: | 67 private: |
68 // Construct from metafile. This is kept internal since it's ambiguous what | 68 // Construct from metafile. This is kept internal since it's ambiguous what |
69 // kind of data is used (png, bmp, metafile etc). | 69 // kind of data is used (png, bmp, metafile etc). |
70 Image(const void* data, size_t size); | 70 Image(const void* data, size_t size); |
71 | 71 |
72 bool LoadPng(const std::string& compressed); | 72 bool LoadPng(const std::string& compressed); |
73 | 73 |
74 bool LoadMetafile(const std::string& data); | 74 bool LoadMetafile(const std::string& data); |
75 | 75 |
76 bool LoadMetafile(const NativeMetafile& metafile); | 76 bool LoadMetafile(const Metafile& metafile); |
77 | 77 |
78 // Pixel dimensions of the image. | 78 // Pixel dimensions of the image. |
79 gfx::Size size_; | 79 gfx::Size size_; |
80 | 80 |
81 // Length of a line in bytes. | 81 // Length of a line in bytes. |
82 int row_length_; | 82 int row_length_; |
83 | 83 |
84 // Actual bitmap data in arrays of RGBAs (so when loaded as uint32, it's | 84 // Actual bitmap data in arrays of RGBAs (so when loaded as uint32, it's |
85 // 0xABGR). | 85 // 0xABGR). |
86 std::vector<unsigned char> data_; | 86 std::vector<unsigned char> data_; |
87 | 87 |
88 // Flag to signal if the comparison functions should ignore the alpha channel. | 88 // Flag to signal if the comparison functions should ignore the alpha channel. |
89 const bool ignore_alpha_; // Currently always true. | 89 const bool ignore_alpha_; // Currently always true. |
90 | 90 |
91 // Prevent operator= (this function has no implementation) | 91 // Prevent operator= (this function has no implementation) |
92 Image& operator=(const Image& image); | 92 Image& operator=(const Image& image); |
93 }; | 93 }; |
94 | 94 |
95 } // namespace printing | 95 } // namespace printing |
96 | 96 |
97 #endif // PRINTING_IMAGE_H_ | 97 #endif // PRINTING_IMAGE_H_ |
OLD | NEW |