[Lazarus] Get JPEG from TAChart in CGI app

Leonardo M. Ramé l.rame at griensu.com
Sun Mar 20 22:34:00 CET 2011


On 2011-03-20 18:16:00 -0300, Leonardo M. Ramé wrote:
> On 2011-03-20 20:16:19 +0000, Henry Vermaak wrote:
> > On 20 March 2011 19:42, Leonardo M. Ramé <l.rame at griensu.com> wrote:
> > > On 2011-03-21 05:39:01 +1000, Alexander Klenin wrote:
> > >> On Mon, Mar 21, 2011 at 05:30, Leonardo M. Ramé <l.rame at griensu.com> wrote:
> > >> >> You have to link you CGI app with some graphic widgetset,
> > >> >> which will unfortunately bloat an executable, but should otherwise work.
> > >> >>
> > >> >
> > >> > Well, I tested that, but I get "Internal Server Error" from my Apache.
> > >>
> > >> What does the log show?
> > >>
> > >
> > > [Sun Mar 20 16:30:09 2011] [error] [client ::1] (cgicharts:16246):
> > > Gtk-WARNING **: cannot open display:
> > 
> > Try using xvfb.  This uses a virtual framebuffer that doesn't need a
> > display.  I've had to use it with a webserver before.
> > 
> > Henry
> > 
> 
> Thanks Henry, it seems to almost work, at least I don't get the Cannot
> Open Display error, but...
> 
> When I do this:
> 
>     lChart.Width := 100;
>     lChart.Height := 100;
>     with lChart.SaveToImage(TJPEGImage) do
>     begin
>       SaveToStream(AResponse.ContentStream);
>       AResponse.ContentType := 'image/jpeg';
>       AResponse.ContentLength := AResponse.ContentStream.Size;
>       AResponse.SendContent;
>     end;
> 
> I get a black square of 100 x 100 pixels.
> 
> If I try this:
> 
>     lChart.SaveToBitmapFile('test.bmp');
> 
> I get the error "Image palette is too big or absent" from my CGI.
> 

Sorry Henry, the correct command to run Xvfb is this:

Xvfb :12 -screen 0 1024x768x16 &

Now it works!

-- 
Leonardo M. Ramé
http://leonardorame.blogspot.com




More information about the Lazarus mailing list