[SOLVED] SIGSEGV in TBitmap.SetSize lazarus / 39-Graphics ---------------------------------------------------------------------- VitalArt · 2018-02-06 03:50 Good time of day, So I needed to use the TBitMap class to create/edit a picture (it is supposed to be passed to tAgg2d.Attach). I used roughly the following 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 uses Graphics; var   img: tbitmap;   a: tAgg2d; begin   a:= tAgg2d.Create;   img:= tbitmap.Create;    //img.LoadFromFile('pic.bmp'); {if you call this, everything works fine}      img.SetSize(500,500); {SIGSEGV in RawImage_QueryDescription}      img.BeginUpdate;    Agg2D.Attach(img);   //draw stuff with agg2d     img.EndUpdate;   img.SaveToFile('pic2.bmp'); end. But it when I call Setsize, which calls several more functions, I get a SIGSEGV in iclude/lclintf.inc at line 177 which is: 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 Result := WidgetSet.RawImage_QueryDescription(AFlags, ADesc); The WidgetSet variable appears to be nil, which is understandable, since I don't use LCL for anything else. What is interesting is that if I call img.LoadFromFile before img.SetSize everything works fine: no SIGSEGV, stuff gets drawn. So my question is: can I avoid this SIGSEGV without calling LoadFromFile? I don't want to have to include the whole LCL into my project either. For the record, I tried to recreate this situation in a separate project, but failed due to 'graphics.pp(20,2) Fatal: Cannot open include file "lcl_defines.inc" ' even though Lazarus opens it fine and it compiles without problems in my main project. My apologies for this potentially being a really dumb/involved question. ---------------------------------------------------------------------- Josh · 2018-02-06 04:41 Hi Not by machine at the moment; but I remember that I had to use .clear before I resized a bitmap like that ie 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 a:= tAgg2d.Create;img:= tbitmap.Create;img.clear;img.SetSize(500,500); ---------------------------------------------------------------------- VitalArt · 2018-02-06 16:19 Unfortunately, I've tried that before, and it didn't work. Fortunately, I've stumbled onto this thread through google: http://forum.lazarus.freepascal.org/index.php?topic=32088.0 Unfortunately, when I try to add the Interfaces unit to my project, it fails to build again with some bizarre error messages. It says:  'win32int.pp(8,84) Fatal: Cannot find Win32Int used by Interfaces, incompatible ppu=C:\lazarus\lcl\units\x86_64-win64\win32\win32int.ppu, package LCL'. When I click on the error message, it shows another path to the 'not found' file, which is the root directory of my project, but I just assume that's where it looks after it decides the one in lcl/units doesn't suit it. From what I remember, this happens when the unit was built with another FPC version. But this can't be, since I just reinstalled Lazarus from scratch and I've recompiled LCL... What gives? I even tried adding LCL to my project, but even that doesn't help... But when I create a new project and select 'Application' there's no problem. If I remember correctly, my original project was created with the option 'Program'. Maybe there's some hidden option that causes that behaviour? Edit: problem solved here: https://forum.lazarus.freepascal.org/index.php/topic,39998.0.html