I've been experiencing some problems when I try to read an Image object. I tried to search on Google using multiple queries, but I didn't manage to find any answer to this.
My problem is the following: Whenever I run the script below, I either get an unhandled exception (see quote #2), or the try/catch catches an exception and outputs something along the lines of quote #1. Why I say "something along the lines of", is mainly because these: "`@|ý'", always change. If I'm lucky, it tells me it can't open image #CCCCCC, which is somewhat correct, because then it takes the correct value of the string, excluding the first three characters. This doesn't seem to happen when I use an image file-name (meaning it always throws these strange (@|ý') characters instead).
Please note that I got both of these errors while trying to run the script multiple times using the same code without making any changes to my environment.
QUOTE #1
What is it referring to when it says invalid argument? Does it mean the argument I pass to read()? If that's the case, then what am I supposed to pass there, if not a color in hex, and not a file-name? Hell, I even tried copy/ pasting a tutorial to no avail.Caught exception: app.exe: unable to open image `@|ý': Invalid arg
ument @ error/blob.c/OpenBlob/2658
QUOTE #2
Unhandled exception at 0x5e841ed7 in app.exe: 0xC0000005: Access violation reading location 0x002f0000.
Code: Select all
#include "stdafx.h"
#include <iostream>
#include "Magick++.h"
using namespace std;
using namespace Magick;
int _tmain(int argc, _TCHAR* argv[])
{
// InitializeMagick("XXX\ImageMagick-6.8.9-Q16"); // <-- Is this necessary? Note it didn't change anything regarding my current error
Image image;
try
{
string backGround = "xc:#CCCCCC"; // <-- Borrowed this line from button.cpp
image.read(backGround); // <-- This is the line that causes everything to blow up
}
catch( Exception &error_ )
{
cout << "Caught exception: " << error_.what() << endl;
}
int capish = 0;
while (capish == 0)
{
cout << endl << endl << "Capish?" << endl;
cin >> capish;
}
return 0;
}
(Please note that before I did the things mentioned above, I did try the first piece of code on this page: http://www.imagemagick.org/Magick++/Image.html, though, that didn't work either. I've tried reading a PNG, and, like the code in the link does, a GIF. None of them worked.)
If I comment out "image.read(backGround);", the errors disappear. Of course though, nothing (as in no images) are loaded/ read either.
I use MSVC++ 2010 Express.
I tried to open the example projects, but the project files couldn't be converted for some reason, which is why I'm attempting to create this from a scratch project.
This is the version I use of ImageMagick: ImageMagick-6.8.9-Q16
If someone could try and help me figure out/ explain to me why I am getting these errors/ where I can read more about them, it'd be greatly appreciated (mostly referring to quote #1).
Thanks in advance,
/Nemo