Page 1 of 1

Loading images from windows resource section with Magick++

Posted: 2006-12-08T04:29:56-07:00
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

Posted: 2006-12-08T07:31:41-07:00
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);