Here is a little test proggie, compile it and drop a "test.gif" next to it.
Code: Select all
#include <iostream>
#include <iomanip>
#include <windows.h>
#include <wand/MagickWand.h>
using namespace std;
void ThrowWandException(MagickWand * wand)
{
ExceptionType severity;
char* description = MagickGetException(wand, &severity);
cerr << "Imagemagick exception: " << description << endl;
description = (char*) MagickRelinquishMemory(description);
exit(-1);
}
int main(int argc, char** argv)
{
// Initialize magickwand
MagickWandGenesis();
if(MagickSetResourceLimit(MemoryResource, 3) == MagickFalse)
{
cerr << "Could not set memory resource limit\n";
exit(100);
}
// Start timer
DWORD start = GetTickCount();
// Read, blob and destroy
int amount = 1000;
for(int i = 1; i < amount + 1; i++)
{
MagickWand * magick_wand = NewMagickWand();
// Read an image.
MagickBooleanType status = MagickReadImage(magick_wand, "test.gif");
if(status == MagickFalse)
ThrowWandException(magick_wand);
// Create da blob
MagickSetImageDepth(magick_wand, 8);
MagickSetImageFormat(magick_wand, "PNG");
unsigned int blob_len = 0;
unsigned char * blob = MagickGetImageBlob(magick_wand, &blob_len);
if(blob == 0)
ThrowWandException(magick_wand);
// Clean up
MagickRelinquishMemory(blob);
magick_wand = DestroyMagickWand(magick_wand);
// Show some stuff
unsigned long mem_limit = GetMagickResource(MemoryResource);
unsigned long map_limit = GetMagickResource(MapResource);
unsigned long area_limit = GetMagickResource(AreaResource);
if(i % 1 == 0.0)
cout << "\r" << setfill(' ') << setw(5) << setprecision(1) << setiosflags(ios::fixed ) << (i == 0 ? 0 : (float)i / (float)amount * 100.0) << "% (" << mem_limit << ", " << map_limit << ", " << area_limit << ")...";
}
// End timing
DWORD end = GetTickCount();
cout << endl;
cout << "iterations: " << amount << endl;
cout << "time : " << ((float)(end - start) / 1000.0) << " seconds" << endl;
cout << "ips : " << ((amount * 1000) / (end - start)) << " iterations per second" << endl;
cout << endl;
cout << "done ..." << endl;
// Clean up
MagickWandTerminus();
return(0);
}
2 - Btw. with and without UseEmbeddableMagick enabled, GetMagickResource(...) always returns 0.
BTW. compiled IM as StaticMultiThreadedDLL with
Code: Select all
#define QuantumDepth 8
#undef UseInstalledMagick
#undef ProvideDllMain
#undef HasX11
#undef UseEmbeddableMagick