still i got a vc++ memory exception on opening a file. no matter whether the path to the file is correct.
Code: Select all
Unhandled exception at 0x10023f45 in CPP.Radon.transform.exe: 0xC0000005: Access violation writing location 0xcda98d72.
Code: Select all
#include <iostream>
#include <conio.h>
#include <Magick++.h>
using namespace std;
//using namespace Magick;
#if _DEBUG
const char* IN_DLL = "C:\\work\\CPP\\radon.trans\\CPP.Radon.transform\\bin\\Debug";
const char* IN_FILE = "xxxsmile.miff";
#endif
int main(int argc, char** argv) {
#if _DEBUG
Magick::InitializeMagick(IN_DLL);
#else
Magick::InitializeMagick(*argv);
#endif
try {
// Construct an image instance first so that we don't have to worry
// about object construction failure due to a minor warning exception
// being thrown.
Magick::Image image;
try {
// Try reading image file
image.read(IN_FILE);
}
catch( Magick::WarningCoder &warning )
{
// Process coder warning while loading file (e.g. TIFF warning)
// Maybe the user will be interested in these warnings (or not).
// If a warning is produced while loading an image, the image
// can normally still be used (but not if the warning was about
// something important!)
cerr << "Coder Warning: " << warning.what() << endl;
}
catch( Magick::Warning &warning )
{
// Handle any other Magick++ warning.
cerr << "Warning: " << warning.what() << endl;
}
catch( Magick::ErrorFileOpen &error )
{
// Process Magick++ file open error
cerr << "Error: " << error.what() << endl;
//continue; // Try next image.
}
try {
image.rotate(90);
image.write("outfile");
}
catch ( Magick::Error & error)
{
// Handle problem while rotating or writing outfile.
cerr << "Caught Magick++ exception: " << error.what() << endl;
}
}
catch( std::exception &error )
{
// Process any other exceptions derived from standard C++ exception
cerr << "Caught C++ STD exception: " << error.what() << endl;
}
catch( ... )
{
// Process *any* exception (last-ditch effort). There is not a lot
// you can do here other to retry the operation that failed, or exit
// the program.
}
10x 10x in advance