MickH, it sounds like you are trying to use GDI Plus. Well, there is a bit of setup that you need to do. First, add these two items to your header definitions:
1 2
|
#include <gdiplus.h>
#pragma comment (lib,"Gdiplus.lib")
| |
Next, add this to your WinMain() variable declarations:
Add these two lines of code to your WinMain() function, just after your variable declarations:
1 2
|
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
| |
Add this line of code at the bottom of WinMain(), just ahead of your return statement:
|
Gdiplus::GdiplusShutdown(gdiplusToken);
| |
This turns on GDI Plus at the start of you program, and shuts it off at the end. "Token" is just another form of a handle.
In your functions or classes, declare your objects, a pointer to your image, and a graphics object. "image1" and "graphic1" are just sample names. You can use whatever names you choose:
1 2
|
static Gdiplus::Image *image1=nullptr;
Gdiplus::Graphics graphic1(hdc);
| |
Load your image from HDD or other drive:
|
image1 = Gdiplus::Image::FromFile(L"<file path>/<file name>");
| |
Finally, draw your image:
|
graphic1.DrawImage(image1, xImgOrg, yImgOrg, cxSize, cySize);
| |
The image origin is always the upper-left corner. You may need to use brackets "{}" in your "case" statements, if the function gives you an error.
I hope this was of help.