Recent

Author Topic: AggPas and BGRABitmap comparison  (Read 21390 times)

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: AggPas and BGRABitmap comparison
« Reply #15 on: July 18, 2016, 12:44:15 pm »
Glad to know BGRABitmap become so feature-rich. Does it support Android?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: AggPas and BGRABitmap comparison
« Reply #16 on: July 18, 2016, 01:40:10 pm »
BGRABitmap is in principle cross-platform, and on top of that there are some optimizations and fixes for different platforms and processors.

Some people seem to have successfully done things on Android with BGRABitmap:
http://forum.lazarus.freepascal.org/index.php?topic=19066.0

And on WinCE:
http://forum.lazarus.freepascal.org/index.php/topic,12411.msg81152.html#msg81152

The main optimization that needs to be implemented for a specific platform is the direct pixel access. Otherwise, it uses LCL functions to generate a bitmap from the data, which is a bit slower. Currently this optimizations is basically done on Windows and Linux.

There might also been some adjustments needed for OpenGL as for some system it is OpenGL ES which does not have the same features.

So basically, you can try a platform and if you find it does not work or that it is slow, I invite you to create a thread in the BGRABitmap section of the forum and me or someone else will be happy to help find a way of improving it.
Conscience is the debugger of the mind

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: AggPas and BGRABitmap comparison
« Reply #17 on: July 18, 2016, 02:34:58 pm »
Is AGG a "black box" for having the TAgg2D class?
TAgg2D was actually added much later to AGG - simply to show that you can implement a all-in-one Canvas like class. It was never meant for day-to-day usage. But as I've come to realise, so many developers are engrained with the idea of one class must be able to do everything, so many tend to use TAgg2D instead of exploring the powers of loosely coupled features.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: AggPas and BGRABitmap comparison
« Reply #18 on: July 18, 2016, 02:56:46 pm »
A TBGRABitmap is an actual image class that behaves like you would expect an image class to behave (i.e. with full SaveTo, LoadFrom functionality, e.t.c.)...
And that is where I fundamentally disagree with such designs. In your above text you now mention that a 2D graphics library also does file handling, unicode or code page conversion of file names, file format handling, streaming etc... That's an awful lot of non 2D graphics functionality thrown it.

My design philosophy: Keep it simple and let each class do one thing only, and do that thing very well.

One a side note:
  It's also exactly the reason I hate LCL's TStringGrid's LoadFromCSVFile() method. What
  if I wanted to load from a JSON or XML file? More examples include VirtualTreeView - is that a treeview, grid,
  listview or all of the above? Also LCL's TListView - is that a list, grid, report etc component? Too much
  functionality in a single class and makes in very prone to bugs.

  fpGUI's StringGrid "load from CSV file" solution is a separate TStringGridBuilder
  class that takes a StringGrid as a parameter. CSV, JSON, XML etc functionality is kept totally separate
  from the TfpgStringGrid class.


Quote
As near as I can tell, BGRABitmap didn't originally set out with any 3D aspirations either, and it's still by and large a 2D-focused library. The point is though that is has 3D capabilities now.
I have no interest in 3D at all, so I'll leave that exercise for somebody else to play with. But like Circular mentioned, AggPas already has rotate, transform, perspective functionality, so it shouldn't be hard to implement a TAgg3D class.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: AggPas and BGRABitmap comparison
« Reply #19 on: July 18, 2016, 04:20:16 pm »
A TBGRABitmap is an actual image class that behaves like you would expect an image class to behave (i.e. with full SaveTo, LoadFrom functionality, e.t.c.)...
And that is where I fundamentally disagree with such designs. In your above text you now mention that a 2D graphics library also does file handling, unicode or code page conversion of file names, file format handling, streaming etc... That's an awful lot of non 2D graphics functionality thrown it.
You can use LoadFromStream if you don't want to use LoadFromFile. And having no ability to read a stream, you would like a class that just takes pointers? And if really you don't want any of the reading mechanism, you can still make your own framework and call the SetPixel function.

Also it is not fair to say that file format handling is in the class. There are readers and writers, directly from the FreePascal readers/writers for image files or based on the same abstract class. You can define your own reader if you like.

Quote
My design philosophy: Keep it simple and let each class do one thing only, and do that thing very well.
I don't find AGG to be simple personally. I would agree that classes are small, but not that they are simple to understand.

