delphi - How to draw transparent image on a form? -


i want draw transparent image on delphi form, not working.

here original png:
transparent border

i have loaded image in timage::

image1.transparent := true; form1.color := clwhite; form1.transparentcolor := true; form1.transparentcolorvalue := clwhite; 

timage

the application:
application


image isnt transparent.
image can drawed control or canvas.
use bmp images.
maybe doing wrong?
please help!

i found solution let draw bmp image alpha channel onto form using windows api:

const   ac_src_over = 0;   ac_src_alpha = 1;  type   blendfunction = packed record     blendop,     blendflags,     sourceconstantalpha,     alphaformat: byte;   end;  function winalphablend(hdcdest: hdc; xorigindest, yorigindest, wdest, hdest: integer;   hdcsrc: hdc; xoriginsrc, yoriginsrc, wsrc, hsrc: integer; ftn: blendfunction): longbool;   stdcall; external 'msimg32.dll' name 'alphablend';  procedure tform4.formclick(sender: tobject); var   hbm: hbitmap;   bm: bitmap;   bf: blendfunction;   dc: hdc; begin   hbm := loadimage(0,     'c:\users\andreas rejbrand\skrivbord\ratingctrl.bmp',     image_bitmap,     0,     0,     lr_loadfromfile);   if hbm = 0     raiselastoserror;   try     if getobject(hbm, sizeof(bm), @bm) = 0 raiselastoserror;     dc := createcompatibledc(0);     if dc = 0 raiselastoserror;     try       if selectobject(dc, hbm) = 0 raiselastoserror;       bf.blendop := ac_src_over;       bf.blendflags := 0;       bf.sourceconstantalpha := 255;       bf.alphaformat := ac_src_alpha;       if not winalphablend(canvas.handle,         10,         10,         bm.bmwidth,         bm.bmheight,         dc,         0,         0,         bm.bmwidth,         bm.bmheight,         bf) raiselastoserror;           deletedc(dc);     end;       deleteobject(hbm);   end; end; 

using gimp, converted png image

http://privat.rejbrand.se/ratingctrl.png

found here 32-bit rgba bitmap, found here, , result good:

http://privat.rejbrand.se/gdiblend1.png http://privat.rejbrand.se/gdiblend2.png http://privat.rejbrand.se/gdiblend3.png


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -