Back to index

radiance  4R0+20100331
Defines | Functions | Variables
meta2bmp.c File Reference
#include "copyright.h"
#include "rtprocess.h"
#include "meta.h"
#include "plot.h"
#include "rast.h"
#include "bmpfile.h"
#include "targa.h"

Go to the source code of this file.

Defines

#define MAXALLOC   30000
#define DXSIZE   400 /* default x resolution */
#define DYSIZE   400 /* default y resolution */
#define XCOM   "pexpand +vOCImsp -DP %s | psort +y"
#define MINRUN   4

Functions

char * findtack (char *s)
int main (int argc, char **argv)
void thispage (void)
void initfile (void)
void nextpage (void)
void printblock (void)

Variables

static const char RCSid [] = "$Id: meta2bmp.c,v 1.2 2005/09/19 12:48:09 schorsch Exp $"
char * progname
SCANBLOCK outblock
int dxsize = DXSIZE
int dysize = DYSIZE
int maxalloc = MAXALLOC
int ydown = 0
static char outname [64]
static char * outtack = NULL
static BMPWriterbmpw = NULL
static int lineno = 0
static short condonly = FALSE
static short conditioned = FALSE

Define Documentation

#define DXSIZE   400 /* default x resolution */

Definition at line 18 of file meta2bmp.c.

#define DYSIZE   400 /* default y resolution */

Definition at line 19 of file meta2bmp.c.

#define MAXALLOC   30000

Definition at line 17 of file meta2bmp.c.

#define MINRUN   4

Definition at line 208 of file meta2bmp.c.

#define XCOM   "pexpand +vOCImsp -DP %s | psort +y"

Definition at line 20 of file meta2bmp.c.


Function Documentation

char* findtack ( char *  s)

Definition at line 47 of file meta2bmp.c.

{
       while (*s && *s != '.')
              s++;
       return(s);
}

Here is the caller graph for this function:

void initfile ( void  )

Definition at line 153 of file meta2bmp.c.

{
    /*
    static unsigned char  cmap[24] = {255,255,255, 255,152,0, 0,188,0, 0,0,255,
                     179,179,0, 255,0,255, 0,200,200, 0,0,0};
     */
    static const unsigned char  cmap[8][3] = {{0,0,0}, {0,0,255}, {0,188,0},
              {255,152,0}, {0,200,200}, {255,0,255}, {179,179,0}, {255,255,255}};
    static int  filenum = 0;
    BMPHeader  *hp;
    register int  i;

    hp = BMPmappedHeader(dxsize, dysize, 0, 256);
    hp->compr = BI_RLE8;
    if (hp == NULL)
       error(USER, "Illegal image parameter(s)");
    for (i = 0; i < 8; i++) {
       hp->palette[i].r = cmap[i][2];
       hp->palette[i].g = cmap[i][1];
       hp->palette[i].b = cmap[i][0];
    }
    hp->impColors = 8;
    if (outtack != NULL) {
       sprintf(outtack, "%d.bmp", ++filenum);
       bmpw = BMPopenOutputFile(outname, hp);
    } else {
       bmpw = BMPopenOutputStream(stdout, hp);
    }
    if (bmpw == NULL)
       error(USER, "Cannot create output");
}

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 57 of file meta2bmp.c.

{
 FILE  *fp;
 char  comargs[200], command[300];

 progname = *argv++;
 argc--;

 condonly = FALSE;
 conditioned = FALSE;
 
 while (argc && **argv == '-')  {
    switch (*(*argv+1))  {
       case 'c':
         condonly = TRUE;
         break;
       case 'r':
         conditioned = TRUE;
         break;
       case 'm':
         minwidth = atoi(*++argv);
         argc--;
         break;
       case 'x':
         dxsize = atoi(*++argv);
         argc--;
         break;
       case 'y':
         dysize = atoi(*++argv);
         argc--;
         break;
       case 'o':
         strcpy(outname, *++argv);
         outtack = findtack(outname);
         argc--;
         break;
       default:
         error(WARNING, "unknown option");
         break;
       }
    argv++;
    argc--;
    }

 if (conditioned) {
    if (argc)
       while (argc)  {
         fp = efopen(*argv, "r");
         plot(fp);
         fclose(fp);
         argv++;
         argc--;
         }
    else
       plot(stdin);
    if (lineno)
       nextpage();
 } else  {
    comargs[0] = '\0';
    while (argc)  {
       strcat(comargs, " ");
       strcat(comargs, *argv);
       argv++;
       argc--;
       }
    sprintf(command, XCOM, comargs);
    if (condonly)
       return(system(command));
    else  {
       if ((fp = popen(command, "r")) == NULL)
          error(SYSTEM, "cannot execute input filter");
       plot(fp);
       pclose(fp);
       if (lineno)
         nextpage();
       }
    }

 return(0);
 }

Here is the call graph for this function:

void nextpage ( void  )

Definition at line 188 of file meta2bmp.c.

{

    if (lineno == 0)
       return;
    if (bmpw != NULL) {
       while (lineno < dysize) {
           nextblock();
           outputblock();
       }
       BMPcloseOutput(bmpw);
       bmpw = NULL;
    }
    lineno = 0;

}

Here is the caller graph for this function:

void printblock ( void  )

Definition at line 211 of file meta2bmp.c.

{
    int  i;
    register unsigned char  *scanline;

    if (lineno == 0)
       initfile();
    for (i = outblock.ybot; i <= outblock.ytop && i < dysize; i++) {
       scanline = outblock.cols[i-outblock.ybot] + outblock.xleft;
       memcpy((void *)bmpw->scanline, (void *)scanline,
                     sizeof(uint8)*(outblock.xright-outblock.xleft+1));
       if (BMPwriteScanline(bmpw) != BIR_OK)
              error(SYSTEM, "Error writing BMP file");
       lineno++;
    }
    
}

Here is the caller graph for this function:

void thispage ( void  )

Definition at line 145 of file meta2bmp.c.

{
    if (lineno)
       error(USER, "cannot restart page in thispage");
}

Here is the caller graph for this function:


Variable Documentation

BMPWriter* bmpw = NULL [static]

Definition at line 36 of file meta2bmp.c.

short conditioned = FALSE [static]

Definition at line 41 of file meta2bmp.c.

short condonly = FALSE [static]

Definition at line 40 of file meta2bmp.c.

int dxsize = DXSIZE

Definition at line 27 of file meta2bmp.c.

int dysize = DYSIZE

Definition at line 27 of file meta2bmp.c.

int lineno = 0 [static]

Definition at line 38 of file meta2bmp.c.

Definition at line 29 of file meta2bmp.c.

Definition at line 25 of file meta2bmp.c.

char outname[64] [static]

Definition at line 33 of file meta2bmp.c.

char* outtack = NULL [static]

Definition at line 34 of file meta2bmp.c.

char* progname

Definition at line 23 of file meta2bmp.c.

const char RCSid[] = "$Id: meta2bmp.c,v 1.2 2005/09/19 12:48:09 schorsch Exp $" [static]

Definition at line 2 of file meta2bmp.c.

int ydown = 0

Definition at line 31 of file meta2bmp.c.