Indy 10: HTTP Server - onCommandGet - Serving dynamic images

Giganews Newsgroups
Subject: Indy 10: HTTP Server - onCommandGet - Serving dynamic images
Posted by:  Matthew Augier (dps) (Matth…@dps.uk.com)
Date: Wed, 4 Jul 2007

Ok, I've been messing about with a HTTP server to provide a couple of
informaiton pages on the app currently running. So far things are not to
bad, and it's all ok... I have a login page, and main page and logout page,
all working and as expected. However, on the main page, I'm trying to add a
dynamic image drawn in the app. Using the Eliza web I have my own WWWEngine
which gets created on a new Session, and has a bitmap and memorystream in
it. I draw the bitmap and then save it to the stream. When I process the
requests I look for images prefixed with "X_" to tell teh server to serve a
dynamic image thus :-

      If Pos('X_',LFileName)=2 Then Begin
          // Dynamic image
          if lFileName='/X_speed.bmp' Then Begin
              With WWWEngine.fTempBitmap1 Do Begin
                  Width := Random(100)+32;
                  Height := Random(100)+32;
                  With Canvas Do Begin
                      Canvas.Brush.Color := Random($ffffff);
                      Canvas.Rectangle(0,0,Width,Height);
                      End;
                  End;
              WWWEngine.fTempBitmap1.SaveToStream(WWWEngine.fTempStream1);
              aResponseInfo.ContentType := 'image/bmp';
              aResponseInfo.ContentStream := WWWEngine.fTempStream1;
              End;
          End
This works fine the first time, but then on a refresh I get nothing but a
little X in place of my graphic?

What am I missing, or what hsould I be doing?

TIA

Mat

Replies