uses
LclIntf, FPImage, FPCanvas, IntfGraphics, LazCanvas;
function CreateRadioButtonBitmap(ASize: Integer; Checked: Boolean): TBitmap;
var
img1, img2: TLazIntfImage;
canvas1, canvas2: TLazCanvas;
R: TRect;
i, n: Integer;
begin
Result := TBitmap.Create;
Result.PixelFormat := pf32Bit;
Result.SetSize(ASize, ASize);
img1 := Result.CreateIntfImage;
try
img1.Width := 2*ASize;
img1.Height := 2*ASize;
canvas1 := TLazCanvas.Create(img1);
try
canvas1.Clear;
R := Rect(0, 0, img1.Width-1, img1.Height-1);
canvas1.Pen.Width := 1;
canvas1.Pen.FPColor := colGray;
canvas1.Brush.Style := bsClear;
canvas1.Brush.FPColor := colWhite;
n := ASize div 8;
for i:= 1 to n do
begin
if i = n then
canvas1.Brush.Style := bsSolid;
canvas1.Ellipse(R);
InflateRect(R, -1, -1);
end;
if Checked then
begin
InflateRect(R, -ASize div 4, -ASize div 4);
canvas1.Brush.Style := bsSolid;
canvas1.Brush.FPColor := colBlue;
canvas1.Ellipse(R);
end;
finally
canvas1.Free;
end;
img2 := Result.CreateIntfImage;
try
canvas2 := TLazCanvas.Create(img2);
try
canvas2.Interpolation := TFPBaseInterpolation.Create;
try
canvas2.StretchDraw(0, 0, ASize, ASize, img1);
Result.LoadFromIntfImage(img2);
finally
canvas2.Interpolation.Free;
end;
finally
canvas2.Free;
end;
finally
img2.Free;
end;
finally
img1.Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
RadioBtnChecked_Bmp := CreateRadioButtonBitmap(16, true);
RadioBtnUnchecked_Bmp := CreateRadioButtonBitmap(16, false);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
RadioBtnChecked_Bmp.Free;
RadioBtnUnchecked_Bmp.Free;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
Canvas.Draw(10, 10, RadioBtnChecked_bmp);
Canvas.Draw(10, 50, RadioBtnUnchecked_bmp);
end;