Advertisement
TLama

Untitled

Mar 14th, 2013
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.73 KB | None | 0 0
  1. uses
  2.   GdiPlus;
  3.  
  4. type
  5.   TOpacity = 0..100;
  6.  
  7. procedure GDIPAlphaBlend(const FileName: string; Destination: TCanvas;
  8.   const X, Y: Integer; const Opacity: TOpacity = 100);
  9. var
  10.   GPImage: IGPImage;
  11.   GPGraphics: IGPGraphics;
  12.   GPColorMatrix: TGPColorMatrix;
  13.   GPImageAttributes: IGPImageAttributes;
  14. begin
  15.   GPImage := TGPImage.Create(FileName);
  16.  
  17.   GPColorMatrix.SetToIdentity;
  18.   GPColorMatrix.M[3, 3] := Opacity / 100;
  19.   GPImageAttributes := TGPImageAttributes.Create;
  20.   GPImageAttributes.SetColorMatrix(GPColorMatrix);
  21.  
  22.   GPGraphics := TGPGraphics.Create(Destination.Handle);
  23.   GPGraphics.DrawImage(GPImage, X, Y, GPImage.Width, GPImage.Height, 0, 0,
  24.     GPImage.Width, GPImage.Height, UnitPixel, GPImageAttributes);
  25. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement