Recent

Author Topic: [SOLVED] SIGSEGV in TBitmap.SetSize  (Read 2624 times)

VitalArt

  • New Member
  • *
  • Posts: 26
[SOLVED] SIGSEGV in TBitmap.SetSize
« on: February 06, 2018, 04:50:27 am »
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][+][-]
  1. uses Graphics;
  2.  
  3. var
  4.    img: tbitmap;
  5.    a: tAgg2d;
  6.  
  7. begin
  8.    a:= tAgg2d.Create;
  9.    img:= tbitmap.Create;
  10.  
  11.    //img.LoadFromFile('pic.bmp'); {if you call this, everything works fine}
  12.    
  13.    img.SetSize(500,500); {SIGSEGV in RawImage_QueryDescription}
  14.    
  15.    img.BeginUpdate;
  16.  
  17.    Agg2D.Attach(img);
  18.    //draw stuff with agg2d
  19.  
  20.    img.EndUpdate;
  21.    img.SaveToFile('pic2.bmp');
  22. end.
  23.  

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][+][-]
  1. Result := WidgetSet.RawImage_QueryDescription(AFlags, ADesc);
  2.  

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.
« Last Edit: February 07, 2018, 05:42:35 pm by VitalArt »

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: SIGSEGV in TBitmap.SetSize
« Reply #1 on: February 06, 2018, 05:41:03 am »
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][+][-]
  1. a:= tAgg2d.Create;
  2. img:= tbitmap.Create;
  3. img.clear;
  4. img.SetSize(500,500);
  5.  
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

VitalArt

  • New Member
  • *
  • Posts: 26
Re: SIGSEGV in TBitmap.SetSize
« Reply #2 on: February 06, 2018, 05:19:20 pm »
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
« Last Edit: February 07, 2018, 05:43:34 pm by VitalArt »

 

TinyPortal © 2005-2018