im trying to make an array of images
Image something(L"something.png");
instead of that
Image something[2];
something[0]=(L"something.png");
any idea
im trying to make an array of images
Image something(L"something.png");
instead of that
Image something[2];
something[0]=(L"something.png");
any idea
Image something[2] = {Image(L"something.png"), Image(L"Something_else.png")};
It's a lot easier to use Gdiplus image and bitmap objects by pointer.
Consider using an array of pointers. If you don't want to have to explicitly remember to free the array when you are done, you can use a smart pointer. In the code sample below I use CAutoPtr.
#include <Windows.h>
#include <gdiplus.h>
#include <atlbase.h>
void HandleImages(HDC hdc)
{
typedef CAutoPtr<Gdiplus::Image> GdiplusImagePtr; // could be declared using CAutoPtr<Gdiplus::Bitmap>
GdiplusImagePtr something[2];
Gdiplus::Graphics g(hdc);
something[0].Attach(new Gdiplus::Bitmap(L"something.png"));
something[1].Attach(new Gdiplus::Bitmap(L"otherthing.png"));
for (int x = 0; x < ARRAYSIZE(something); x++)
{
g.DrawImage(something[x], 50*x, 0);
}
// CAutoPtr will call destructor for each item in something array
}