]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiImage.h
Simplify image loading on screen which is not asynchronous, never was...
[lyx.git] / src / frontends / qt4 / GuiImage.h
1 // -*- C++ -*-
2 /**
3  * \file GuiImage.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef GUIIMAGE_H
14 #define GUIIMAGE_H
15
16 #include "graphics/GraphicsImage.h"
17
18 #include <QImage>
19 #include <QPixmap>
20
21 namespace lyx {
22 namespace graphics {
23
24 class GuiImage : public Image
25 {
26 public:
27         /// Access to this class is through this static method.
28         static Image * newImage();
29
30         /// Retrieve the buffered pixmap.
31         QPixmap const & qpixmap() const { return transformed_pixmap_; }
32
33         /// Retrieve the buffered pixmap.
34         QImage const & qimage() const { return transformed_; }
35
36 private:
37         /// Create a copy
38         virtual Image * clone() const;
39         /// Get the image width
40         virtual unsigned int width() const;
41         /// Get the image height
42         virtual unsigned int height() const;
43         // FIXME Is the image drawable ?
44         virtual bool isDrawable() const { return true; }
45         /**
46          * Load the image file into memory.
47          */
48         bool load(support::FileName const & filename);
49         /**
50          * Finishes the process of modifying transformed_, using
51          * \c params to decide on color, grayscale etc.
52          * \returns true if successful.
53          */
54         virtual bool setPixmap(Params const & params);
55         /// Clip the image using params.
56         virtual void clip(Params const & params);
57         /// Rotate the image using params.
58         virtual void rotate(Params const & params);
59         /// Scale the image using params.
60         virtual void scale(Params const & params);
61
62         /// Access to the class is through newImage() and clone.
63         GuiImage() {}
64         ///
65         GuiImage(GuiImage const &);
66
67         /// The original loaded image.
68         QImage original_;
69
70         /// The transformed image for display.
71         QImage transformed_;
72         /// Buffer the pixmap itself
73         QPixmap transformed_pixmap_;
74 };
75
76 } // namespace graphics
77 } // namespace lyx
78
79 #endif // GUIIMAGE_H