From 5eaeb9d424feab2829ba1d5b80c917f7d959d71a Mon Sep 17 00:00:00 2001 From: ltoetsch <> Date: Thu, 1 Mar 2001 15:11:30 +0000 Subject: [lcd4linux @ 2001-03-01 15:11:30 by ltoetsch] added PNG,Webinterface --- README.Webinterface | 29 ++++++++++++++++++++ Raster.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++--- nph-png | 41 ++++++++++++++++++++++++++++ png.html | 8 ++++++ 4 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 README.Webinterface create mode 100755 nph-png create mode 100644 png.html diff --git a/README.Webinterface b/README.Webinterface new file mode 100644 index 0000000..0f87dff --- /dev/null +++ b/README.Webinterface @@ -0,0 +1,29 @@ + +Prerequisits: + +- libgd (I used 1.81 for testing), which needs libpng and libz. + Get it from http://www.boutell.com/gd/ +- apache, perl, netscape (I don't know, if other browsers can display + server pushed images) + +The PNG driver in Raster is able to generate PNG-Images. + +To display this png file continuously in a web page, follow these instructions: +Copy the sample png.html to an appropriate place under your htdocs. +Copy the sample nph-png perl script into your cgi-bin directory, and adjust +png.html to contain this directory. +Adjust nph-png to contain the path/filename of the outputfile (s. -o option +in README.Raster or 'lcd4linux -h'). +Start 'lcd4linux -o /path/filename.png'. + +If you are on a slow connection to your webserver you might also adjust the +$DELAY in nph-png or the tick/tack in lcd4linux.conf. + +Note: depending on your webservers configuration, you must rename nph-png to + nph-png.pl or npg-png.cgi. + + +Please send correction, additions, questions & donations to +Leopold Toetsch + +Have fun. diff --git a/Raster.c b/Raster.c index 1e6d4d6..eeb9aea 100644 --- a/Raster.c +++ b/Raster.c @@ -1,4 +1,4 @@ -/* $Id: Raster.c,v 1.12 2001/03/01 11:08:16 reinelt Exp $ +/* $Id: Raster.c,v 1.13 2001/03/01 15:11:30 ltoetsch Exp $ * * driver for raster formats * @@ -20,6 +20,9 @@ * * * $Log: Raster.c,v $ + * Revision 1.13 2001/03/01 15:11:30 ltoetsch + * added PNG,Webinterface + * * Revision 1.12 2001/03/01 11:08:16 reinelt * * reworked configure to allow selection of drivers @@ -94,7 +97,9 @@ #include #include #include - +#ifdef WITH_PNG +#include +#endif #include "debug.h" #include "cfg.h" @@ -203,12 +208,77 @@ int Raster_flush (void) return -1; } if (rename (tmp, path)<0) { - error ("Raster: close(%s) failed: %s", tmp, strerror(errno)); + error ("Raster: rename(%s) failed: %s", tmp, strerror(errno)); + return -1; + } + + return 0; +} + + +#ifdef WITH_PNG +int Png_flush (void) +{ + static int seq=0; + int xsize, ysize, row, col; + char path[256], tmp[256]; + FILE *fp; + gdImagePtr im; + int bg, hg, fg; + + xsize=2*border+(Lcd.cols-1)*cgap+Lcd.cols*Lcd.xres*pixel+(Lcd.cols*Lcd.xres-1)*pgap; + ysize=2*border+(Lcd.rows-1)*rgap+Lcd.rows*Lcd.yres*pixel+(Lcd.rows*Lcd.yres-1)*pgap; + + im = gdImageCreate(xsize, ysize); + /* first color = background */ + bg = gdImageColorAllocate(im, + 0xff&background>>16, + 0xff&background>>8, + 0xff&background); + hg = gdImageColorAllocate(im, + 0xff&halfground>>16, + 0xff&halfground>>8, + 0xff&halfground); + + fg = gdImageColorAllocate(im, + 0xff&foreground>>16, + 0xff&foreground>>8, + 0xff&foreground); + + + for (row=0; row'----------------here we go!'); +while (1) { + print multipart_start(-type=>'image/png'); + undef $/; + open(IN, "$file.png") or die("Can't read '$file.png'"); + $_ = ; + print $_; + close(IN); + print multipart_end; + if ($DELAY) { + sleep $DELAY; + } + else { + W: while (1) { + # sleep(1); + (undef, undef, undef, undef, undef, undef, undef, $nsize, undef, + $nmtime) = stat "$file.png"; + if($mtime != $nmtime || $size != $nsize) { + $mtime = $nmtime; + $size = $nsize; + last W; + } + } + } +} + diff --git a/png.html b/png.html new file mode 100644 index 0000000..5cb914b --- /dev/null +++ b/png.html @@ -0,0 +1,8 @@ + +PNG Test + + +

PNG test

+ + + -- cgit v1.2.3