Alphablend is a function used to specify image transparency. It is used in graphics, graphutil, and ribbonstyleactnctrls.
In the following test, an image is displayed in the form and the transparency can be adjusted.
In this example:
Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, comctrls; Type tform1 = Class (tform) trackbar1: ttrackbar; procedure outputs (Sender: tobject); Procedure formdestroy (Sender: tobject); Procedure trackbar1change (Sender: tobject); Procedure outputs (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} var bit: tbitmap; Procedure tform1.formcreate (Sender: tobject); begin bit: = tbitmap. create; bit. loadfromfile ('C: \ temp \ test.bmp '); trackbar1.min: = 0; trackbar1.max: = 255; trackbar1.position: = 128; doublebuffered: = true; end; Procedure tform1.formdestroy (Sender: tobject); begin bit. free; end; Procedure tform1.formpaint (Sender: tobject); var blendfunc: tblendfunction; begin blendfunc. blendop: = ac_src_over; blendfunc. blendflags: = 0; blendfunc. sourceconstantalpha: = trackbar1.position; If bit. pixelformat = pf32bit then blendfunc. alphaformat: = ac_src_alpha else blendfunc. alphaformat: = 0; windows. alphablend (canvas. handle, {Target DC} 30, 10, bit. width, bit. height, {target location and size} bit. canvas. handle, {source DC} 0, 0, bit. width, bit. height, {source location and size} blendfunc {transparent structure}); end; Procedure tform1.trackbar1change (Sender: tobject); begin repaint; end.
Form file:
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 206 clientwidth = 223 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false oncreate = formcreate ondestroy = formdestroy onpaint = formpaint pixelsperinch = 96 textheight = 13 object trackbar1: ttrackbar left = 8 Top = 175 width = 207 Height = 23 showselrange = false taborder = 0 onchange = trackbar1change endend