如何建立Gdiplus::Bitmap的数组集合
时间: 2024-05-22 17:15:57 浏览: 16
要建立一个Gdiplus::Bitmap的数组集合,可以按照以下步骤进行:
1. 定义一个Gdiplus::Bitmap类型的指针数组。
Gdiplus::Bitmap** bitmapArray;
2. 分配数组空间,可以使用new运算符。
bitmapArray = new Gdiplus::Bitmap*[numOfBitmaps];
3. 对每个数组元素进行初始化,即创建一个新的Gdiplus::Bitmap对象。
for (int i = 0; i < numOfBitmaps; i++)
{
bitmapArray[i] = new Gdiplus::Bitmap(width, height, PixelFormat32bppARGB);
}
4. 使用完毕后,记得释放内存,即删除数组元素和数组本身。
for (int i = 0; i < numOfBitmaps; i++)
{
delete bitmapArray[i];
}
delete[] bitmapArray;
完整代码示例如下:
int numOfBitmaps = 5;
int width = 100;
int height = 100;
Gdiplus::Bitmap** bitmapArray;
bitmapArray = new Gdiplus::Bitmap*[numOfBitmaps];
for (int i = 0; i < numOfBitmaps; i++)
{
bitmapArray[i] = new Gdiplus::Bitmap(width, height, PixelFormat32bppARGB);
}
// 使用数组进行操作
...
for (int i = 0; i < numOfBitmaps; i++)
{
delete bitmapArray[i];
}
delete[] bitmapArray;
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)