Recent

Author Topic: save output aggpas to png and install problems  (Read 22870 times)

K.Bleijenberg

  • New Member
  • *
  • Posts: 14
save output aggpas to png and install problems
« on: January 10, 2014, 10:27:46 am »
In a command line application I want to create a few images, draw rectangles, text etc and save them as png. I don't want dependency on LCL. Is this possible with aggpas?

I tried to install aggpas:
The OS is Ubuntu 64 bits.
Lazarus version 1.0.10

I save the source of aggpas in a map. I create a new project and added agg2D.pas. Add dependency LCLBase (the only dependency). The compiler stops while parsing agg_font_win32_tt. It cannot find the unit windows. Of course this is linux.
I changed the target in the IDE to Linux. No luck.
Someone suggested to add {$include agg_mode.inc} above the uses clause  => no luck.

What can I do?
 

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: save output aggpas to png and install problems
« Reply #1 on: January 10, 2014, 11:33:40 am »
Please take a look at this page:
http://www.crossgl.com/aggpas/aggpas-download.htm
There are 3 different versions of AggPas: for Windows, for Linux and for Mac. This probably means that AggPas library is not meant to use like some other libraries: one package for all systems. It has a separate package for each system instead. Please check if you have package for Linux
Too late to escape fate

K.Bleijenberg

  • New Member
  • *
  • Posts: 14
Re: save output aggpas to png and install problems
« Reply #2 on: January 10, 2014, 11:52:27 am »
Please take a look at this page:
http://www.crossgl.com/aggpas/aggpas-download.htm
There are 3 different versions of AggPas: for Windows, for Linux and for Mac. This probably means that AggPas library is not meant to use like some other libraries: one package for all systems. It has a separate package for each system instead. Please check if you have package for Linux

I've downloaded the source from this page and unpacked the tar.gz for Linux to a directory and got the described problems.

Kees

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: save output aggpas to png and install problems
« Reply #3 on: January 10, 2014, 12:25:30 pm »
I happen to work on a project in which I will probably use AggPas as well; and it should work on Ubuntu 64 bit as well, so maybe I will try to build it on my PC later today and see if it works
Too late to escape fate

K.Bleijenberg

  • New Member
  • *
  • Posts: 14
Re: save output aggpas to png and install problems
« Reply #4 on: January 10, 2014, 03:20:47 pm »
I happen to work on a project in which I will probably use AggPas as well; and it should work on Ubuntu 64 bit as well, so maybe I will try to build it on my PC later today and see if it works

That would be nice!

Kees

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: save output aggpas to png and install problems
« Reply #5 on: January 10, 2014, 06:35:25 pm »
I managed to compile AGG on Ubuntu Linux 64 bit; I didn't have problems with Windows unit... However it seems that such easy task like drawing an image in memory and saving it to PNG file is very hard to accomplish with AggPas because it does not have any routines for exporting images to file..... The only way one could possibly do this is to attach TAgg2D instance to a bitmap from Graphics unit from LCL, then export the image using LCL units & routines
« Last Edit: January 10, 2014, 06:37:13 pm by hinst »
Too late to escape fate

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: save output aggpas to png and install problems
« Reply #6 on: January 10, 2014, 06:50:28 pm »
Take a look at this sample plz:
http://wiki.freepascal.org/fcl-image#Basic_Canvas_Setup
looks like exactly what we need. One can render an image in memory and save it to file using fcl-image package; so external packages like AggPas are not even necessary
Too late to escape fate

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: save output aggpas to png and install problems
« Reply #7 on: January 11, 2014, 11:46:17 am »
In a command line application I want to create a few images, draw rectangles, text etc and save them as png. I don't want dependency on LCL. Is this possible with aggpas?
Yes it is possible. Simply copy the raw image buffer data to a FCL-Image container (eg: PNG, JPG etc), then save it to file.

BTW: The original open sourced AggPas is a bit out of date. I have made some changes and bug fixes in AggPas included with fpGUI. You can get the latest AggPas code here [https://github.com/fredvs/fpGUI/tree/master/src/corelib/render/software]

Incidentally, the fpGUI repository contains some Agg/AggPas documentation too. There is a demo using pure AGG API (no other GUI dependencies) and shows how it writes the image buffer to a file. As I mentioned above, simple copy the image buffer to a FCL-Image container of choice, and write it to another image file format. See <fpgui>/docs/aggpas/basic_renderers.agdoc.html
« Last Edit: January 11, 2014, 11:57:23 am by Graeme Geldenhuys »
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: save output aggpas to png and install problems
« Reply #8 on: January 11, 2014, 11:55:52 am »
Indecently, the fpGUI repository contains some Agg/AggPas documentation too.

We presume you meant "incidentally" ;D

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: save output aggpas to png and install problems
« Reply #9 on: January 11, 2014, 11:58:01 am »
Well, I can understand the use of "indecently" when comparing the documentation effort of typical open source code (yes, looking at myself, too).

Anyway, indecent documentation is far more likely to be remembered well than staid, boring, middle of the road documentation ;)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: save output aggpas to png and install problems
« Reply #10 on: January 11, 2014, 11:58:36 am »
We presume you meant "incidentally" ;D

