Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Macros | Functions
getfb.c File Reference
#include <stdio.h>
#include <brlcad/fb.h>
#include "rle.h"
Include dependency graph for getfb.c:

Go to the source code of this file.

Macros

#define MAX_PIXELS   1024
 

Functions

 main (int argc, char **argv)
 

Macro Definition Documentation

#define MAX_PIXELS   1024

Definition at line 15 of file getfb.c.

Function Documentation

main ( int  argc,
char **  argv 
)

Definition at line 17 of file getfb.c.

20 {
21  rle_hdr hdr;
22  FILE *rle_fd;
23  FBIO *fbp;
24  int r_debug;
25  char * rle_file;
26  register int i,j;
27 
28  unsigned char scanline[4][MAX_PIXELS]; /* Run length scan line */
29  unsigned char *rows[4]; /* Character pointers for rle_getrow */
30 
31  RGBpixel pix[MAX_PIXELS]; /* pixel structure */
32  int x_len, y_len;
33 
34  hdr = *rle_hdr_init( (rle_hdr *)NULL );
35  rle_names( &hdr, cmd_name( argv ), NULL, 0 );
36  argc--; argv++;
37  while( argv[0][0] == '-') {
38 
39  switch( argv[0][1] ) {
40  case 'D':
41  r_debug = 1;
42  break;
43  default:
44  break;
45  }
46  argc--; argv++;
47  }
48 
49  rle_file = argv[0];
50  rle_names( &hdr, hdr.cmd, rle_file );
51  hdr.rle_file = rle_open_f(hdr.cmd, rle_file, "r");
52  if( rle_get_setup( &hdr ) < 0 ) {
53  fprintf(stderr, "getfb: Error reading setup information\n");
54  exit(1);
55  }
56 
57  if (r_debug)
58  {
59  fprintf( stderr,"Image bounds\n\tmin %d %d\n\tmax %d %d\n",
60  hdr.xmin, hdr.ymin,
61  hdr.xmax, hdr.ymax );
62  if ( hdr.alpha )
63  fprintf( stderr, "Alpha Channel present\n");
64  rle_debug(1);
65  }
66 
67  /* We`re only interested in R, G, & B */
68  RLE_CLR_BIT(hdr, RLE_ALPHA);
69  for (i = 3; i < hdr.ncolors; i++)
70  RLE_CLR_BIT(hdr, i);
71 
72  x_len = hdr.xmax - hdr.xmin + 1;
73  y_len = hdr.ymax - hdr.ymin + 1;
74 
75  if( (fbp = fb_open( "", hdr.xmax+1, hdr.ymax+1 )) == NULL )
76  exit(12);
77 
78  for ( i = hdr.ymin; i <= hdr.ymax; i++) {
79  rows[0] = (unsigned char *)-1;
80  rows[1] = scanline[1];
81  rows[2] = scanline[2];
82  rows[3] = scanline[3];
83  rle_getrow(&hdr, &rows[1] );
84 
85  for ( j = 0; j < x_len; j++)
86  {
87  pix[j][RED] = scanline[1][j];
88  pix[j][GRN] = scanline[2][j];
89  pix[j][BLU] = scanline[3][j];
90  }
91  fb_write( fbp, hdr.xmin, i, pix, x_len );
92  }
93  exit(0);
94 }
int xmin
Definition: rle.h:100
#define MAX_PIXELS
Definition: getfb.c:15
rle_hdr hdr
Definition: iristorle.c:35
int ymin
Definition: rle.h:100
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
const char * cmd
Definition: rle.h:133
int rle_get_setup(rle_hdr *the_hdr)
Definition: rle_getrow.c:74
Definition: rle.h:96
int xmax
Definition: rle.h:100
rle_pixel ** rows
Definition: rletopaint.c:57
#define RLE_CLR_BIT(glob, bit)
Definition: rle.h:124
int ymax
Definition: rle.h:100
void rle_debug(int on_off)
Definition: rle_getrow.c:293
int i
Definition: rletorla.c:82
int alpha
Definition: rle.h:100
#define RLE_ALPHA
Definition: rle.h:65
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
char * cmd_name(char **argv)
Definition: cmd_name.c:31
unsigned char scanline[4][1280]
Definition: get_orion.c:37
#define RED(x)
Definition: getami.c:49
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
FILE * rle_file
Definition: rle.h:114
int ncolors
Definition: rle.h:100
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267