Recent

Author Topic: Draw Directly on TBitmap  (Read 3766 times)

trayres

  • Jr. Member
  • **
  • Posts: 92
Draw Directly on TBitmap
« on: March 28, 2016, 07:49:22 am »
Code: Pascal  [Select][+][-]
  1. var bmp: TBitmap;
  2.  
  3. begin
  4. bmp := TBitmap.Create;
  5. bmp.SetSize(600,600); <- This is causing a segfault
  6. {Draw some stuff}
  7. end.
  8.  

In file lclintf.inc at line 177:
Result:=WidgetSet.RawImage_QueryDescription(AFlags,ADesc);

This looks a lot like example code from Delphi; I think something isn't being initialized correctly?

I started from a simple console project, and added LCL as a required package to get the Graphics module.

Any thoughts all?
Thanks!

JZS

  • Full Member
  • ***
  • Posts: 205
Re: Draw Directly on TBitmap
« Reply #1 on: March 28, 2016, 11:28:29 am »
With Lazarus 1.6 on Windows this piece of code compiles/runs successfully.

Probably you need to mention the version you are using, and on which platform!
I use recent stable release

Leledumbo

  • Hero Member
  • *****
  • Posts: 8799
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Draw Directly on TBitmap
« Reply #2 on: March 28, 2016, 01:35:01 pm »
This looks a lot like example code from Delphi; I think something isn't being initialized correctly?

I started from a simple console project, and added LCL as a required package to get the Graphics module.
Nah, Delphi doesn't have widgetset concept. The missing thing is Interfaces unit, since the code queries underlying widgetset which won't exist if you omit Interfaces from uses clause.

Handoko

  • Hero Member
  • *****
  • Posts: 5425
  • My goal: build my own game engine using Lazarus
Re: Draw Directly on TBitmap
« Reply #3 on: March 28, 2016, 01:54:25 pm »
It works on my Lazarus installation. Just as Leledumbo said, Lazarus is not Delphi. You better start your new project by clicking: menu > File > New > Application. By doing that, it will automatically put necessaries units in the uses clause.

Or you can simply download my sample project for testing

trayres

  • Jr. Member
  • **
  • Posts: 92
Re: Draw Directly on TBitmap
« Reply #4 on: April 01, 2016, 06:30:45 pm »
This looks a lot like example code from Delphi; I think something isn't being initialized correctly?

I started from a simple console project, and added LCL as a required package to get the Graphics module.
Nah, Delphi doesn't have widgetset concept. The missing thing is Interfaces unit, since the code queries underlying widgetset which won't exist if you omit Interfaces from uses clause.

This was exactly the problem. Thank you! Adding the Interfaces unit solved it, and now I know how to get an LCL program running without going through the wizard (so I have a better idea of what's going on).

Much appreciated!

 

TinyPortal © 2005-2018