P
paul-kieu
Guest
Hi everyone,
I developed a deskstop app with GDI/MFC on Window 7.
This app loads an image per 5s. It crashed after 4-5h and I got ERROR_INVALID_PARAMETER in CreateDIBSection.
Hereafter is the code :
UINT local_colors = 2;
RGBQUAD image_colormap[2];
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;
UINT local_bmpInfo_size = sizeof(BITMAPINFO) + local_colors * sizeof(RGBQUAD);;
LPBITMAPINFO local_bmpInfo = (LPBITMAPINFO ) malloc(local_bmpInfo_size);
local_bmpInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
local_bmpInfo->bmiHeader.biBitCount = 1;
local_bmpInfo->bmiHeader.biClrUsed = local_colors;
local_bmpInfo->bmiHeader.biCompression = BI_RGB;
local_bmpInfo->bmiHeader.biHeight = 320l;
local_bmpInfo->bmiHeader.biPlanes = 1;
local_bmpInfo->bmiHeader.biWidth = 320l;
CopyMemory(local_bmpInfo->bmiColors, image_colormap, local_colors* sizeof(RGBQUAD));
HDC local_hDC = ::GetDC(NULL);
if(local_hDC)
{
UCHAR* image_bits = NULL;
HBITMAP local_imgHandle = CreateDIBSection(local_hDC , local_bmpInfo, DIB_RGB_COLORS, (void**)&image_bits, NULL, 0l);
}
::Release(NULL,local_hDC);
Do you have any idea ?
Continue reading...
I developed a deskstop app with GDI/MFC on Window 7.
This app loads an image per 5s. It crashed after 4-5h and I got ERROR_INVALID_PARAMETER in CreateDIBSection.
Hereafter is the code :
UINT local_colors = 2;
RGBQUAD image_colormap[2];
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;
UINT local_bmpInfo_size = sizeof(BITMAPINFO) + local_colors * sizeof(RGBQUAD);;
LPBITMAPINFO local_bmpInfo = (LPBITMAPINFO ) malloc(local_bmpInfo_size);
local_bmpInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
local_bmpInfo->bmiHeader.biBitCount = 1;
local_bmpInfo->bmiHeader.biClrUsed = local_colors;
local_bmpInfo->bmiHeader.biCompression = BI_RGB;
local_bmpInfo->bmiHeader.biHeight = 320l;
local_bmpInfo->bmiHeader.biPlanes = 1;
local_bmpInfo->bmiHeader.biWidth = 320l;
CopyMemory(local_bmpInfo->bmiColors, image_colormap, local_colors* sizeof(RGBQUAD));
HDC local_hDC = ::GetDC(NULL);
if(local_hDC)
{
UCHAR* image_bits = NULL;
HBITMAP local_imgHandle = CreateDIBSection(local_hDC , local_bmpInfo, DIB_RGB_COLORS, (void**)&image_bits, NULL, 0l);
}
::Release(NULL,local_hDC);
Do you have any idea ?
Continue reading...