Created
November 22, 2019 10:52
-
-
Save HemulGM/0f9e1888ad25272319fe83e1cce37cd1 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
function CreateAvatar(Source: TGraphic; Mask: TPngImage): TPngImage; | |
var | |
BMPSmooth: TBitmap; | |
Av: TPngImage; | |
begin | |
BMPSmooth := SmoothStrechDraw(Source, TSize.Create(Mask.Width, Mask.Height)); | |
Result := TPngImage.CreateBlank(COLOR_RGB, 16, Mask.Width, Mask.Height); | |
Result.Canvas.Draw(0, 0, BMPSmooth); | |
with TDirect2DCanvas.Create(Result.Canvas, Rect(0, 0, Mask.Width, Mask.Height)) do | |
begin | |
BeginDraw; | |
Brush.Style := bsClear; | |
Pen.Width := 3; | |
Pen.Color := $0081B543; | |
Ellipse(Rect(0, 0, Mask.Width - 1, Mask.Height - 1)); | |
EndDraw; | |
Free; | |
end; | |
BMPSmooth.Free; | |
Result.CreateAlpha; | |
ApplyMask(0, 0, Mask, Result); | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment