Chromium Code Reviews| 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; | |
| 25 | |
| 26 // Lightweight raw-bitmap management. The image, once initialized, is immutable. | 24 // Lightweight raw-bitmap management. The image, once initialized, is immutable. |
| 27 // The main purpose is testing image contents. | 25 // The main purpose is testing image contents. |
| 28 class PRINTING_EXPORT Image { | 26 class PRINTING_EXPORT Image { |
| 29 public: | 27 public: |
| 30 // Creates the image from the metafile. Deduces bounds based on bounds in | 28 // Creates the image from the metafile. Deduces bounds based on bounds in |
| 31 // metafile. If loading fails size().IsEmpty() will be true. | 29 // metafile. If loading fails size().IsEmpty() will be true. |
| 32 explicit Image(const Metafile& metafile); | 30 Image(const void* metafile_src_buffer, size_t metafile_src_buffer_size); |
| 33 | 31 |
| 34 // Copy constructor. | 32 // Copy constructor. |
| 35 explicit Image(const Image& image); | 33 explicit Image(const Image& image); |
| 36 | 34 |
| 37 ~Image(); | 35 ~Image(); |
| 38 | 36 |
| 39 const gfx::Size& size() const { | 37 const gfx::Size& size() const { |
| 40 return size_; | 38 return size_; |
| 41 } | 39 } |
| 42 | 40 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 59 | 57 |
| 60 uint32_t pixel_at(int x, int y) const { | 58 uint32_t pixel_at(int x, int y) const { |
| 61 DCHECK(x >= 0 && x < size_.width()); | 59 DCHECK(x >= 0 && x < size_.width()); |
| 62 DCHECK(y >= 0 && y < size_.height()); | 60 DCHECK(y >= 0 && y < size_.height()); |
| 63 const uint32_t* data = reinterpret_cast<const uint32_t*>(&*data_.begin()); | 61 const uint32_t* data = reinterpret_cast<const uint32_t*>(&*data_.begin()); |
| 64 const uint32_t* data_row = data + y * row_length_ / sizeof(uint32_t); | 62 const uint32_t* data_row = data + y * row_length_ / sizeof(uint32_t); |
| 65 return Color(data_row[x]); | 63 return Color(data_row[x]); |
| 66 } | 64 } |
| 67 | 65 |
| 68 private: | 66 private: |
| 69 // Construct from metafile. This is kept internal since it's ambiguous what | |
| 70 // kind of data is used (png, bmp, metafile etc). | |
| 71 Image(const void* data, size_t size); | |
| 72 | |
| 73 bool LoadPng(const std::string& compressed); | 67 bool LoadPng(const std::string& compressed); |
|
Lei Zhang
2017/04/12 19:33:33
This is dead code, BTW.
hal.canary
2017/04/13 20:55:38
I'll clean up some of this dead code....and I just
Lei Zhang
2017/04/13 21:21:20
There's certainly a lot of cruft here.
| |
| 74 | 68 |
| 75 bool LoadMetafile(const Metafile& metafile); | 69 bool LoadMetafile(const void* metafile_src_buffer, |
| 70 size_t metafile_src_buffer_size); | |
| 76 | 71 |
| 77 // Pixel dimensions of the image. | 72 // Pixel dimensions of the image. |
| 78 gfx::Size size_; | 73 gfx::Size size_; |
| 79 | 74 |
| 80 // Length of a line in bytes. | 75 // Length of a line in bytes. |
| 81 int row_length_; | 76 int row_length_; |
| 82 | 77 |
| 83 // Actual bitmap data in arrays of RGBAs (so when loaded as uint32_t, it's | 78 // Actual bitmap data in arrays of RGBAs (so when loaded as uint32_t, it's |
| 84 // 0xABGR). | 79 // 0xABGR). |
| 85 std::vector<unsigned char> data_; | 80 std::vector<unsigned char> data_; |
| 86 | 81 |
| 87 // Flag to signal if the comparison functions should ignore the alpha channel. | 82 // Flag to signal if the comparison functions should ignore the alpha channel. |
| 88 const bool ignore_alpha_; // Currently always true. | 83 const bool ignore_alpha_; // Currently always true. |
| 89 | 84 |
| 90 // Prevent operator= (this function has no implementation) | 85 // Prevent operator= (this function has no implementation) |
| 91 Image& operator=(const Image& image); | 86 Image& operator=(const Image& image); |
| 92 }; | 87 }; |
| 93 | 88 |
| 94 } // namespace printing | 89 } // namespace printing |
| 95 | 90 |
| 96 #endif // PRINTING_IMAGE_H_ | 91 #endif // PRINTING_IMAGE_H_ |
| OLD | NEW |