Loading images from windows resource section with Magick++

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
roel_

Loading images from windows resource section with Magick++

Post by roel_ »

Hi,

Is there sample code somewhere on how to load an image (png) from the resources of an application and convert it to a Magick::Image object? Thanks.


cheers,

roel
roel_

Post by roel_ »

Easier than I thought, here's one for the archives:

Code: Select all

HRSRC resinfo = ::FindResource(_Module.m_hInst, MAKEINTRESOURCE(IDB_CROSS), "png");
DWORD resourcesize = ::SizeofResource(_Module.m_hInst, resinfo);
HGLOBAL pnghandle = ::LoadResource(_Module.m_hInst, resinfo);
void* buf = ::LockResource(pnghandle);

Magick::Blob blob(buf, resourcesize);
Magick::Image image;
image.read(blob);
Post Reply