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
|
2003-09-07 01:45:40 +00:00
|
|
|
|
* \author Herbert Vo<EFBFBD>
|
2002-09-05 11:31:30 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +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"
|
|
|
|
|
|
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.
|
2004-09-26 13:34:57 +00:00
|
|
|
|
boost::function<Image::ImagePtr()> Image::newImage;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
|
|
/// Return the list of loadable formats.
|
2004-09-26 13:34:57 +00:00
|
|
|
|
boost::function<Image::FormatList()> Image::loadableFormats;
|
2002-07-04 17:45:35 +00:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::GRAPHICS)
|
2007-02-26 22:27:37 +00:00
|
|
|
|
<< "graphics::Image::getScaledDimensions()"
|
2002-07-21 15:51:07 +00:00
|
|
|
|
<< "\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
|