From a64e6fe1fc676771b589503916bde0f857401119 Mon Sep 17 00:00:00 2001 From: reinelt <> Date: Fri, 24 Mar 2000 11:36:56 +0000 Subject: [lcd4linux @ 2000-03-24 11:36:56 by reinelt] new syntax for raster configuration changed XRES and YRES to be configurable PPM driver works nice --- Raster.c | 132 +++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 77 insertions(+), 55 deletions(-) (limited to 'Raster.c') diff --git a/Raster.c b/Raster.c index a7cac00..34c4cd9 100644 --- a/Raster.c +++ b/Raster.c @@ -1,4 +1,4 @@ -/* $Id: Raster.c,v 1.1 2000/03/23 07:24:48 reinelt Exp $ +/* $Id: Raster.c,v 1.2 2000/03/24 11:36:56 reinelt Exp $ * * driver for raster formats * @@ -20,6 +20,12 @@ * * * $Log: Raster.c,v $ + * Revision 1.2 2000/03/24 11:36:56 reinelt + * + * new syntax for raster configuration + * changed XRES and YRES to be configurable + * PPM driver works nice + * * Revision 1.1 2000/03/23 07:24:48 reinelt * * PPM driver up and running (but slow!) @@ -36,6 +42,7 @@ #include #include +#include #include "cfg.h" #include "display.h" @@ -45,53 +52,62 @@ static DISPLAY Display; -static int pixelsize=-1; -static int pixelgap=0; -static int rowgap=0; -static int colgap=0; +static int pixel=-1; +static int pgap=0; +static int rgap=0; +static int cgap=0; static int border=0; static int foreground=0; static int halfground=0; static int background=0; -#define R(color) (0xff&((color)>>16)) -#define G(color) (0xff&((color)>>8)) -#define B(color) (0xff&((color))) - int Raster_flush (void) { - int xsize, ysize; - int x, y, pos; + int xsize, ysize, row, col; + unsigned char *buffer; + unsigned char R[3], G[3], B[3]; - xsize=2*border+Display.cols*Display.xres*(pixelsize+pixelgap); - ysize=2*border+Display.rows*Display.yres*(pixelsize+pixelgap); + 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); - printf ("P3\n"); - printf ("%d %d\n", xsize, ysize); - printf ("255\n"); + if ((buffer=malloc(xsize*ysize*sizeof(*buffer)))==NULL) + return -1; - pos=0; + memset (buffer, 0, xsize*ysize*sizeof(*buffer)); - for (y=0; y=xsize-border || - y=ysize-border || - (y-border)%(pixelsize+pixelgap)>=pixelsize || - (x-border)%(pixelsize+pixelgap)>=pixelsize) { - pos+=printf ("%d %d %d ", R(background), G(background), B(background)); - } else { - if (Pixmap[((y-border)/(pixelsize+pixelgap))*Display.cols*Display.xres+(x-border)/(pixelsize+pixelgap)]) - pos+=printf ("%d %d %d ", R(foreground), G(foreground), B(foreground)); - else - pos+=printf ("%d %d %d ", R(halfground), G(halfground), B(halfground)); - } - if (pos>80) { - pos=0; - printf ("\n"); - } + 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; rowrows=rows; Self->cols=cols; + Self->xres=xres; + Self->yres=yres; Display=*Self; pix_clear(); @@ -156,6 +178,6 @@ int Raster_bar (int type, int row, int col, int max, int len1, int len2) DISPLAY Raster[] = { - { "PPM", 0, 0, XRES, YRES, BARS, Raster_init, Raster_clear, Raster_put, Raster_bar, Raster_flush }, + { "PPM", 0, 0, 0, 0, BARS, Raster_init, Raster_clear, Raster_put, Raster_bar, Raster_flush }, { "" } }; -- cgit v1.2.3