Page 1 of 1
image.read() failing
Posted: 2014-08-20T04:12:12-07:00
by PBert
Hi Folks,
when trying to init an image by reading from a file location, my program crashes. Here's what I've gone in circles around:
Code: Select all
InitializeMagick("..."); // tried a few locations from the program location, to null
Image image;
image.read("..."); // crash
But if I init an image using:
Code: Select all
Image image(Geometry(100,100),Color(255,200,0,255))); // coloured orange for testing
all is fine, including running the image through routines (e.g. contrast). But I cannot read, nor write (image.write("..") does nothing either, though it doesn't crash).
What might be causing this, or where might I be going wrong?
I'm using a static build (6.8.5 I think), testing on win7 (program is intended for win and mac). Not sure what else I could add that might help. Let me know if more is needed.
Cheers,
PB.
Re: image.read() failing
Posted: 2014-08-20T04:19:24-07:00
by snibgo
What is your development environment? I'll guess it is MSVC and you are in debug mode. See this recent thread:
viewtopic.php?f=2&t=26109
If that doesn't help: do the demo programs compile and run?
Re: image.read() failing
Posted: 2014-08-20T19:33:27-07:00
by PBert
Hi snibgo,
development is being done in VS Exp. 2010, and the crashes are happening in release builds. I must confess, generally speaking, I don't do debug builds as I test most things manually myself by (e.g.) printing variable values etc.
For notes' sake, the build ends up as a dll (albeit with another extension) and is a plugin that runs under the wing of another major piece of software. The plugin runs fine, until .read() is called. I should have mentioned also that the IM namespace and routines are buing called inside namespace brackets like the following:
Code: Select all
void MyFunction(void)
{
using namespace MyMagic
{
InitImageMagic..
Image image;
}
}
Is this likely to make any difference?
Most (90%+) of the demos build. Of the ones that do build, when running the .exe a window is opened, but it disappears very quickly - so I'm not sure if they're doing what they're meant to or not.
PB.
Re: image.read() failing
Posted: 2014-08-20T21:16:25-07:00
by snibgo
Sorry, I have forgotten anything I ever knew about Visual Studio. When you have built the demo programs, you should be able to run them from the command line. They should read and write image files successfully.
Re: image.read() failing
Posted: 2014-08-20T22:30:25-07:00
by PBert
That's no worries, thanks for having a go - I'll do a bit more testing with the demos and the command line at some stage to see if anything further can come out of them.
In the meantime, I may have found a workaround that, while not the most efficient way, might do enough to at least continue with other areas of development until another solution/someone else comes along to chip in!
Cheers,
PBert.
Re: image.read() failing
Posted: 2014-08-28T01:02:29-07:00
by PBert
Hi folks,
I've 'worked out' what the problem is here. See examples:
Code: Select all
// this fails
Image Img1;
Img1.read("C:\test.png");
// this works
Image Img1;
Img1.read("C:/test.png");
// note the difference is the folder characters ("\" and "/")
Would be happy to hear from anyone who might be able to explain the above, if anything just for knowledge's sake. Otherwise, the change seems to of worked.
Cheers,
PBert.
Re: image.read() failing
Posted: 2014-08-28T01:19:09-07:00
by snibgo
Have you built your program plus libraries as a Unix program or a Windows program? Unix programs want "/", and Windows programs want "\".
I haven't figured out this stuff myself, but you might discover something if you insert this in your code:
Code: Select all
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
printf ("MAGICKCORE_WINDOWS_SUPPORT defined\n");
#endif
#if defined(WIN32)
printf ("WIN32 defined\n");
#endif
#if defined(WIN64)
printf ("WIN64 defined\n");
#endif