summaryrefslogtreecommitdiffstats
path: root/printing/image.h
diff options
context:
space:
mode:
authorsverrir@chromium.org <sverrir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 17:23:58 +0000
committersverrir@chromium.org <sverrir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 17:23:58 +0000
commitaa82249f5670f88c545039f7ae997643c97fd639 (patch)
tree11ea4e90843eb246e77813ddac68b30bf4d907b0 /printing/image.h
parent538173f8209bd078cb82627e32b06ae522766072 (diff)
downloadchromium_src-aa82249f5670f88c545039f7ae997643c97fd639.zip
chromium_src-aa82249f5670f88c545039f7ae997643c97fd639.tar.gz
chromium_src-aa82249f5670f88c545039f7ae997643c97fd639.tar.bz2
Print only the focused frame. This makes more sense than trying to print all frames since most of the time you end up with ugly clipping and scroll bars on the printed page.
This also fixes printing issue with print selection since we don't pick up the currently selected text if's not in the main frame. Also did some refactoring of the printing test in render_view_unittest. Mainly to reuse the new Image class. BUG=http://crbug.com/15250 TEST=Print pages with frames. Print selection when using multiple frames (one example in bug). Review URL: http://codereview.chromium.org/149644 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20876 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/image.h')
-rw-r--r--printing/image.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/printing/image.h b/printing/image.h
index 8ef1007..a927549 100644
--- a/printing/image.h
+++ b/printing/image.h
@@ -11,10 +11,11 @@
#include "base/basictypes.h"
#include "base/gfx/size.h"
#include "base/logging.h"
+#include "printing/native_metafile.h"
namespace printing {
-// Lightweight raw-bitmap management. The image, once initialized, is immuable.
+// Lightweight raw-bitmap management. The image, once initialized, is immutable.
// The main purpose is testing image contents.
class Image {
public:
@@ -23,12 +24,22 @@ class Image {
// If image loading fails size().IsEmpty() will be true.
explicit Image(const std::wstring& filename);
+ // Creates the image from the metafile. Deduces bounds based on bounds in
+ // metafile. If loading fails size().IsEmpty() will be true.
+ explicit Image(const NativeMetafile& metafile);
+
+ // Copy constructor.
+ explicit Image(const Image& image);
+
const gfx::Size& size() const {
return size_;
}
+ // Return a checksum of the image (MD5 over the internal data structure).
+ std::string checksum() const;
+
// Save image as PNG.
- bool SaveToPng(const std::wstring& filename);
+ bool SaveToPng(const std::wstring& filename) const;
// Returns % of pixels different
double PercentageDifferent(const Image& rhs) const;
@@ -50,10 +61,16 @@ class Image {
}
private:
+ // Construct from metafile. This is kept internal since it's ambiguous what
+ // kind of data is used (png, bmp, metafile etc).
+ Image(const void* data, size_t size);
+
bool LoadPng(const std::string& compressed);
bool LoadMetafile(const std::string& data);
+ bool LoadMetafile(const NativeMetafile& metafile);
+
// Pixel dimensions of the image.
gfx::Size size_;
@@ -67,7 +84,8 @@ class Image {
// Flag to signal if the comparison functions should ignore the alpha channel.
const bool ignore_alpha_; // Currently always true.
- DISALLOW_EVIL_CONSTRUCTORS(Image);
+ // Prevent operator= (this function has no implementation)
+ Image& operator=(const Image& image);
};
} // namespace printing