My philosophy is rather: if someone wants something, let's give it. If someone wants something a bit more special, let's give the components to do that. So every feature is as much as possible given a simple function, that enables to use it without understanding its inner workings. There may be some things you cannot do with the provided functions, but then, you can simply dig a bit further according to how motivated you are to do so.

Quote
It's also exactly the reason I hate LCL's TStringGrid's LoadFromCSVFile() method. What
  if I wanted to load from a JSON or XML file?
You don't need to hate it. You can ask to have readers and writers just like for images or provide a patch that would do that.

Quote
Also LCL's TListView - is that a list, grid, report etc component? Too much
  functionality in a single class and makes in very prone to bugs.
Are you worried about bugs and you find it reassuring that AGG classes are small and that would prevent bugs?

Quote
fpGUI's StringGrid "load from CSV file" solution is a separate TStringGridBuilder
  class that takes a StringGrid as a parameter. CSV, JSON, XML etc functionality is kept totally separate
  from the TfpgStringGrid class.
That's good. And you don't need to hate LCL version to value your own version.

Quote
I have no interest in 3D at all, so I'll leave that exercise for somebody else to play with. But like Circular mentioned, AggPas already has rotate, transform, perspective functionality, so it shouldn't be hard to implement a TAgg3D class.
Yet that would still be a lot for a user that does not have hours to spend on that. Basically you are saying AGG is better because it lets you program something, but that's not an actual fact, that's a potential. It is like saying a big promise is better than an actual gift.

TAgg2D was actually added much later to AGG - simply to show that you can implement a all-in-one Canvas like class. It was never meant for day-to-day usage. But as I've come to realise, so many developers are engrained with the idea of one class must be able to do everything so many tend to use TAgg2D instead of exploring the powers of loosely coupled features.
I hear two things. That you are sad that people are not more using the loosely coupled features. On that I would tend to be also enthusiastic about people trying to use the more specialized class of BGRABitmap. The other thing I hear is that you say the developers don't use them because they are mentally conditioned. On that I would say that yes there are habits, but the more fundamental reason is that it takes time and energy to learn to use loosely coupled features. When you are focused on achieving something, having to program everything at a low level can become an obstacle to your creativity.
Conscience is the debugger of the mind

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: AggPas and BGRABitmap comparison
« Reply #20 on: July 18, 2016, 06:58:12 pm »
Hello, both of you are awesome. I think it's about personal preference. I like the idea mentioned by Graeme. As describe in here:

https://en.wikipedia.org/wiki/KISS_principle
https://en.wikipedia.org/wiki/Unix_philosophy

Anyways, I just have a peek at BGRABitmap. It has good tutorials, good for beginners like me. Great.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: AggPas and BGRABitmap comparison
« Reply #21 on: July 18, 2016, 07:34:59 pm »
Hello, both of you are awesome.
Thank you.  :)
Conscience is the debugger of the mind

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: AggPas and BGRABitmap comparison
« Reply #22 on: July 18, 2016, 08:25:40 pm »
Am I right that only three facts are mentioned here when comparing AggPas and BGRABitmap:
1-Pixel format.
2-Speed.
3-One is low level mainly, and lacks a simple interface while the other has both.

Did I miss anything else apart from I like and you like, and my design philosophy and your design philosophy?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: AggPas and BGRABitmap comparison
« Reply #23 on: July 18, 2016, 10:14:40 pm »
Yes, the difference in terms of features:
Quote
AggPas has some 2D transformation features for path and images that are not available in BGRABitmap and better SVG support
BGRABitmap has Phong shading, Foyd-Steinberg dithering and color number reduction, lots of ready-to-use filters, OpenGL 2D and 3D acceleration, lots of raster image formats including layered images
Conscience is the debugger of the mind

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: AggPas and BGRABitmap comparison
« Reply #24 on: July 18, 2016, 10:20:34 pm »
Yes, the difference in terms of features:
Quote
AggPas has some 2D transformation features for path and images that are not available in BGRABitmap and better SVG support
BGRABitmap has Phong shading, Foyd-Steinberg dithering and color number reduction, lots of ready-to-use filters, OpenGL 2D and 3D acceleration, lots of raster image formats including layered images

Thank you.

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: AggPas and BGRABitmap comparison
« Reply #25 on: July 19, 2016, 01:30:16 am »
Also it is not fair to say that file format handling is in the class.
Reading an earlier message from somebody else I guess I was a bit harsh there. If BGRABitmap is like an enhanced TBitmap/TGraphic/TImage class of sorts, then I guess direct image format handling should be a given, because the LCL and VCL classes have them.

