【发布时间】:2013-04-19 11:20:03
【问题描述】:
我需要创建 HBITMAP。
这就是问题所在。我在内存中有 bmp 文件的内容。
如果位图作为资源,我知道如何创建 HBITMAP。 但是既然是在内存中,我就不知道怎么弄了。
我这样做(如果在资源中):Link
hDC = BeginPaint(hWnd, &Ps);
// Load the bitmap from the resource
bmpExercising = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_EXERCISING));
// Create a memory device compatible with the above DC variable
MemDCExercising = CreateCompatibleDC(hDC);
// Select the new bitmap
SelectObject(MemDCExercising, bmpExercising);
// Copy the bits from the memory DC into the current dc
BitBlt(hDC, 10, 10, 450, 400, MemDCExercising, 0, 0, SRCCOPY);
// Restore the old bitmap
DeleteDC(MemDCExercising);
DeleteObject(bmpExercising);
EndPaint(hWnd, &Ps);
如果它是内存资源,请指导我如何操作。
以某种方式将char img[10000] 更改为资源?
这里,img 是约束位图内容的内存。
【问题讨论】:
-
CreateDIBitmap 是您所需要的,但它是一个复杂的函数。寻找一些示例代码。
-
你能给我举个例子吗?我真的搜索了很多......
-
@c.adhityaa 没有找到任何我可以推荐的样品。正如我所说,这是一个复杂的功能,并且很大程度上取决于您的“内存资源”的格式。我想您只需要通过 MSDN 工作即可。当您有一些实际代码时,我相信这里的人会帮助您解决任何问题。请记住花时间仔细准确地描述您的问题,这不是您这次所做的事情,这就是您得到三个不同答案的原因。
-
抱歉,当时很着急...现在改写问题会更好... :)