Running IM C++ programs

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
teetanne

Post by teetanne »

Hi majlow,

well, to write a C++ prog. do it like this with VC++

Code: Select all

#include "stdafx.h"
#include <Magick++.h>

using namespace std;
using namespace Magick;

int _tmain(int argc, _TCHAR* argv[])
{
        cout << "crop a image" << endl;
	cout << "---------------------------------" << endl;
	int iRet = 0;
	Image image;
	Geometry frame;
        string fileName(argv[1]);    // todo: test argv[1] != null
	try {
		image.read(fileName);
		frame.width(100);
		frame.height(100);
		frame.xOff(50);
		frame.yOff(50);
		image.crop(frame);
		image.write(filename);
		iRet = 0;
	}
	catch(exception &error_) {
		cout << error_.what() << endl;
		iRet = 1;
        }
	catch(...) {
		cout << "Unknown exception occurred" << endl;
		iRet = 1;
        }
	return iRet;
}
When you move your exe file to a other computer you have to take all dlls from the imagemagick bin folder and put it in the same folder as the exe file. Your have to compile your prog. in release mode.
Compare http://redux.imagemagick.org/discussion ... php?t=3671


Thats it, nothing more.

Good luck, teetanne
teetanne

Post by teetanne »

Hi majlow,

download the "depends.exe" from MS an see what you program is missing.

teetanne
Post Reply