2002-09-05 11:31:30 +00:00
|
|
|
/**
|
2002-02-27 09:59:52 +00:00
|
|
|
* \file GraphicsImage.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-02-27 09:59:52 +00:00
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author Baruch Even
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author Herbert Voss
|
2002-09-05 11:31:30 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* Full author contact details are available in file CREDITS
|
2002-02-27 09:59:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GraphicsImage.h"
|
|
|
|
#include "GraphicsParams.h"
|
2002-07-21 15:51:07 +00:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
using std::endl;
|
|
|
|
using std::abs;
|
2002-05-29 12:23:43 +00:00
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace graphics {
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
// This is to be connected to a function that will return a new
|
|
|
|
// instance of a viable derived class.
|
2002-07-04 17:45:35 +00:00
|
|
|
boost::function0<Image::ImagePtr> Image::newImage;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
/// Return the list of loadable formats.
|
2002-07-04 17:45:35 +00:00
|
|
|
boost::function0<Image::FormatList> Image::loadableFormats;
|
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
std::pair<unsigned int, unsigned int>
|
2002-06-28 11:22:56 +00:00
|
|
|
Image::getScaledDimensions(Params const & params) const
|
2002-02-27 09:59:52 +00:00
|
|
|
{
|
2002-08-27 20:30:20 +00:00
|
|
|
// scale only when value > 0
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
2002-08-24 22:02:30 +00:00
|
|
|
if (params.scale) {
|
2002-08-27 20:30:20 +00:00
|
|
|
width = (getWidth() * params.scale) / 100;
|
|
|
|
height = (getHeight() * params.scale) / 100;
|
|
|
|
} else {
|
|
|
|
width = getWidth();
|
|
|
|
height = getHeight();
|
2002-08-24 22:02:30 +00:00
|
|
|
}
|
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
lyxerr[Debug::GRAPHICS]
|
|
|
|
<< "GraphicsImage::getScaledDImensions()"
|
|
|
|
<< "\n\tparams.scale : " << params.scale
|
2002-08-24 22:02:30 +00:00
|
|
|
<< "\n\twidth : " << width
|
|
|
|
<< "\n\theight : " << height
|
2002-07-21 15:51:07 +00:00
|
|
|
<< std::endl;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-08-24 22:02:30 +00:00
|
|
|
return std::make_pair(width, height);
|
2002-02-27 09:59:52 +00:00
|
|
|
}
|
2002-05-29 12:23:43 +00:00
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
} // namespace graphics
|
|
|
|
} // namespace lyx
|