From 5b3b7e2609d010298a345eed91255c880b3f9e0f Mon Sep 17 00:00:00 2001 From: reinelt <> Date: Sun, 26 Mar 2000 12:55:03 +0000 Subject: [lcd4linux @ 2000-03-26 12:55:03 by reinelt] enhancements to the PPM driver --- Raster.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 14 deletions(-) (limited to 'Raster.c') diff --git a/Raster.c b/Raster.c index 1159612..f4f86f4 100644 --- a/Raster.c +++ b/Raster.c @@ -1,4 +1,4 @@ -/* $Id: Raster.c,v 1.3 2000/03/25 05:50:43 reinelt Exp $ +/* $Id: Raster.c,v 1.4 2000/03/26 12:55:03 reinelt Exp $ * * driver for raster formats * @@ -20,6 +20,10 @@ * * * $Log: Raster.c,v $ + * Revision 1.4 2000/03/26 12:55:03 reinelt + * + * enhancements to the PPM driver + * * Revision 1.3 2000/03/25 05:50:43 reinelt * * memory leak in Raster_flush closed @@ -48,6 +52,11 @@ #include #include #include +#include +#include +#include +#include + #include "cfg.h" #include "display.h" @@ -67,21 +76,37 @@ static int foreground=0; static int halfground=0; static int background=0; +extern char* output; + + int Raster_flush (void) { + static int seq=0; + static unsigned char *bitbuf=NULL; + static unsigned char *rowbuf=NULL; int xsize, ysize, row, col; unsigned char R[3], G[3], B[3]; - static unsigned char *buffer=NULL; + char path[256], tmp[256], buffer[256]; + int fd; + + xsize=2*border+(Display.cols-1)*cgap+Display.cols*Display.xres*pixel+(Display.cols*Display.xres-1)*pgap; + ysize=2*border+(Display.rows-1)*rgap+Display.rows*Display.yres*pixel+(Display.rows*Display.yres-1)*pgap; - xsize=2*border+(Display.cols-1)*cgap+Display.cols*Display.xres*(pixel+pgap); - ysize=2*border+(Display.rows-1)*rgap+Display.rows*Display.yres*(pixel+pgap); + if (bitbuf==NULL) { + if ((bitbuf=malloc(xsize*ysize*sizeof(*bitbuf)))==NULL) { + fprintf (stderr, "Raster: malloc(%d) failed: %s\n", xsize*ysize*sizeof(*bitbuf), strerror(errno)); + return -1; + } + } - if (buffer==NULL) { - if ((buffer=malloc(xsize*ysize*sizeof(*buffer)))==NULL) + if (rowbuf==NULL) { + if ((rowbuf=malloc(3*xsize*sizeof(*rowbuf)))==NULL) { + fprintf (stderr, "Raster: malloc(%d) failed: %s\n", 3*xsize*sizeof(*rowbuf), strerror(errno)); return -1; + } } - - memset (buffer, 0, xsize*ysize*sizeof(*buffer)); + + memset (bitbuf, 0, xsize*ysize*sizeof(*bitbuf)); for (row=0; row>16; G[0]=0xff&background>>8; B[0]=0xff&background; - + R[1]=0xff&halfground>>16; G[1]=0xff&halfground>>8; B[1]=0xff&halfground; - + R[2]=0xff&foreground>>16; G[2]=0xff&foreground>>8; B[2]=0xff&foreground; for (row=0; row