I'm creating a program, and I need to load a PNG image from the resource files. The goal is simple, pass a Bitmap object by reference to a function, which assigns the PNG from the stream to it, and returns. Because it's by reference, the origial should be affected.
Using the tutorial over on CodeProject, I came up with the following code:
/*Standard stuff*/
HINSTANCE hinst=GetModuleHandle(0);
//This one works, but in the release, I don't want the image outside of the EXE
//Bitmap image(L"temp.png");
Bitmap image(30,44);
loadResource(image, MAKEINTRESOURCE(IDB_TEMP), RT_RCDATA);
Graphics graphics(hdc);
TextureBrush brush(&image,WrapModeTile);
graphics.FillRectangle(&brush, Rect(0, 0, 60, 88));
/*Standard stuff*/
The problem is that the original Bitmap isn't updated properly. It's initialized, and keeps that value, even after loadResource() runs.
Can you place your PNG file here for checking? I will try to help you check that.
Jack
--------------------------------------------------------------------------------
HMI/SCADA/CAD/GIS VC++ Source Codes: http://www.code-home.com
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.