I think should not be in double value is Magick++ Image.density()?
Swiss army knife of image processing
Brought to you by:
bfriesen
Hi,
Image.density()'s return value is int on pgmagick.
see https://bitbucket.org/hhatto/pgmagick/issues/53/
The following code(x_resolution,y_resolution) I think there is no problem ?
$ hg diff
diff -r 4e0a7a93d9a4 Magick++/lib/Image.cpp
--- a/Magick++/lib/Image.cpp Sat Nov 07 14:48:53 2015 -0600
+++ b/Magick++/lib/Image.cpp Mon Nov 09 13:49:47 2015 +0000
@@ -2724,8 +2724,8 @@
{
if (isValid())
{
- unsigned int x_resolution=72;
- unsigned int y_resolution=72;
+ double x_resolution=72;
+ double y_resolution=72;
if (constImage()->x_resolution > 0.0)
x_resolution=static_cast<unsigned int>(constImage()->x_resolution + 0.5);
sorry, my broken english.
The Geometry class (and the density() methods which depend on it) is fundamentally broken when it comes to floating point since it does not support floating point.
These functions do part of what is required:
However, I see that there are no xResolution() and yResolution() methods which accept a double and set the resolution. This seems like the actual fixable bug.
Mercurial changeset 14723:43a59a8ef281 adds Magick++ Image methods xResolution() and yResolution() so that the image resolution can be set to full precision.
Thanks
I am not sure if the API additions are enough. There are two ways that image resolution is used. The resolution is a property of the image which was already read. The density() method also covers the case where the resolution was specified before the file was read. This has influence for rendered formats like EPS, PDF, SVG, and WMF. I am thinking that additional parameterized density() methods are needed to allow the rendering resolution to be set before the input file is read.
Re-opening to add parameterized density() methods which are not based on Geometry so that the rendering resolution can be specified before a file is read.