|
|
|
date: Thu, 22 May 2008 23:51:38 -0500,
group: microsoft.public.platformsdk.gdi
back
Re: AlphaBlend a bitmap
"James L. Williams" wrote in message
news:E73F8B04-BC35-4EFA-BCE6-5A3AA2B8FF9D@microsoft.com...
> Hello,
>
> Can someone explain how to AlphaBlend a bitmap with a background color of
> a window!. I would like to take a bitmap and make it light with the
> background color of a treeview and then paint that to the treeview. I
> don't want to use GDI+ and I don't use the MS Visual C. I tried using the
> windows API alphablend, but I couldn't get it to work.
>
> Thanks,
>
>
> James
The AlphaBlend function displays bitmaps that have transparent or
semitransparent pixels.
This means that your bitmap should contain an alpha chanel (32bit BMP)
It is not a simple task to create these and you would need a photo editing
program that can save them.
I use Corel Photopaint, save them as PhotoShop files (PSD), load them into
GifMovieGear and save them as 32bit BMPs.
hCurrentBmp=LoadBitmap((HINSTANCE)ghInstance,MAKEINTRESOURCE(IDB_BMP));
//should use LoadImage( ) and you can load from a file if not using a
resource
HDC hDC=GetDC(m_hWnd);
HDC hCDC=CreateCompatibleDC(hDC);
GetTextMetrics(hDC,&tm);
if(hCurrentBmp){
SetStretchBltMode(hDC,HALFTONE);
SelectObject(hCDC,hCurrentBmp);
BLENDFUNCTION bf;
bf.BlendOp=AC_SRC_OVER;
bf.BlendFlags=0;
bf.SourceConstantAlpha=255;
bf.AlphaFormat=AC_SRC_ALPHA;
AlphaBlend(
hDC,
0,0,
nWidthDest,nHeightDest,
hCDC,
0,0,
nWidthSrc,nHeightSrc,
bf);
}
DeleteDC(hCDC);
DeleteDC(hDC);
Hope that helps.
Regards,
Ron Francis
www.RonaldFrancis.com
date: Sat, 24 May 2008 11:14:11 +0930
author: Ron Francis
|
|