Last active
November 22, 2019 08:32
-
-
Save HemulGM/027c13456f751dc052670fef4a10494c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
procedure TForm14.FormCreate(Sender: TObject); | |
var | |
Pic: TPicture; | |
PNG, FStatusMask, FOver: TPngImage; | |
function CreateAvatar(Source: TGraphic; Mask: TPngImage): TPngImage; | |
var | |
BMPSmooth: TBitmap; | |
Av: TPngImage; | |
begin | |
BMPSmooth := SmoothStrechDraw(Source, TSize.Create(Mask.Width, Mask.Height)); | |
Av := TPngImage.CreateBlank(COLOR_RGB, 16, Mask.Width, Mask.Height); | |
Av.Canvas.Draw(0, 0, BMPSmooth); | |
BMPSmooth.Free; | |
Av.CreateAlpha; | |
ApplyMask(0, 0, Mask, Av); | |
Result := TPngImage.CreateBlank(COLOR_RGBALPHA, 16, Mask.Width, Mask.Height); | |
DrawTo(0, 0, FOver, Result); | |
DrawTo(0, 0, Av, Result); | |
Av.Free; | |
end; | |
begin | |
FStatusMask := TPngImage.Create; | |
FStatusMask.LoadFromFile('mask.png'); | |
FOver := TPngImage.Create; | |
FOver.LoadFromFile('mask_over.png'); | |
Pic := TPicture.Create; | |
Pic.LoadFromFile('sample.png'); | |
PNG := CreateAvatar(Pic.Graphic, FStatusMask); | |
ImageAvatar.Picture.Assign(PNG); | |
PNG.Free; | |
Pic.Free; | |
FOver.Free; | |
FStatusMask.Free; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment