CopyRect not working under Linux? lazarus / 39-Graphics ---------------------------------------------------------------------- han · 2017-12-07 22:37 I working on a code conversion from Windows to Linux and have an odd problem I can't fix. The program works with images and requires a horizontal and vertical flip of an Timage. It works in Window but not under Linux (fpc 3.0.2 and 3.0.4). I have impression the CopyRect doesn't work. Below my routine. Why doesn't it work in Linux and how to fix? procedure Tmainwindow.Fliphorizontal1Click(Sender: TObject); var src, dest: TRect;     bmp: TBitmap;     w, h: integer; begin   w:=image1.Picture.Width; h:=image1.Picture.Height;   dest:=bounds(0, 0, w, h);   //src:=rect(0, h, w, 0); // Vertical flip   src:=rect(w, 0, 0, h); // Horizontal flip   //src:=rect(w, h, 0, 0); // Both flip   bmp:=TBitmap.Create;   bmp.PixelFormat:=pf24bit;   bmp.SetSize(w, h);   bmp.Canvas.Draw(0, 0, image1.Picture.Bitmap);   image1.Picture.Bitmap.Canvas.CopyRect(dest, bmp.Canvas, src);   bmp.Free; end; ---------------------------------------------------------------------- Blaazen · 2017-12-07 23:22 Hi, this works under Linux (Qt): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   ...  dest:=rect(w, 0, 0, h);  image1.Picture.Bitmap.Canvas.StretchDraw(dest, bmp); ---------------------------------------------------------------------- han · 2017-12-08 07:53 Yes that works!. I'm not a fan of StrechDraw since it can result in distortions. The application is an astronomical application and should be correct on subpixel level. Later, I found a way to fix the CopyRect routine: This works only in MS-Windows Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  src:=rect(w, 0, 0, h);  dest:=bounds(0, 0, w, h); This works both in MS-Windows and Linux: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i src:=rect(0, 0, w, h);dest:=rect(w, 0, 0, h);//horizontal flip Weird, is this a bug? This is the new procedure working both in MS-Windows and Linux: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure Tmainwindow.Fliphorizontal1Click(Sender: TObject);var src, dest: TRect;    bmp: TBitmap;    w, h: integer;begin  w:=image1.Picture.Width; h:=image1.Picture.Height;  src:=rect(0, 0, w, h);  dest:=rect(w, 0, 0, h);//horizontal flip  bmp:=TBitmap.Create;  bmp.PixelFormat:=pf24bit;  bmp.SetSize(w, h);  bmp.Canvas.Draw(0, 0, image1.Picture.Bitmap);  image1.Picture.Bitmap.Canvas.CopyRect(dest, bmp.Canvas, src);  bmp.Free;end; ---------------------------------------------------------------------- han · 2017-12-08 09:33 The same effect with StretchDraw if line 13 is replaced with:      image1.Picture.Bitmap.Canvas.StretchDraw(dest, bmp);    Is this a different behavior inside Linux? ---------------------------------------------------------------------- Blaazen · 2017-12-08 16:27 Yes, both CopyRect and StrechDraw work in Linux now. I don't if that trick of swapping Src and Dest rectangles is a bug, although.