BITMAP not in color when painted, HELP!

This is a discussion on BITMAP not in color when painted, HELP! within the Windows Programming forums, part of the Platform Specific Boards category; I have a bitmap painted fine, but the colors are very low. Like if the pic was one of a ...

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question BITMAP not in color when painted, HELP!

    I have a bitmap painted fine, but the colors are very low. Like if the pic was one of a regular window, it would only show up in blue, pink, purlse, gray, and white. Here's some code, HELP IF YOU CAN!:


    HBITMAP hbmBall;
    BITMAP bm;

    int ballX, ballY;

    void Draw(HDC hdc)
    {
    HDC hdcMemory;
    hdcMemory = CreateCompatibleDC(hdc);

    SelectObject(hdcMemory, hbmBall);
    BitBlt(hdc, ballX, ballY, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCPAINT);

    DeleteDC(hdcMemory);
    }



    // That's the function to load the bitmap, then I call:


    case WM_CREATE:
    hbmBall = LoadBitmap(g_hInst, "BMP1");

    GetObject(hbmBall, sizeof(bm), &bm);

    ballX = 0;
    ballY = 0;
    break;
    case WM_PAINT:
    PAINTSTRUCT ps;
    HDC hdcWindow;
    hdcWindow = BeginPaint(hwnd, &ps);

    Draw(hdcWindow);

    EndPaint(hwnd, &ps);
    break;




    This all works, but the colors are very weird. What do I do?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    >>SelectObject(hdcMemory, hbmBall); = Memory lost each time, or at least on init. (In this case the same bmp is being selected in each time so may be OK.)
    Not a problem unless you want the program to run for more than a few minutes.

    >>SRCPAINT -> why use this operation? I would guess if the colours look 'washed out' (white background) that this is the problem . Read the help to fix.

    >>HBITMAP hbmBall;
    >>BITMAP bm;
    >>int ballX, ballY;
    If not global should be static. Unless you only have one file in the project.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    Yeah I haven't been able to do that either. Everything on the screen looks hackish. I'm thinking though the secret is in the bitmap structure...

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    SRCPAINT might be a problem, because it combines source and destination colors by OR operator. I would use SRCCOPY instead.

    LoadBitmap () may also cause color conversions, because it converts DIB bitmap into DDB bitmap.

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Also watch the pen alignment.

    try a

    SetStretchBltMode(hdc,HALFTONE);

    slower but better colour result.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    Registered User DutchStud's Avatar
    Join Date
    Oct 2001
    Posts
    43
    I would say change SRCPAINT to SRCCOPY first. that's probably your problem. if that doesn't work, then try some of the other suggestions.

  7. #7
    Neandrake
    Guest
    I've never seen the function Draw(). Is that a mistake?

  8. #8
    Neandrake
    Guest
    Whoops, my mistake, nevermind that las question...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 08:43 AM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  3. Loading a Bitmap resource for OpenGL Texture[x]
    By the dead tree in forum Game Programming
    Replies: 4
    Last Post: 08-26-2004, 01:12 PM
  4. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 09:07 AM
  5. texture is all white in opengl!
    By Crossbow in forum Game Programming
    Replies: 7
    Last Post: 03-31-2002, 10:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21