TBgraBitmap.TakeScreenShot not working on Lazarus 1.x 64 bits - Ubuntu 16.04 lazarus / 39-Graphics ---------------------------------------------------------------------- Jurassic Pork · 2017-07-15 07:25 hello, on Lazarus 1.x 64 bits - Ubuntu 16.04   gtk2 interface with this code : 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 TForm1.Button3Click(Sender: TObject);var MyCapture : TBgraBitmap;var MyArea : TRect;begin  MyArea := Bounds(400,400,500,500);  MyCapture := TBgraBitmap.Create();  MyCapture.TakeScreenShot(MyArea);  MyCapture.SaveToFile('/home/jurassic/MyCapture.png');end;i have this error message when i call TakeScreenShot : 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 Cannot get raw image from device error in this code : 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 TBGRALCLBitmap.LoadFromDevice(DC: System.THandle; ARect: TRect);var  rawImage: TRawImage;begin  if (ARect.Right <= ARect.Left) or (ARect.Bottom <= ARect.Top) then  begin    SetSize(0,0);    exit;  end;  try    if not RawImage_FromDevice(rawImage, DC, ARect) then    raise Exception.Create('Cannot get raw image from device');    SetSize(rawImage.Description.Width, rawImage.Description.Height);    LoadFromRawImage(rawImage,255);  finally    rawImage.FreeData;  end;end; so what is wrong :  it seems that it is the DC pointer type . If in all the files of the tbgrabitmap package, i replace DC : System.THandle by  : DC : PtrUInt TakeScreenshot works. Is it a good idea ? Ami calmant, J.P ---------------------------------------------------------------------- circular · 2017-07-15 11:55 Hi, PtrUInt seems ok, however it may be better to use a type defined for such handes. Apparently, System.THandle is not the right one. Is HDC type available? What about the definition of RawImage_FromDevice, what type is used in its parameters? ---------------------------------------------------------------------- Jurassic Pork · 2017-07-15 12:32 HDC type seems to be defined in lcltype unit (lcltype.pp) : 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 type HDC = type THandle;type THandle = type PtrUInt;  and RawImage_fromdevice seems to use HDC : 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 function RawImage_FromDevice(out ARawImage: TRawImage; ADC: HDC; const ARect: TRect): Boolean; override; may be you can change  some bgrabitmap files. Something like that : Quotefor lctype : bgrabitmap-master/bgrabitmap/bgrabitmaptypes.pas bgrabitmap/bgrabitmaptypes.pas (34,32) Classes, Types, BGRAGraphics,lcltype, bgrabitmap-master/bgrabitmap/bgradefaultbitmap.pas bgrabitmap/bgradefaultbitmap.pas (36,63) BGRACanvas, BGRACanvas2D, BGRAArrow, BGRAPen, BGRATransform,lcltype; bgrabitmap-master/bgrabitmap/bgralclbitmap.pas bgrabitmap/bgralclbitmap.pas (8,42) Classes, SysUtils, Graphics, GraphType,lcltype, BGRABitmapTypes, BGRADefaultBitm... for HDC : bgrabitmap-master/bgrabitmap/bgradefaultbitmap.pas bgradefaultbitmap.pas (903,35) procedure LoadFromDevice({%H-}DC: HDC); override; bgradefaultbitmap.pas (904,35) procedure LoadFromDevice({%H-}DC: HDC; {%H-}ARect: TRect); override; bgradefaultbitmap.pas (6077,41) procedure TBGRAPtrBitmap.LoadFromDevice(DC: HDC); bgradefaultbitmap.pas (6082,41) procedure TBGRAPtrBitmap.LoadFromDevice(DC: HDC; ARect: TRect); bgrabitmap-master/bgrabitmap/bgralclbitmap.pas bgralclbitmap.pas (31,35) procedure LoadFromDevice({%H-}DC: HDC); override; bgralclbitmap.pas (32,35) procedure LoadFromDevice({%H-}DC: HDC; {%H-}ARect: TRect); override; bgralclbitmap.pas (878,41) procedure TBGRALCLBitmap.LoadFromDevice(DC: HDC); bgralclbitmap.pas (900,41) procedure TBGRALCLBitmap.LoadFromDevice(DC: HDC; ARect: TRect); bgrabitmap-master/bgrabitmap/bgracustombitmap.inc bgracustombitmap.inc (390,31) procedure LoadFromDevice(DC: HDC); virtual; abstract; overload; bgracustombitmap.inc (392,31) procedure LoadFromDevice(DC: HDC; ARect: TRect); virtual; abstract; overload; ---------------------------------------------------------------------- circular · 2017-07-17 18:10 Ok. I applied changes following this idea in "dev-bgrabitmap" branch. Does it fix the problem? ---------------------------------------------------------------------- Jurassic Pork · 2017-07-17 22:36 hello, thanks circular, i have downloaded the dev-bgrabitmap version of bgrapbitmap. It seems to be OK for the TakeScreenshot function on Ubuntu 16.04  64 bits Lazarus 1.8RC3 64 bits. Ami calmant, J.P