[Lazarus] Get JPEG from TAChart in CGI app

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Mon Mar 21 09:40:19 CET 2011



On Mon, 21 Mar 2011, Mattias Gaertner wrote:

> On Mon, 21 Mar 2011 11:53:52 +1000
> Alexander Klenin <klenin at gmail.com> wrote:
>
>> On Mon, Mar 21, 2011 at 08:41, Mattias Gaertner
>> <nc-gaertnma at netcologne.de> wrote:
>>> On Mon, 21 Mar 2011 04:58:18 +1000
>>> Alexander Klenin <klenin at gmail.com> wrote:
>>>> Hm. For me GUI means "graphical user interface" -- that is, windows (aka forms),
>>>> interacting with mouse, etc.
>>>> I have just committed a demo which does not have any of this,
>>>> and yet successfully draws TChart to a file -- see previous mail.
>>>> Maybe for you GUI means a different thing?
>>>
>>> Yes. The GUI of the screen.
>>> By accessing the LCL canvas you access the widgetset (gtk2) which
>>> accesses the current screen. For example the gtk2 asks for
>>> theme, fonts, screen color depths and sub pixel rendering parameters.
>>> A cgi program has no screen.
>>
>> It is ok to ask for all these things since thay are necessary to
>> render the chart.
>> However, the fact they are unconditionally taken from the screen is IMO
>> a deficiency of either GTK or LCL-GTK.
>
> The display error comes from the gtk.
>
>
>> As you can see in this thread, as soon as this deficiency is worked around,
>> (in this case, by using Xvfb utility), the problem is solved.
>
> I wonder how much overhead it is for a cgi program to start gtk on xvfb
> compared to a fpcanvas program.

A lot. A connection to the X server must be established, and the whole
of GTK must be set up. This is an expensive operation.

I can't believe people even consider this approach. It's like PHP devels
would suddenly say that "well, from now on you must run your web apps with
an X server". They would be the laughing stock of the whole PHP programmer's
community.

Yet, in lazarus, no-one seems to mind this kind of statements. It's even
encouraged.

None of "theme,  screen color depths and sub pixel rendering parameters" are
necessary to create a bitmap. A bitmap is a matrix of pixels with a certain
color. No more, no less. Some of these parameters are needed when the bitmap is
being displayed, but definitely not when it is created.

When making a picture with a digital camera, the camera also has no knowledge 
of the screen you'll be displaying the picture on. Nevertheless, it makes pictures.

Michael.




More information about the Lazarus mailing list