Fixed, thanks! [I'm still busy with my first cup of coffee, so not fully awake yet]    ;)
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: save output aggpas to png and install problems
« Reply #11 on: January 11, 2014, 12:00:06 pm »
Anyway, indecent documentation is far more likely to be remembered well than staid, boring, middle of the road documentation ;)
ROFL   :D
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

K.Bleijenberg

  • New Member
  • *
  • Posts: 14
Re: save output aggpas to png and install problems
« Reply #12 on: January 12, 2014, 01:14:01 pm »
In a command line application I want to create a few images, draw rectangles, text etc and save them as png. I don't want dependency on LCL. Is this possible with aggpas?
Yes it is possible. Simply copy the raw image buffer data to a FCL-Image container (eg: PNG, JPG etc), then save it to file.

BTW: The original open sourced AggPas is a bit out of date. I have made some changes and bug fixes in AggPas included with fpGUI. You can get the latest AggPas code here [https://github.com/fredvs/fpGUI/tree/master/src/corelib/render/software]

Incidentally, the fpGUI repository contains some Agg/AggPas documentation too. There is a demo using pure AGG API (no other GUI dependencies) and shows how it writes the image buffer to a file. As I mentioned above, simple copy the image buffer to a FCL-Image container of choice, and write it to another image file format. See <fpgui>/docs/aggpas/basic_renderers.agdoc.html

I' ve downloaded the new version of aggpas and compiled it. No problems. I' ve read the part of the docs. The code is in cpp, I do not fully understand it, but.... my general idea for the program is:
1. create a TAgg2D
2 create a memory - TfpgImage and attach the Tagg2D to the TfpgImage
3. do the drawing with the methods of the TAgg2D
4. get the pointer to the memory of the memory-TfgpImage
5. create a TFPMemoryImage and fill all pixels with the pixels from the TAgg2D
6. save the TFpMemoryImage to png.

Is this correct?

At step 2, I have a problem. I've found functions like CreateImage_BMP (in fpg_imgfmt_bmp). This function creates a TfpgImage. If I want to work in the same direction as in the docs I need a function CreateImage_PPM.
The memorybuffer is then a PPM buffer and not a bmp structure.

Please help.

Kees

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: save output aggpas to png and install problems
« Reply #13 on: January 12, 2014, 03:31:10 pm »
as far as I know: all fpgui units depend on either WinAPI GUI routines or X library on Linux, so in case you plan to use your application on server-only PC which has no X library installed, it is best not to use fpgui units at all.
Quote
...simple copy the image buffer to a FCL-Image container of choice...
I think that using fpgui routines is not what he meant. Perhaps one should copy image from agg-pas render-buffer object to TFPMemoryImage instance

Create agg-2d render buffer (I don't remember the class name now);
Draw;
Create TFPMemoryImage;
Copy agg render buffer pixels to TFPMemoryImage instance;
Save TFPMemoryImage to png;

;; do not use fpgui routines; the only thing you want from fpgui here is AggPas library with latest bug fixes applied to it
Too late to escape fate

benohb

  • Full Member
  • ***
  • Posts: 213
Re: save output aggpas to png and install problems
« Reply #14 on: January 12, 2014, 04:52:24 pm »
There

http://wiki.freepascal.org/fcl-image

and

http://imaginglib.sourceforge.net/index.php?page=about


if aggpas ...you can use  aggpas with "Vampyre Imaging Library" for save as more format

=From my project=
Here I use cairo surface ...you can do this with aggpas

Code: [Select]
InitImage(Img);
NewImage(cairo_image_surface_get_width(fc1),cairo_image_surface_get_height(fc1), ifA8R8G8B8, Img);
//copy pixel.
for I := 0 to (Img.Width-1) * (Img.Height-1) do
Pinteger(Img.Bits)[I]:=Pinteger(cairo_image_surface_get_data(fc1))[i];
SaveImageToFile('/tmp/1.jpeg', Img);
FreeImage(Img);


Quote
BTW: The original open sourced AggPas is a bit out of date. I have made some changes and bug fixes in AggPas included with fpGUI. You can get the latest AggPas code here [https://github.com/fredvs/fpGUI/tree/master/src/corelib/render/software]

If I was a girl  :-*....Thank you

 

TinyPortal © 2005-2018