问题描述
大家好,
我在Window 7上开发了一个带有GDI / MFC的deskstop应用程序。
I developed a deskstop app with GDI/MFC on Window 7.
此应用程序加载了每5秒的图像。它在4-5h后崩溃,我在CreateDIBSection中得到了ERROR_INVALID_PARAMETER。
This app loads an image per 5s. It crashed after 4-5h and I got ERROR_INVALID_PARAMETER in CreateDIBSection.
以下是代码:
UINT local_colors = 2;
UINT local_colors = 2;
RGBQUAD image_colormap [2];
RGBQUAD image_colormap[2];
image_colormap [0] .rgbRed = image_colormap [0] .rgbGreen = image_colormap [0] .rgbBlue = 0;
image_colormap[0].rgbRed = image_colormap[0].rgbGreen = image_colormap[0].rgbBlue = 0;
image_colormap [1] .rgbRed = image_colormap [1] .rgbGreen = image_colormap [1] .rgbBlue = 255;
image_colormap[1].rgbRed = image_colormap[1].rgbGreen = image_colormap[1].rgbBlue = 255;
UINT local_bmpInfo_size = sizeof(BITMAPINFO)+ local_colors * sizeof(RGBQUAD);;
UINT local_bmpInfo_size = sizeof(BITMAPINFO) + local_colors * sizeof(RGBQUAD);;
LPBITMAPINFO local_bmpInfo =(LPBITMAPINFO)malloc(local_bmpInfo_size);
LPBITMAPINFO local_bmpInfo = (LPBITMAPINFO ) malloc(local_bmpInfo_size);
CopyMemory(local_bmpInfo-> bmiColors,image_colormap,local_colors * sizeof(RGBQUAD));
CopyMemory(local_bmpInfo->bmiColors, image_colormap, local_colors* sizeof(RGBQUAD));
HDC local_hDC = :: GetDC(NULL);
HDC local_hDC = ::GetDC(NULL);
if(local_hDC)
if(local_hDC)
{
UCHAR * image_bits = NULL;
UCHAR* image_bits = NULL;
HBITMAP local_imgHandle = CreateDIBSection(local_hDC ,local_bmpInfo,DIB_RGB_COLORS,(void **)& image_bits,NULL,0l);
HBITMAP local_imgHandle = CreateDIBSection(local_hDC , local_bmpInfo, DIB_RGB_COLORS, (void**)&image_bits, NULL, 0l);
}
:: Release(NULL,local_hDC);
::Release(NULL,local_hDC);
您有什么想法吗?
推荐答案
你有任何更新吗?如果您的案例已经解决,请帮助标记答案。如果没有,请随时与我们联系。
Have you got any updates? If your case has been solved, please help to mark answers. If not, just feel free to contact us.
您的理解与合作将不胜感激。
Your understanding and cooperation will be grateful.
最好的问候,
Best Regards,
Jack Zhang
Jack Zhang
这篇关于GDI:CreateDIBSection / CreateDIBitmap几个小时后失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!