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