]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsImage.C
Rob's patch and some minor cleanup
[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         unsigned int width = getWidth();
38         unsigned int height = getHeight();
39
40         // scale only when value makes sense, i.e. not zero
41         if (params.scale) {
42                 width  = (width * params.scale) / 100;
43                 height = (height * params.scale) / 100;
44         }
45
46         lyxerr[Debug::GRAPHICS]
47                 << "GraphicsImage::getScaledDImensions()"
48                 << "\n\tparams.scale       : " << params.scale
49                 << "\n\twidth              : " << width
50                 << "\n\theight             : " << height
51                 << std::endl;
52
53         return std::make_pair(width, height);
54 }
55
56 } // namespace grfx
57