Board index » cppbuilder » alpha channel

alpha channel


2003-07-19 07:08:44 AM
cppbuilder3
Is there a way to the alpha value of a TBitmap, progammatically in C++
Builder.
Thanks,
Nathan
 
 

Re:alpha channel

Hi Nathan,
Quote
Is there a way to the alpha value of a TBitmap, progammatically
in C++ Builder.
The TBitmap class doesn't provide support for translucency. If you don't
need to deploy on Win95/NT4-, you can use the AlphaBlend() GDI function;
here's an example...
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap& Bitmap = *Image1->Picture->Bitmap;
Bitmap.PixelFormat = pf32bit;
int const cx = Bitmap.Width;
int const cy = Bitmap.Height;
BLENDFUNCTION bf = {0};
bf.SourceConstantAlpha = 128;
::AlphaBlend(
Canvas->Handle, 5, 5, cx, cy,
Bitmap.Canvas->Handle, 0, 0, cx, cy,
bf
);
}
The other option is to perform the blending manually; you'd use a third
bitmap whose pixels would be set to a mixture between the pixels associated
with the target DC and the pixels associated with your source bitmap. Let
me know if you need an example of this latter approach.
Good luck,
--
Damon (TeamB)
BCBCAQ - bcbcaq.bytamin-c.com
 

Re:alpha channel

BTW, if you do use the AlphaBlend() function, be sure to add
$(BCB)\lib\psdk to the "Library path" within the Project Options dialog.
Also, within your .cpp file, add #pragma link "msimg32.lib".
--
Damon (TeamB)
BCBCAQ - bcbcaq.bytamin-c.com
"Damon Chandler (TeamB)" wrote:
Quote
If you don't need to deploy on Win95/NT4-, you can use the
AlphaBlend() GDI function;
 

{smallsort}

Re:alpha channel

There are various Graphics processing algorithm, search at google u will
find some,
:-)
-Dumboo
"Nathan Maxon" < XXXX@XXXXX.COM >wrote in message
Quote
Is there a way to the alpha value of a TBitmap, progammatically in C++
Builder.

Thanks,
Nathan