]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsImage.cpp
rename/merge LyXLength related stuff
[lyx.git] / src / graphics / GraphicsImage.cpp
1 /**
2  * \file GraphicsImage.cpp
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 Voß
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "GraphicsImage.h"
16 #include "GraphicsParams.h"
17 #include "debug.h"
18
19
20 namespace lyx {
21 namespace graphics {
22
23 // This is to be connected to a function that will return a new
24 // instance of a viable derived class.
25 boost::function<Image::ImagePtr()> Image::newImage;
26
27 /// Return the list of loadable formats.
28 boost::function<Image::FormatList()> Image::loadableFormats;
29
30
31 std::pair<unsigned int, unsigned int>
32 Image::getScaledDimensions(Params const & params) const
33 {
34         // scale only when value > 0
35         unsigned int width;
36         unsigned int height;
37         if (params.scale) {
38                 width  = (getWidth() * params.scale) / 100;
39                 height = (getHeight() * params.scale) / 100;
40         } else {
41                 width = getWidth();
42                 height = getHeight();
43         }
44
45         LYXERR(Debug::GRAPHICS)
46                 << "graphics::Image::getScaledDimensions()"
47                 << "\n\tparams.scale       : " << params.scale
48                 << "\n\twidth              : " << width
49                 << "\n\theight             : " << height
50                 << std::endl;
51
52         return std::make_pair(width, height);
53 }
54
55 } // namespace graphics
56 } // namespace lyx