CBitmap class - Programmer

This is a discussion on CBitmap class - Programmer ; Hello everyone, i'm new to windows programming in C++. I have to display a 2-D array as a bitmap. I tried to compile the following code..but the compiler doesnt identify the CBitmap class...can anyone tell me what is missing (headers/functions) ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: CBitmap class

  1. CBitmap class

    Hello everyone,
    i'm new to windows programming in C++. I have to display a 2-D array as

    a bitmap. I tried to compile the following code..but the compiler
    doesnt identify the CBitmap class...can anyone tell me what is missing
    (headers/functions) so as to complete the code??


    HDC dc= ::GetDC(0);
    int Bps = ::GetDeviceCaps(dc,BITSPIXEL);
    ::ReleaseDC(0,dc);


    int size = 100*100*Bps/8;
    BYTE *bbits = new BYTE[size]; //-------------bbits is a 2D(100*100)
    array
    memset(bbits,192,size);


    CBitmap bitmap;
    bitmap.CreateBitmap(100, 100, 1, Bps, bbits);


    BITMAP bmp;
    bitmap.GetBitmap(&bmp);
    CClientDC dcScreen(this);
    CDC dcMem;
    dcMem.CreateCompatibleDC(&dcScreen);
    CBitmap *pOld = dcMem.SelectObject(&bitmap);
    dcScreen.BitBlt(0,0,bmp.bmWidth,bmp.bmHeight,&dcMem,0,0,SRCCOPY);


    dcMem.SelectObject(pOld);
    bitmap.DeleteObject();
    dcMem.DeleteDC();
    delete []bbits;


  2. Re: CBitmap class

    CBitmap is defined in afxwin.h. So, you should include afxwin.h in your
    headers (StdAfx.h it's perfect).
    #include

    This should work!


+ Reply to Thread