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

Unified Diff: printing/image.h

Issue 149644: Print only the focused frame. This makes more sense than trying to print all... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: printing/image.h
===================================================================
--- printing/image.h (revision 20864)
+++ printing/image.h (working copy)
@@ -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 @@
// 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 @@
}
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 @@
// 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

Powered by Google App Engine
This is Rietveld 408576698