Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transparent bitmaps

Status
Not open for further replies.

LyMc

Programmer
Joined
Jun 3, 2003
Messages
84
Location
US
To the best I've been able to test VS .NET, it apparently does not allow gifs to be imported as bitmaps. In fact, it seems to like bmps exclusively. The question is: is there any way to force a single color on a bitmap to be treated as transparent? I'm aware of the O/T toggle on bitmap editor, but I have not been able to make it work: the bitmap I am working with just now has the T turned on, yet the bitmap, when displayed obviously doesn not have a transparent background.

If someone can give me the clue/detail I need to make a single color transparent in a bitmap in VS, I'd be very grateful.
 
several ways exist...
one is to display yer bitmaps using an CImageList
e.g.
\\create image list
HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, *pstrBmpFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);

if (hBitmap)
m_bmpItem.Attach(hBitmap);

BITMAP bm;
m_bmpItem.GetBitmap (&bm);
m_pImageList = new CImageList;
m_pImageList->Create(bm.bmWidth, bm.bmHeight, ILC_COLOR24 | ILC_MASK, 1, 1);
\\add image with transparent colour
m_pImageList->Add(&m_bmpItem, RGB(255, 0, 255));

//draw the list in ::paint or the like
m_pImageList->DrawIndirect(pDC,
nBmpIndex,
CPoint(DestRect.left, DestRect.top),
CSize(DestRect.Width(), DestRect.Height()),
CPoint(0, 0));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top