2
에 숫자를 그리려면 요구 사항이 입니다.이 숫자는 자동으로 변경됩니다 .Delphi 7에서 이미지를 동적으로 만들 수 있습니까? 아무도 제게 제안 해주세요.이미지에 숫자를 그리는 방법 Delphi 7
내 용 Rakesh.
는에 숫자를 그리려면 요구 사항이 입니다.이 숫자는 자동으로 변경됩니다 .Delphi 7에서 이미지를 동적으로 만들 수 있습니까? 아무도 제게 제안 해주세요.이미지에 숫자를 그리는 방법 Delphi 7
내 용 Rakesh.
는이 절차에게 이미지
procedure GenerateImageFromNumber(ANumber:Integer;Const FileName:string);
Var
Bmp : TBitmap;
begin
Bmp:=TBitmap.Create;
try
Bmp.PixelFormat:=pf24bit;
Bmp.Canvas.Font.Name :='Arial';// set the font to use
Bmp.Canvas.Font.Size :=20;//set the size of the font
Bmp.Canvas.Font.Color:=clWhite;//set the color of the text
Bmp.Width :=Bmp.Canvas.TextWidth(IntToStr(ANumber));//calculate the width of the image
Bmp.Height :=Bmp.Canvas.TextHeight(IntToStr(ANumber));//calculate the height of the image
Bmp.Canvas.Brush.Color := clBlue;//set the background
Bmp.Canvas.FillRect(Rect(0,0, Bmp.Width, Bmp.Height));//paint the background
Bmp.Canvas.TextOut(0, 0, IntToStr(ANumber));//draw the number
Bmp.SaveToFile(FileName);//save to a file
finally
Bmp.Free;
end;
end;
을
검사를 텍스트를 그릴 그리고이
procedure TForm1.Button1Click(Sender: TObject);
begin
GenerateImageFromNumber(10000,'Foo.bmp');
Image1.Picture.LoadFromFile('Foo.Bmp');//Image1 is a TImage component
end;
내가 GenerateImageFromNumber있을 것 (처럼 사용하기
TBitmap
의 Canvas 속성을 사용할 수 있습니다)는 임시 파일을 전혀 사용하지 않고 TImage에 할당되거나 직접 TImage에 그려지는 TBitmap을 반환합니다. –감사합니다 ...! – rakesh
@rakesh, 이것이 문제를 해결하면 RRUZ의 대답을 받아 들여야합니다. –