Quote
I don't find AGG to be simple personally. I would agree that classes are small, but not that they are simple to understand.
I'm to old to keep spoon feeding every new developer that comes round. If they can't bother working through some tutorials, then I can't bother to help them. I work on a lot of open source projects and trying to scale down because I'm very busy at work and other personal interests. So my statement about working through some tutorials apply not just to AggPas, but to other components or frameworks too. eg: tiOPF, FPTest, DCPCrypt, OnGuard, fpGUI etc.

Quote
Quote
It's also exactly the reason I hate LCL's TStringGrid's LoadFromCSVFile() method. What
  if I wanted to load from a JSON or XML file?
You don't need to hate it. You can ask to have readers and writers just like for images or provide a patch that would do that.
The problem being, such methods were introduced, and now used by others. So you can't just remove them to clean up the crappy API. You first have to deprecate them for a release or two - that's if you are willing to break somebody's code.

Quote
Are you worried about bugs and you find it reassuring that AGG classes are small and that would prevent bugs?
Always, and again that doesn't just apply to AggPas, but to other frameworks too. It is well knows that if you have a 1000 line procedure it is prone to bugs and hard to fix - compared to many smaller and to-the-point procedures. The latter is infinitely easier to debug, unit test etc.


Quote
And you don't need to hate LCL version to value your own version.
It is a crappy design. Somebody wanted to populate a StringGrid from a CSV file and created a method in TStringGrid to do that. Scratch your own itch. No thought about good design. They were too lazy to come up with a better and more flexible solution. The person that introduced that method should start reading books about Design Patterns.

A quick search in my git repository reveals those CSV methods were introduced back in 2011 as commit r32179.

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

jesusr

  • Sr. Member
  • ****
  • Posts: 484
Re: AggPas and BGRABitmap comparison
« Reply #26 on: July 19, 2016, 10:20:23 am »
One a side note:
  It's also exactly the reason I hate LCL's TStringGrid's LoadFromCSVFile() method. What
  if I wanted to load from a JSON or XML file? More examples include VirtualTreeView - is that a treeview, grid,
  listview or all of the above? Also LCL's TListView - is that a list, grid, report etc component? Too much
  functionality in a single class and makes in very prone to bugs.

  fpGUI's StringGrid "load from CSV file" solution is a separate TStringGridBuilder
  class that takes a StringGrid as a parameter. CSV, JSON, XML etc functionality is kept totally separate
  from the TfpgStringGrid class.

Would your grid allow to be filled by just any xml or json file?, if it so, it must be an exceptional implementation because it doesn't sound right comparing a fixed file format like a csv versus something completely arbitrary like json or xml.

There are reasons for and against on having this feature implemented within TStringGrid, not everything is black and white.

jesusr

  • Sr. Member
  • ****
  • Posts: 484
Re: AggPas and BGRABitmap comparison
« Reply #27 on: July 19, 2016, 10:41:17 am »
Quote
Quote
And you don't need to hate LCL version to value your own version.
It is a crappy design. Somebody wanted to populate a StringGrid from a CSV file and created a method in TStringGrid to do that. Scratch your own itch. No thought about good design. They were too lazy to come up with a better and more flexible solution. The person that introduced that method should start reading books about Design Patterns.

A quick search in my git repository reveals those CSV methods were introduced back in 2011 as commit r32179.

Oh, with so many arrows pointing to the bad guy, the bad guy feels the need to answer. Yep, he may start reading those books, or not, or maybe he have read some... But the bad guy remembers how difficult or impossible is to please everybody and specially to Graeme, because he one day is in love with it, the next day he hate it, now he love it again, ups now he really hate it again, simply no way. Yep I'm not talking about grids. :).

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: AggPas and BGRABitmap comparison
« Reply #28 on: July 19, 2016, 10:47:39 am »
Would your grid allow to be filled by just any xml or json file?
I moved my reply to a new thread.

  http://forum.lazarus.freepascal.org/index.php/topic,33405.msg216419.html
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: AggPas and BGRABitmap comparison
« Reply #29 on: July 19, 2016, 10:52:24 am »
...because he one day is in love with it, the next day he hate it, now he love it again, ups now he really hate it again,
Sorry mate, I have no idea what you are trying to say.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

 

TinyPortal © 2005-2018