[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Server-push scripts with GD?



Hi:

I am trying to build applications on web which output couple images in sequence.
So I use the Server-push method to output the animation-like GIF content using GD
library.
The attached source is the testing cgi.
The problem was that each of the output GIF was cut somewhere in the middle, except
the last GIF.
I wonder if this is regarding the buffering of the Apache server or the GD problem?
I also prefixed the script with nph- to make it non-parsed by the server.
I am using RedHat 6.1, Apache 1.3.9, and GD 1.3-5 (pretty old though).
The Server-push scripts only works on Netscape Navigator??
Any advise? Thanks in advance.

Kuokai




#include "gd.h"
#include <stdio.h>

int main(int argc, char **argv)
{
  gdImagePtr im;
  int i;
  int black, white;
  int color;
  int red;
  gdPoint points[4];

printf("HTTP/1.0 200 OK\n");
printf("Pragma: no-cache\n");
printf("Content-type: multipart/x-mixed-replace;boundary=goober\n\n");

for (i = 1; i <= 10; i++)
{
  im = gdImageCreate(300, 300);
  black = gdImageColorAllocate(im, 0, 0, 00);      
  color = gdImageColorAllocate(im, 25*i, 25*i, 25*i);        
  red = gdImageColorAllocate(im, 255, 0, 0);
  white = gdImageColorAllocate(im, 255, 255, 255);
                       
  points[0].x = 149;
  points[0].y = 10;
  points[1].x = 289;
  points[1].y = 289;
  points[2].x = 10;
  points[2].y = 289;
  points[3].x = 149;
  points[3].y = 149;

//  gdImageFilledRectangle(im, 25, 25, 174, 174, red);
  gdImageFilledPolygon(im, points, 4, color);
//  gdImagePolygon(im, points, 4, red);
  gdImageFilledRectangle(im, 25, 25, 174, 174, red);
  gdImageArc(im, 200, 125, 98, 48, 0, 360, white);

  sleep(1);

  printf("\n--goober\n");
  printf("Pragma: no-cache\n");
  printf("Content-type: image/gif\n\n");
  gdImageGif(im, stdout);

  gdImageDestroy(im);
  fflush(stdout);
//sleep(1);
}
  
  printf("\n--goober--\n");
  return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]