Thread: Help creating a Bitmap

  1. #1
    Registered User
    Join Date
    Jan 2003

    Help creating a Bitmap

    I need help to create a Bitmap picture.

    The situation is like this:

    I am loading in an array with 16 bit values. Each of these values represent the color of one pixel. Each array represents one line of a bitmap image. And then I loop the program so that in the end, a whole picture is created on the screen.

    My problem is, what kind of API functions can I use to do this?

    I have looked at SetPixel() and Bitmap constructor, but I don't understand the whole process.

    Can anyone give me some tips?

    I'm using C++ in MFC.

    Hoping for a reply


  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Newport, South Wales, UK
    If you load the array into memory, you can draw it to the screen using StretchDIBits. You'll need to fill out the BITMAPINFOHEADER of a BITMAPINFO structure first, specifying the size of the BITMAPINFOHEADER structure, width and height (Negative height if the array stores the top line first and the bottom line last), 1 plane, 16 bit count and zeroing the other members.

    Once that's done, you can call:-
    StretchDIBits(hdc, XDest, YDest, nDestWidth, nDestHeight, XSrc, YSrc, nSrcWidth, nSrcHeight, lpBits, &bi, DIB_RGB_COLORS, SRCCOPY);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 09:43 AM
  3. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  4. Copying Bitmap Resources without Creating HDC's
    By bartybasher in forum Windows Programming
    Replies: 1
    Last Post: 08-02-2004, 06:35 AM
  5. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM