Error while retrieving image's width / height

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Clem

Error while retrieving image's width / height

Post by Clem »

Hello,

I only need imagemagick to load/save image files.

The annoying code snippet is simple :

Code: Select all

Magick::Image tmpImage;
try
{
    tmpImage.read (path);
    unsigned int width = tmpImage.columns();
    ...
Everything compiles well, but at the execution i've got this message :

Unhandled exception at 0x7c342eee in xxx.exe: 0xC0000005: Access violation reading location 0xcccccccc.

Then i have tried in an other way :

Code: Select all

Magick::Image tmpImage;
try
{
    tmpImage.read (path);
    Magick::Geometry tmpImageGeometry = tmpImage.size();
    unsigned int width = tmpImageGeometry.width();
    ...
But that doesn't change anything, the error message is still popped...

The geometry seems not to be well set at image loading, the behavior is like dealing with an uninitialized pointer.

Any idea please, i've spent all the day on this !
(I have also tried to use magick++ through the "cool image" library : the problem is still present but apprears a little bit before : during construction "Magick::Image image(filename);" at line 26812 in CImg.h)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Error while retrieving image's width / height

Post by magick »

Have you tried the demo workspaces provided with the ImageMagick binary distribution? Go to c:\Program Files\ImageMagick-6.4.2-Q16\Magick++_Demos and select the button workspace. Build the workspace and start it. Does it run to completion without complaint? If so, substitute your code snippet in the button workspace and build and run. Sometimes we get reports about errors like the one you posted that is simply due to not setting up the compile parameters properly.
Clem

Re: Error while retrieving image's width / height

Post by Clem »

Hi, thank you for your attention.

The "button" project compiles with warning (since i use the dll version of magick++ and it uses stl classes (such as "std::_Container_base_aux") as base class, which haven't got dll interface). But the demo runs properly.

So i have copied the settings in my own project, it compiles but doesn't work ! The program now crashes at "tmpImage.read (path);" with the same error message.

- Are there any known issues by using magick in a dll (my project is a dll, not an executable) ?
- Perhaps i must use the static version of the magick library but that's annoying since i project to reuse it in the next dll i have to develop for my soft.

i'm lost...
rawsonl

Re: Error while retrieving image's width / height

Post by rawsonl »

Did you ever figure this out?
Post Reply