Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: printing/image.h

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/emf_win.h ('k') | printing/metafile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <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/printing_export.h" 13 #include "printing/printing_export.h"
14 #include "ui/gfx/size.h" 14 #include "ui/gfx/size.h"
15 15
16 namespace base {
16 class FilePath; 17 class FilePath;
18 }
17 19
18 namespace printing { 20 namespace printing {
19 21
20 class Metafile; 22 class Metafile;
21 23
22 // Lightweight raw-bitmap management. The image, once initialized, is immutable. 24 // Lightweight raw-bitmap management. The image, once initialized, is immutable.
23 // The main purpose is testing image contents. 25 // The main purpose is testing image contents.
24 class PRINTING_EXPORT Image { 26 class PRINTING_EXPORT Image {
25 public: 27 public:
26 // Creates the image from the given file on disk. Uses extension to 28 // Creates the image from the given file on disk. Uses extension to
27 // defer file type. PNG and EMF (on Windows) currently supported. 29 // defer file type. PNG and EMF (on Windows) currently supported.
28 // If image loading fails size().IsEmpty() will be true. 30 // If image loading fails size().IsEmpty() will be true.
29 explicit Image(const FilePath& path); 31 explicit Image(const base::FilePath& path);
30 32
31 // Creates the image from the metafile. Deduces bounds based on bounds in 33 // Creates the image from the metafile. Deduces bounds based on bounds in
32 // metafile. If loading fails size().IsEmpty() will be true. 34 // metafile. If loading fails size().IsEmpty() will be true.
33 explicit Image(const Metafile& metafile); 35 explicit Image(const Metafile& metafile);
34 36
35 // Copy constructor. 37 // Copy constructor.
36 explicit Image(const Image& image); 38 explicit Image(const Image& image);
37 39
38 ~Image(); 40 ~Image();
39 41
40 const gfx::Size& size() const { 42 const gfx::Size& size() const {
41 return size_; 43 return size_;
42 } 44 }
43 45
44 // Return a checksum of the image (MD5 over the internal data structure). 46 // Return a checksum of the image (MD5 over the internal data structure).
45 std::string checksum() const; 47 std::string checksum() const;
46 48
47 // Save image as PNG. 49 // Save image as PNG.
48 bool SaveToPng(const FilePath& filepath) const; 50 bool SaveToPng(const base::FilePath& filepath) const;
49 51
50 // Returns % of pixels different 52 // Returns % of pixels different
51 double PercentageDifferent(const Image& rhs) const; 53 double PercentageDifferent(const Image& rhs) const;
52 54
53 // Returns the 0x0RGB or 0xARGB value of the pixel at the given location. 55 // Returns the 0x0RGB or 0xARGB value of the pixel at the given location.
54 uint32 Color(uint32 color) const { 56 uint32 Color(uint32 color) const {
55 if (ignore_alpha_) 57 if (ignore_alpha_)
56 return color & 0xFFFFFF; // Strip out A. 58 return color & 0xFFFFFF; // Strip out A.
57 else 59 else
58 return color; 60 return color;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Flag to signal if the comparison functions should ignore the alpha channel. 92 // Flag to signal if the comparison functions should ignore the alpha channel.
91 const bool ignore_alpha_; // Currently always true. 93 const bool ignore_alpha_; // Currently always true.
92 94
93 // Prevent operator= (this function has no implementation) 95 // Prevent operator= (this function has no implementation)
94 Image& operator=(const Image& image); 96 Image& operator=(const Image& image);
95 }; 97 };
96 98
97 } // namespace printing 99 } // namespace printing
98 100
99 #endif // PRINTING_IMAGE_H_ 101 #endif // PRINTING_IMAGE_H_
OLDNEW
« no previous file with comments | « printing/emf_win.h ('k') | printing/metafile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698