you only need to open a TCanvas and then use gGXW->ReadGIF(...), it
will put the GIF in the current pad.
here is a Long Island weather display macro that does exactly that,
cheers,
patrick.
//LI_weather.C
//
// Display local weather
//
{
gROOT->Reset();
// Display local weather
// this is the URL
Char_t URL[] = "http://www.weather.com/images/radar/single_site/lgaloc_450x284.gif";
Char_t UniqueFileName[100];
Char_t ExecCmd[100];
TUrl u(URL);
TSocket s(u.GetHost(), u.GetPort());
if (!s.IsValid())
return ;
const Int_t kMsgLength = 1000;
Char_t msg[kMsgLength];
const Int_t kLength = 50000; // should be enough to store the GIF
Char_t Buf[kLength];
// Construct the HTTP request
sprintf(msg, "GET %s HTTP/1.0\rUser-Agent: ILikeMyself/99.3\rHost: %s:%d\n\rAccept: */*\n\r\n\r", u.GetFile(), u.GetHost(), u.GetPort());
s.SendRaw(msg, strlen(msg));
s.RecvRaw(Buf, kLength);
s.Close();
Int_t length;
Char_t dummy[100];
// Get the length of the GIF file
sscanf(strstr(Buf, "Content-length: "), "%s %d", dummy, &length);
// Find the beginning of the GIF
Char_t *gif = strstr(Buf, "\r\n\r\n")+4;
// Make a unique file name
sprintf(UniqueFileName, "/tmp/%f.gif", gRandom->Gaus(10, 0.2));
FILE *handle = fopen(UniqueFileName, "w");
fwrite(gif, length, sizeof(Char_t), handle);
fclose(handle);
// Display GIF
TCanvas *c = new TCanvas("Browser");
c->Update();
gGXW->ReadGIF(50, 100, UniqueFileName);
c->Update();
sprintf(ExecCmd, "rm -f %s", UniqueFileName);
gSystem->Exec(ExecCmd);
}
On Mon, 19 Jul 1999, Adnan Khan wrote:
> Hi Fons!
>
> I am intending to display some images based on the data I am receiving
> from the server. Currently, I do not have to worry about the data been
> sent from the server to my GUI client. I just intend to display the image
> based on that raw data.
>
> I was trying TGXclient class under CINT env. but couldn't quite got at it.
> What problem I am having is, I am unable to invoke a parent window using
> TGXClient object. Can you tell me as to what parameters I must pass to
> CreateWindow() method to display a paraent window? Furhter, I intend to
> use ReadGIF() method to display gif image.
>
> Tell me if any other way I should try that will do the job in an efficient
> way.
>
> take care and thanks
>
> cheers, ADnan
>
>
> On Tue, 20 Jul 1999, Fons Rademakers wrote:
>
> > Hi Adnan,
> >
> > currently you can only display xpm images in some widgets, like
> > TGPictureButton. In a canvas you can use a gif as a background image.
> >
> > What exactly do you want to achieve?
> >
> > Cheers, Fons.
> >
> >
> >
> > > Hi Rooters!
> > >
> > > I am trying to display a simple gif image with in my GUI. Just wondering
> > > to know how should I use TGXClient ( what seems to me appropriate for my
> > > work) class in order to be able to display gif images.
> > >
> > > More over, any one has an idea as to what needs to be done in order to
> > > display raw formated data, as an image?
> > >
> > > Shall be grateful for advice
> > >
> > > Thanks
> > > ADnan Khan
> > >
> > >
> >
> >
> > --
> > Org: CERN, European Laboratory for Particle Physics.
> > Mail: 1211 Geneve 23, Switzerland
> > E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248
> > WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910
> >
>
>
-------------------------------------------o-------------------------------
Patrick Decowski |
24-504 | Home: (617)625-9352
Massachusetts Institute of Technology | Office: (617)253-9735
77 Massachusetts Ave | Fax: (617)253-1755
Cambridge, MA 02139-4307 |
-------------------------------------------o-------------------------------
http://web.mit.edu/decowski/www/home.html | e-mail: decowski@mit.edu
-------------------------------------------o-------------------------------