I recently changes to a new notebook and facing very slow graphics with a project using TBitmap.
The same project is running on my other computer like a charme.
I don't have any problems with
any ohter programm on that notebook.
Scanling a 4896x3264 pixel picture to 580x350 pixel with CopyRect or StretchDraw takes over 20 seconds!
Has anybody an idea how to solve this problem?
procedure TForm1.Button1Click(Sender: TObject);
var
SourceJpg: TJpegImage; // Source image
Bitmap1: TBitmap; // Original bitmap
Bitmap2: TBitmap; // Target bitmap
Rect1: TRect; // Original Rect
Rect2: TRect; // Target Rect
begin
// Load SourceJpg from file
Label1.Caption := 'Load SourceJpg...';
Label1.Refresh;
SourceJpg := TJpegImage.Create;
SourceJpg.LoadFromFile('./Julia.jpg');
// Assign SourceJpg to a bitmap
Label1.Caption := 'Assign SourceJpg...';
Label1.Refresh;
Bitmap1 := TBitmap.Create;
Bitmap1.Assign(SourceJpg);
// Show bitmap without scaling
Label1.Caption := 'Show bitmap without scaling...';
Label1.Refresh;
Image1.Canvas.Draw(0, 0, Bitmap1);
// Size of original bitmap
Rect1.Create(0, 0, Bitmap1.Width, Bitmap1.Height);
// Create the target bitmap
Bitmap2 := TBitmap.Create;
Bitmap2.SetSize(580, 350);
// Size of target bitmap
Rect2.Create(0, 0, Bitmap2.Width, Bitmap2.Height);
// Draw a scaled bitmap to the target bitmap
Label1.Caption := 'Draw a scaled bitmap to the target...';
Label1.Refresh;
Bitmap2.Canvas.CopyRect(Rect2, Bitmap1.Canvas, Rect1);
// Show scaled bitmap
Label1.Caption := 'Show scaled bitmap.';
Label1.Refresh;
Image1.Canvas.Draw(0, 0, Bitmap2);
//Label1.Caption := 'Show as stretched bitmap.';
//Label1.Refresh;
//Image1.Canvas.StretchDraw(Rect2, Bitmap1);
end;
Some infos about the notebook:
ComputerProzessor Intel(R) Celeron(R) N4100 CPU @ 1.10GHz
Hauptspeicher 3856MB (489MB used)
Maschinen-Typ Laptop
Betriebssystem Ubuntu 19.04
Benutzername maik (maik)
Date/Time Sa 13 Jul 2019 16:38:57 CEST
AnzeigeAuflösung 1366x768 pixels
OpenGL-Renderer Mesa DRI Intel(R) UHD Graphics 600 (Geminilake 2x6)
X11-Hersteller The X.Org Foundation
Audio-Geräte
Audio Adapter HDA-Intel - HDA Intel PCH
Audio Adapter ThinkPad EC - ThinkPad Console Audio Control