Page 1 of 1

Issue with CRT/std::string

Posted: 2008-10-07T16:14:00-07:00
by dsharlet
Any time I try to load an image from a file, i.e.:

Magick::Image("C:\\Test.bmp")

It crashes in std::string related functions. I think the problem is that it looks like the library was compiled with MSVCRT 7.1, while I am using 8.

I need a workaround for this problem. I don't see a plain old char pointer member, so it looks like my next best option is to load the file into a Blob myself (so I can open the file with my version of the CRT), and then pass the blob to the Magick::Image constructor instead of the filename.

My question is that I need this to be relatively fast (I am dealing with image sequences of movies), is this going to be significantly slower than the method of passing the string and having the library do the work? Will I be sacrificing functionality by doing this? I need some of the more exotic image types to work (exr, dpx) so I need all the formats to support working with blobs.

A cursory look at the source of Image.cpp did not reveal whether there would be a difference between the two.

edit: I went ahead and implemented this workaround, and it works. This tells me that it most likely is the source of the crash. So all I need to know is that I'm not losing functionality or performance by doing this.

Re: Issue with CRT/std::string

Posted: 2008-10-07T16:41:47-07:00
by magick
Try building the button project in ImageMagick-6.4.4-Q16\Magick_demos. Now modify it slightly to call Magick::Image("C:\\Test.bmp"). Does that work? Its possible that certain project options need to be set for Magick++ to work properly.

Re: Issue with CRT/std::string

Posted: 2008-10-07T16:47:07-07:00
by dsharlet
That test crashes (I tried it earlier).

My project is huge, and most of the compiler options are set the way they are so the rest of my project (and other libraries) work.

Regardless, I don't think the compiler options would fix the problem. The issue is deeper than that - that the declaration (memory layout) of std::string changed between MSVCRT 7.1 and MSVCRT 8.

Re: Issue with CRT/std::string

Posted: 2008-10-07T16:50:45-07:00
by magick
The obvious solution would be to compile the ImageMagick distribution with Visual 8. Just grab the ImageMagick Windows source distribution and run the configure program to generate a workspace.

Re: Issue with CRT/std::string

Posted: 2008-10-07T19:38:12-07:00
by dsharlet
But ImageMagick is client installed software.

I am OK with the solution I have (read/write blobs from/to files manually, then pass that to Image), as long as I am not losing the support of image file formats (if ImageMagick is using other libraries to support formats that don't support reading/writing from memory).

Re: Issue with CRT/std::string

Posted: 2008-10-07T19:58:09-07:00
by magick
Blob support is automagically available to all image formats and delegates.