Графика
Модератор: Модераторы
Графика
Как заполнить PaintBox пикселями произвольного цвета? В делфи есть функция Scanline, есть ли в Лазарусе что либо похожее?
Посмотри пример в lazarus/examples/scanline
Сделал во так:
Но работает довольно медленно.
Есть способы как то ускорить вывод картинки?
Код: Выделить всё
procedure TForm1.Button1Click(Sender: TObject);
var
MyBitmap: TBitmap;
x,y: Integer;
ScanLineImage: TLazIntfImage;
IntfImage: TLazIntfImage;
ImgFormatDescription: TRawImageDescription;
begin
MyBitmap:=TBitmap.Create;
ScanLineImage:=TLazIntfImage.Create(0,0);
ImgFormatDescription.Init_BPP32_B8G8R8_BIO_TTB(1000,1000);
ScanLineImage.DataDescription:=ImgFormatDescription;
for y:=0 to 999 do
begin
for x:=0 to 999 do
begin
PByte(ScanLineImage.GetDataLineStart(y))[x*4+0]:=250; //B
PByte(ScanLineImage.GetDataLineStart(y))[x*4+1]:=250; //G
PByte(ScanLineImage.GetDataLineStart(y))[x*4+2]:=250; //R
end;
end;
// create IntfImage with the format of the current LCL interface
MyBitmap.Width:=ScanLineImage.Width;
MyBitmap.Height:=ScanLineImage.Height;
IntfImage:=MyBitmap.CreateIntfImage;
// convert the content from the very specific to the current format
IntfImage.CopyPixels(ScanLineImage);
MyBitmap.LoadFromIntfImage(IntfImage);
form1.PaintBox1.Canvas.Draw(10,10,MyBitmap);
ScanLineImage.Free;
IntfImage.Free;
MyBitmap.Free;
end; Но работает довольно медленно.
Есть способы как то ускорить вывод картинки?
