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