2 * \file GraphicsImage.C
3 * Copyright 2002 the LyX Team
4 * Read the file COPYING
6 * \author Baruch Even <baruch.even@writeme.com>
7 * \author Angus Leeming <a.leeming@ic.ac.uk>
13 #pragma implementation
16 #include "GraphicsImage.h"
17 #include "GraphicsParams.h"
21 // This is to be connected to a function that will return a new
22 // instance of a viable derived class.
23 boost::signal0<Image::ImagePtr> Image::newImage;
25 /// Return the list of loadable formats.
26 boost::signal0<Image::FormatList> Image::loadableFormats;
28 std::pair<unsigned int, unsigned int>
29 Image::getScaledDimensions(Params const & params) const
31 if (params.scale == 0 && params.width == 0 && params.height == 0)
33 return std::make_pair(getWidth(), getHeight());
35 typedef unsigned int dimension;
38 if (params.scale != 0) {
39 width = dimension(getWidth() * params.scale / 100.0);
40 height = dimension(getHeight() * params.scale / 100.0);
43 height = params.height;
46 width = height * getWidth() / getHeight();
47 } else if (height == 0) {
48 height = width * getHeight() / getWidth();
52 if (width == 0 || height == 0)
53 // Something is wrong!
54 return std::make_pair(getWidth(), getHeight());
56 return std::make_pair(width, height);