1 // -*- C++ -*-
2 /**
3  * \file GraphicsImage.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Baruch Even
8  * \author Angus Leeming
9  *
10  * Full author contact details are available in file CREDITS.
11  *
12  * An abstract base class for the images themselves.
13  * Allows the user to retrieve the pixmap, once loaded and to issue commands
14  * to modify it.
15  *
16  * The boost::functions newImage and loadableFormats are connected to the
17  * appropriate derived classes elsewhere, allowing the graphics cache to
18  * access them without knowing anything about their instantiation.
19  *
20  * The loading process can be asynchronous, but cropping, rotating and
21  * scaling block execution.
22  */
23 
24 #ifndef GRAPHICSIMAGE_H
25 #define GRAPHICSIMAGE_H
26 
27 namespace lyx {
28 
29 namespace support { class FileName; }
30 
31 namespace graphics {
32 
33 class Params;
34 
35 class Image {
36 public:
37 	///
~Image()38 	virtual ~Image() {}
39 
40 	/// Create a copy
41 	virtual Image * clone() const = 0;
42 
43 	/// Get the image width
44 	virtual unsigned int width() const = 0;
45 
46 	/// Get the image height
47 	virtual unsigned int height() const = 0;
48 
49 	/// Is the image drawable ?
50 	virtual bool isDrawable() const = 0;
51 
52 	/** Start loading the image file.
53 	 *  The caller should expect this process to be asynchronous and
54 	 *  so should connect to the "finished" signal above.
55 	 */
56 	virtual bool load(support::FileName const & filename) = 0;
57 
58 	/** Generate the pixmap.
59 	 *  Uses the params to decide on color, grayscale etc.
60 	 *  Returns true if the pixmap is created.
61 	 */
62 	virtual bool setPixmap(Params const & params) = 0;
63 };
64 
65 /// Only way to create a new Image.
66 /// Implemented in the frontend.
67 Image * newImage();
68 
69 } // namespace graphics
70 } // namespace lyx
71 
72 #endif // GRAPHICSIMAGE_H
73