createDIBsection failed

From: Francois (francois.aspert_at_epfl.ch)
Date: 08/17/04


Date: Tue, 17 Aug 2004 14:08:02 +0200

Hello!

i'm using the following code which is supposed to display a BMP image on
the screen.
But the result is a black rectangle.

CClientDC dc(this);
CDC bmDC;
bmDC.CreateCompatibleDC(&dc);
HDC hDC = bmDC.GetSafeHdc();
BITMAPINFO bmInfo;
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth = im_data->width;
bmInfo.bmiHeader.biHeight = im_data->height;
bmInfo.bmiHeader.biPlanes = 1;
bmInfo.bmiHeader.biBitCount = 24;
bmInfo.bmiHeader.biCompression = BI_RGB;
bmInfo.bmiHeader.biSizeImage = 0;
bmInfo.bmiHeader.biXPelsPerMeter = 0;
bmInfo.bmiHeader.biYPelsPerMeter = 0;
bmInfo.bmiHeader.biClrUsed = 0;
bmInfo.bmiHeader.biClrImportant = 0;
bmInfo.bmiColors[0].rgbBlue = 0;
bmInfo.bmiColors[0].rgbGreen = 0;
bmInfo.bmiColors[0].rgbRed = 0;
bmInfo.bmiColors[0].rgbReserved = 0;
kdu_byte *inter = im_data->data_buf;
HBITMAP hBmp =
::CreateDIBSection(hDC,(BITMAPINFO*)&bmInfo,DIB_RGB_COLORS,(void**)&inter,NULL,NULL);
DWORD yoyo = GetLastError();
CBitmap bmp;
bmp.Attach(hBmp);
BITMAP bi;
bmp.GetBitmap(&bi);
CBitmap *pOldbmp = bmDC.SelectObject(&bmp);
dc.BitBlt(50,150,im_data->width,im_data->height,&bmDC,0,0,SRCCOPY);
                                bmDC.SelectObject(pOldbmp);

but the error code after CreateDIBsection returns me the error code : 8
i.e. not enough storage place.

what can be wrong there?

thanks

Francois



Relevant Pages

  • CreateDIBSection failed
    ... i'm using the following code which is supposed to display a BMP image on ... HDC hDC = bmDC.GetSafeHdc; ... BITMAPINFO bmInfo; ... CBitmap bmp; ...
    (microsoft.public.win32.programmer.gdi)
  • createDIBsection failed
    ... i'm using the following code which is supposed to display a BMP image on ... HDC hDC = bmDC.GetSafeHdc; ... BITMAPINFO bmInfo; ... CBitmap bmp; ...
    (microsoft.public.vc.mfc)
  • Re: createDIBsection failed
    ... Put break points on those guys and interigate them. ... > i'm using the following code which is supposed to display a BMP image on ... > BITMAPINFO bmInfo; ...
    (microsoft.public.vc.language)
  • Re: createDIBsection failed
    ... Put break points on those guys and interigate them. ... > i'm using the following code which is supposed to display a BMP image on ... > BITMAPINFO bmInfo; ...
    (microsoft.public.vc.mfc)