Thread: Transparent Bitmap - inserting into richeditctrl

  1. #1
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001

    Transparent Bitmap - inserting into richeditctrl

    I'm using a great class called CImageDataObject that takes a IRichEditOle* and an HBITMAP and inserts it into the associated CRichEditCtrl. My problem is that I am inserting small "smiley" bitmaps into a chat edit and every one has white around the yellow face. How do I make the background transparent? I was just making the background of the rich edit white, but I'm using a CListBox beside it and I can't change it to white, so it looks odd with white and gray right next to each other. I suppose I could use a CListCtrl instead of CListBox so I can change the bgcolor but I don't want to do that unless I have to.


    After rereading my post, I just want to make it clear that I'd like to somehow make the background of the bitmaps transparent.
    Last edited by LuckY; 08-05-2003 at 01:05 PM.

  2. #2
    Join Date
    Jan 2002
    TransparentBlt may help but leaks resources on win9x so you may prefer a more general solution to transparency. The general idea is to create a monochrome mask of the image, blt that to the target using SRCAND flag and follow up with the image itself using SRCPAINT - the flags are the final parameter of BitBlt. I can't recall exactly how to create a monochrome mask at run-time from the image but a google search should turn up plenty of examples.

    Alternatively you may wish to try using an image list common control which can 'allegedly' create the monochrome masks for you (I never got them to do exactly what I needed but that's probably because I was doing something wrong).

    In any case, you will have to use an owner draw list control to handle the image rendering yourself.

    Note: The link to the knowledge base article on msdn referred to in the TransparentBlt page describing a non-resource leaky solution is broken; the article (including source) can be found here.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with Bitmap Display
    By The Brain in forum Windows Programming
    Replies: 7
    Last Post: 03-23-2009, 05:33 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. 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