Page 1 of 1

Readimage low resolution C++

Posted: 2013-05-17T01:21:38-07:00
by Jessica Wu
I use the imagemagick++ API in my C++ programm. Readimage is used to read a multi-pages PDF file. But the resolution of the output image is too low.

vector<Image> imageList;
readImages( &imageList, "E:/ww.pdf" );
for(int i = 0; i < imageList.size(); i++)
{imageList.density("300");}
writeImages( imageList.begin(), imageList.end(), "D:/yes.tif" );

Is there some solutions to improve the resolution.

Re: Readimage low resolution C++

Posted: 2013-05-17T15:56:49-07:00
by dlemstra
You need to assign the density before reading the image. You cannot do that with readImages right now. But if you inline the content of readImages it can be done:

Code: Select all

// Not tested:
MagickCore::ImageInfo *imageInfo = MagickCore::CloneImageInfo(0);

std::string imageSpec =  "E:/ww.pdf";
imageSpec.copy(imageInfo->filename, MaxTextExtent-1);
imageInfo->filename[imageSpec.length()] = 0;
MagickCore::CloneString(&imageInfo->density, "300");

MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo(&exceptionInfo);
MagickCore::Image* images = MagickCore::ReadImage(imageInfo, &exceptionInfo);
MagickCore::DestroyImageInfo(imageInfo);
Magick::insertImages(imageList, images);
Magick::throwException(exceptionInfo);
MagickCore::DestroyExceptionInfo(&exceptionInfo);