]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsImage.C
This file is part of LyX, the document processor.
[lyx.git] / src / graphics / GraphicsImage.C
1 /**
2  * \file GraphicsImage.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Baruch Even 
7  * \author Angus Leeming 
8  * \author Herbert Voss 
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 #include <config.h>
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "GraphicsImage.h"
20 #include "GraphicsParams.h"
21 #include "debug.h"
22
23 using std::endl;
24 using std::abs;
25
26 namespace grfx {
27
28 // This is to be connected to a function that will return a new
29 // instance of a viable derived class.
30 boost::function0<Image::ImagePtr> Image::newImage;
31
32 /// Return the list of loadable formats.
33 boost::function0<Image::FormatList> Image::loadableFormats;
34
35
36 std::pair<unsigned int, unsigned int>
37 Image::getScaledDimensions(Params const & params) const
38 {
39         // scale only when value > 0
40         unsigned int width;
41         unsigned int height;
42         if (params.scale) {
43                 width  = (getWidth() * params.scale) / 100;
44                 height = (getHeight() * params.scale) / 100;
45         } else {
46                 width = getWidth();
47                 height = getHeight();
48         }
49
50         lyxerr[Debug::GRAPHICS]
51                 << "GraphicsImage::getScaledDImensions()"
52                 << "\n\tparams.scale       : " << params.scale
53                 << "\n\twidth              : " << width
54                 << "\n\theight             : " << height
55                 << std::endl;
56
57         return std::make_pair(width, height);
58 }
59
60 } // namespace grfx
61