Home > Back-end >  The problem of bitmap
The problem of bitmap

Time:09-28

I want to realize this function:
Abitmap: Tbitmap;

Abitmap. LoadFromStream (stream);//into a picture,

And then a layer of translucent color in the picture on this chart,




Finally put the add a layer of translucent color pictures, show in somewhere, or save to a new diagram:
Self. ImageControl1. Bitmap:=Abitmap;


I try the following methods, not at all:
Abitmap. Canvas. The fill. Color:=$80 cd00cd;
Abitmap. Canvas. FillEllipse (arect, 0.5);

Consult everybody should how to do???????

I am using firemonkey ~ ~

CodePudding user response:

Abitmap. Canvas, only a layer of figure, is bad to do,
Recommended PNGImage set transparency,
Bitmap. Assign (Png)

CodePudding user response:

Transparent channel is another 32-bit BitMap,
Tbitmap transpartnecolor can specify transparent color,

CodePudding user response:

,, there are two ways to approach a, is as a PNG image with a transparent head, this is pure color pictures, just a transparent channel, and then directly on the Bitmap PNG painted, this is a weak-minded method, the second approach is to use Windows's own AlphaBlend function synthesis function, the fusion methods and is also a similar, just code generation, need not oneself construction, give you a function:
 
Procedure DrawAlphaByColor (DC: HDC. AlpahRect: TRect; Color: TColor; AlphaByte: Byte=100);
Var
BMP: TBitmap;
BF: BLENDFUNCTION;
W, H: Integer;
The begin
BMP:=TBitmap. Create;
W:=AlpahRect. Right - AlpahRect. Left;
H:=AlpahRect. Bottom - AlpahRect. Top;
BMP. SetSize (W, H);
BMP. Canvas. Brush. Color:=Color;
BMP. Canvas. FillRect (BMP) Canvas) ClipRect);
BF. BlendOp:=AC_SRC_OVER;
BF. BlendFlags:=0;
BF. AlphaFormat:=0;
BF. SourceConstantAlpha:=AlphaByte;
Windows. AlphaBlend function (DC, AlpahRect. Left, AlpahRect. Top, W, H,
BMP. Canvas. Handle, 0, 0, BMP. Width, BMP. Height, BF);
BMP. Free;
The end;

Actually the code is not much
Use the
DrawAlphaByColor (BMP) Canvas) Handle, the Rect (0, 0, BMP. Width, BMP. Height), clred, 50)
  • Related