我正在尝试制作一个图像数组
Image something(L"something.png");而不是那样
Image something[2];
something[0]=(L"something.png");有什么想法吗?
发布于 2010-08-31 13:17:14
通过指针使用Gdiplus图像和位图对象要容易得多。
考虑使用指针数组。如果您不想在完成时显式地记住释放数组,则可以使用智能指针。在下面的代码示例中,我使用了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
}https://stackoverflow.com/questions/3606126
复制相似问题