Author Topic: 2D Flowchart  (Read 21337 times)


  • Hero Member
  • *****
  • Posts: 2513
Re: 2D Flowchart
« Reply #30 on: August 16, 2014, 07:47:25 pm »
After DrawStuff(agg), Buf holds the data of the image. Convert the data to the pixel format of your destination. Here is some code you can use to test it on a TImage:
Code: [Select]
 ..., ExtCtrls, Graphics;
procedure BufToImage(const buf:array of int8; image: TImage);
  pdst: PByte;
  psrc: PCardinal;
  x, y: Integer;
  c: TColor;
  sizeOfOneRowInBytes: cardinal;
  image.Picture.Bitmap.SetSize(ImageWidth, ImageHeight);

  //support for pf24bit or pf32bit pixel formats
  sizeOfOnePixelInBytes := PIXELFORMAT_BPP[image.Picture.Pixmap.PixelFormat] div 8;// 3 or 4 bytes
  sizeOfOneRowInBytes := ImageWidth * sizeOfOnePixelInBytes;

  pdst := image.Picture.Bitmap.RawImage.Data+sizeOfOneRowInBytes*(ImageHeight-1);
  psrc := @buf[0];
  for y := 0 to ImageHeight - 1 do
    for x := 0 to ImageWidth - 1 do
      //switch places between red and blue bytes;
      c := (psrc^ and $0000FF00) or (RolDWord(psrc^, 16) and $00FF00FF);
      PCardinal(pdst)^ := psrc^;

      inc(pdst, sizeOfOnePixelInBytes);
      inc(psrc, 1);
    dec(pdst, 2*sizeOfOneRowInBytes);

It works for me on Windows.


  • Hero Member
  • *****
  • Posts: 1430
    • Graeme on the web
Re: 2D Flowchart
« Reply #31 on: August 17, 2014, 02:10:51 am »
Keep in mind that I am new to FPC, how do I get started with fpGUI w/Aggpas on a TForm? Do you have any getting started turorial?
There is no "getting started" tutorial, but I am working on one. I've already got various chapter ideas and some text down.

Do you already understand how to create a basic fpGUI application? If not, take a look at the <fpgui>/examples/gui/ directory for many small demos. If you are using Lazarus IDE, you can register a new project type by installing <fpgui>/extras/lazarus_ide/fpgui_ide.lpk package. An fpGUI project can then be created by going to "File -> New... -> Project -> fpGUI Application". All applications and demos included with fpGUI contains Lazarus Project files, so you can just open and compile them too.

Using AggPas with fpGUI.
There are two options.

1.  There is experimental support which makes AggPas the default backend for fpGUI - thus any existing fpGUI application will automatically use AggPas. Everything is then painted with AggPas and you use the TfpgCanvas as normal. After enough testing this will eventually become the default backend on all platforms. To enable this you need to enable the AggCanvas compiler define in the fpgui_toolkit.lpk package and recompile that package. Open the package then go to its Compiler Options -> Other and remove the "X" after the line -dAggCanvas

2.  Alternatively you can use the normal X11 or GDI backends of fpGUI, and only use AggPas to paint to a bitmap which you can then paint somewhere on the screen (or save to a file). Do do this, create an instance of TAgg2D and create a instance of TfpgImage. The image will become the output buffer of whatever you paint with AggPas. To tell TAgg2D about the image, call the TAgg2D.Attach() method. Now simply paint using the available methods of the TAgg2D class. Documentation for the TAgg2D class can be found at <fpgui>/docs/aggpas/agg2d.html

I hope this is enough to get you started. If you want more support don't hesitate to ask. You can also join the official fpGUI support newsgroup where more people will be able to answer and learn from your questions. Details connecting the newsgroup can be found there []
« Last Edit: August 17, 2014, 02:16:19 am by Graeme Geldenhuys »
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal


  • Jr. Member
  • **
  • Posts: 76
Re: 2D Flowchart
« Reply #32 on: August 22, 2014, 05:04:48 am »
Thanks for this and all the help so far.

At present I decided to ignore presentation quality because I have my own TZoomCanvas that easily can be modified to use something else than core LCL to draw graphics later.

I create diagrams with a special functionality, and it's more important to get the engine up running for now so I can move on to what I wanna use it for - it also leaves the doors open so that people who favor BGRABitmap, fpGUI or other libraries easily can do a minor port later.


TinyPortal © 2005-2018