how to use API SetMagickResourceLimit

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
wsq003
Posts: 7
Joined: 2012-02-16T00:29:20-07:00
Authentication code: 8675308

how to use API SetMagickResourceLimit

Post by wsq003 »

I have included <Magick++.h> and can use class Image/Blob to draw text.

When I tried to call SetMagickResourceLimit, the GCC reported:
./my_magick.cpp:10: error: 'ThreadResource' was not declared in this scope
./my_magick.cpp:10: error: 'SetMagickResourceLimit' was not declared in this scope

Code: Select all

int warterMark(void** buff, int* len)
{
	if (!magick_init) {
		SetMagickResourceLimit(ThreadResource, 1);
		magick_init = true;
	}

	int need_write = 0;
	Blob destBlob;
	try
	{
		Image image;
		Blob srcBlob(*buff, *len);

		image.read(srcBlob);

		list<Drawable> text_draw_list;
		//text_draw_list.push_back(DrawableFont("-*-helvetica-medium-r-normal-*-*-120-*-*-*-*-iso8859-1"));
		text_draw_list.push_back(DrawableFont("Courier"));
		text_draw_list.push_back(DrawableText(50, 50, "Hello world!"));
		text_draw_list.push_back( DrawableStrokeColor(Color("red")));
		text_draw_list.push_back( DrawableFillColor(Color(0, 0, 0, MaxRGB)));
		image.draw(text_draw_list);

		image.magick("JPEG");
		image.write(&destBlob);

		int outputSize = destBlob.length();
		if (outputSize > *len)
		{
			*buff = (char *)realloc(*buff, outputSize);
		}
		*len = outputSize;

		memcpy(*buff, destBlob.data(), outputSize);
	}
	catch (exception &e)
	{
		return 5;
	}

	return 0;
}
Can anyone tell me what should I do?

Thanks in advance.
wsq003
Posts: 7
Joined: 2012-02-16T00:29:20-07:00
Authentication code: 8675308

Re: how to use API SetMagickResourceLimit

Post by wsq003 »

I resolved this problem by reading the <Magic++/Include.h>
//Include ImageMagick headers into namespace "MagickCore"

The proper code should be:
MagickCore::SetMagickResourceLimit(MagickCore::ThreadResource, 1);

Sorry for disturbing.
Post Reply