Transparent BMP display

This is a discussion on Transparent BMP display within the Windows Programming forums, part of the Platform Specific Boards category; I know how to load a bitmap from the resource and display it, but how can I display a bitmap ...

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Transparent BMP display

    I know how to load a bitmap from the resource and display it, but how can I display a bitmap with a transparent color?

    Code:
    static HBITMAP hBmp_Background;
    HWND hBmpStat;
    
    hBmp_Background = LoadBitmap(ghInstance, MAKEINTRESOURCE(ID_BMPBG));
    hBmpStat = CreateWindowEx(NULL, "Static", "",
                        WS_VISIBLE | WS_CHILD | SS_BITMAP,
                        0, 0, 0, 0, hwnd, NULL, ghInstance, NULL);
    SendMessage(hBmpStat, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmp_Background);
    And one more thing, do I need to keep the loaded object till the end of the program, or can I delete it once the STM_SETIMAGE is sent?

    Thank you.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You'll only be able to draw icons to a basic, non-subclassed static control if you want transparency (icons contain both the mask and image).

    For transparent bitmap rendering there's the quick and easy TransparentBlt which, unfortunately leaks memory under win98. To ensure your approach works for all windows then refer to the msdn article, How to draw transparent bitmaps.

    edit: theForger's winprog tutorial has a page similar to the msdn one: transparent bitmaps which you may find useful.
    Last edited by Ken Fitlike; 08-13-2005 at 06:14 AM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    thank you, i'll look it up.

    one more thing, how do you know it leaks memory, is there some sort place where I can get those type of notifications?
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Quote Originally Posted by msdn, TransparentBlt
    Windows 95/98: TransparentBlt contains a memory leak that can exhaust system resources. To draw a transparent bitmap using BitBlt - see Knowledge Base article 79212.
    The knowledgebase (kb) 79212 article is the other page I gave you a link to (How to draw transparent bitmaps).
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Transparent bmp on top of webcam feed?
    By h3ro in forum Windows Programming
    Replies: 4
    Last Post: 08-06-2008, 09:45 AM
  2. Pressing a key to display a new bmp
    By batman123 in forum Game Programming
    Replies: 2
    Last Post: 01-10-2005, 04:08 PM
  3. to display 8-bit bmp
    By rakesh09 in forum C Programming
    Replies: 2
    Last Post: 03-25-2003, 12:07 AM
  4. to display bmp of any size
    By rakesh09 in forum C Programming
    Replies: 5
    Last Post: 03-23-2003, 10:49 AM
  5. display pcx / bmp images
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 11-27-2001, 08:56 AM

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