CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Posts
    13

    Displaying a Bitmap

    Suggestions please. I can display a bitmap file from a preloaded resouce (using LoadBitmap) onto a window, but unable to do so when using an externally loaded file (using CreateBitmap).

    [external file format decompression is okay - PCX format]


  2. #2
    Join Date
    May 1999
    Location
    Republic of Korea
    Posts
    74

    Re: Displaying a Bitmap

    Check if the loaded file is a bitmap with palette(256 color image, for example).
    In that case, you must realize the palette before you call BitBlt to display it correctly.




  3. #3
    Join Date
    May 1999
    Posts
    13

    Re: Displaying a Bitmap

    The following is a preview of your post. If everything looks ok then you can click 'Continue' and your post will be entered. If not then use your back button to go back and edit some more.

    Subject: Re: Displaying a Bitmap

    I decode a PCX file, create & select the palette, but return a NULL when trying to realize it. I do not think this is the problem though.

    The SelectObject function returns a NULL when tring to select the externally read in data, although the CreateBitmapIndirect & CreateCompatibleDC functions appear to work correctly and return handles.

    The code below shows what I am doing, although what is wrong I cannot see ...


    hpal = CreatePalette( &logpal );
    oldhpal = SelectPalette( hdc, hpal, FALSE );
    check = RealizePalette( hdc );
    hbmpMyBitmap = CreateBitmapIndirect( &bm ); //hbmpMyBitmap = LoadBitmap(hInst, "MyBitmap"); //Using this internal resource, I display a bitmap in the window
    //GetObject(hbmpMyBitmap, sizeof(BITMAP), &bm);
    hdcMemory = CreateCompatibleDC(hdc);
    hbmpOld = SelectObject(hdcMemory,
    hbmpMyBitmap);i = BitBlt(hdc, 80, 80, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCCOPY);
    SelectObject(hdcMemory, hbmpOld);
    DeleteDC(hdcMemory);
    ReleaseDC(hwnd, hdc);




    any ideas please ?








  4. #4
    Join Date
    May 1999
    Posts
    13

    Displaying a Bitmap - Solved

    It would seem that the hardware caperbility changes with different resolutions, and the RC_PALETTE funtionality disappeared on my system when I changed from colour 256 mode.

    When in colour 256 mode I have RC_PALETTE functionality and hence I can display a decoded PCX file as a bitmap on a window.

    I used GetDeviceCaps(phdc, RASTERCAPS) & RC_PALETTE

    to check for the RC_PALETTE flag.

    Thats it !


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured