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