Thread: BITMAP not in color when painted, HELP!

  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: [email protected]

    ---------------------------------
    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,868
    >>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,708
    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,868
    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, 09: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, 10:07 AM
  5. texture is all white in opengl!
    By Crossbow in forum Game Programming
    Replies: 7
    Last Post: 03-31-2002, 11:54 AM