Created
February 26, 2017 17:29
-
-
Save JordiCorbilla/b4eb68aa9cbb1b30a6f1fff457ef628e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 TForm1.PaintImage(index: integer; value : string; rows, columns : integer); | |
var | |
image : Timage; | |
i, j, k : integer; | |
MyRect: TRectF; | |
begin | |
image := GetImage(index); | |
//start painting | |
image.Canvas.BeginScene; | |
k := 1; | |
for i := 0 to rows-1 do | |
begin | |
for j := 0 to columns-1 do | |
begin | |
if value[k] = '1' then | |
image.Canvas.Fill.Color := TAlphaColors.Lime | |
else | |
image.Canvas.Fill.Color := TAlphaColors.Black; | |
inc(k); | |
image.Canvas.Stroke.Color := TAlphaColors.Green; | |
image.Canvas.Stroke.Thickness := 0; | |
//Use LocalToAbsolute to paint within the boundaries of TImage and not the form canvas! | |
MyRect := TRectF.Create(image.LocalToAbsolute(TPointF.Create(round(((i)*image.Width)/rows), round(((j)*image.Height)/rows))), round((image.Width)/rows), round((image.Height)/rows)); | |
image.Canvas.FillRect(MyRect, 0, 0, AllCorners, 1); | |
end; | |
end; | |
image.Canvas.EndScene; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment