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

Go to the source code of this file.

Functions

void rasterInit (int fd, int width, int height)
 
void rasterRowGet (unsigned char *red, unsigned char *green, unsigned char *blue)
 
void rasterDone ()
 

Variables

static char rcsid [] = "$Header:$"
 
rle_hdr hdr
 
struct {
   int   width
 
   int   height
 
   unsigned char **   scan
 
   int   row
 
Globals
 

Function Documentation

void rasterDone ( )

Definition at line 103 of file rle.c.

References hdr, and rle_puteof().

104 {
105  rle_puteof(&hdr);
106 }
rle_hdr hdr
Definition: rle.c:21
void rle_puteof(rle_hdr *the_hdr)
Definition: rle_putrow.c:474

Here is the call graph for this function:

void rasterInit ( int  fd,
int  width,
int  height 
)

Definition at line 31 of file rle.c.

35 {
36  FILE *rleFile;
37  int i;
38 
39  hdr = *rle_hdr_init( (rle_hdr *)NULL );
40  /* Fake the names, since we don't have argv. */
41  rle_names( &hdr, "rletoabA62", fd == 0 ? NULL : "RLE file", 0 );
42 
43  Globals.width = width;
44  Globals.height = height;
45  if (fd == 0) {
46  rleFile = stdin;
47  } else {
48  rleFile = fdopen(fd, "r");
49  }
50  hdr.rle_file = rleFile;
51  rle_get_setup_ok(&hdr, NULL, NULL);
52 
53  if (hdr.xmax > width) {
54  fprintf(stderr, "Warning: RLE width (%d) exceeds maximum (%d)\n",
55  hdr.xmax, width);
56  }
57  if (hdr.ymax > height) {
58  fprintf(stderr, "Warning: RLE height (%d) exceeds maximum (%d)\n",
59  hdr.ymax, height);
60  }
61  Globals.row = 0;
62  Globals.scan = (unsigned char **) malloc((hdr.ncolors +
63  hdr.alpha) *
64  sizeof(unsigned char *));
65  for (i = 0; i < hdr.ncolors + hdr.alpha; i++)
66  Globals.scan[i] =
67  (unsigned char *)malloc(hdr.xmax+1);
68 
69  if (hdr.alpha) {
70  Globals.scan++;
71  }
72 }
rle_hdr hdr
Definition: rle.c:21
static struct @5 Globals
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
Definition: rle.h:96
int xmax
Definition: rle.h:100
int width
Definition: rle.c:24
int ymax
Definition: rle.h:100
FILE * fd
Definition: getfb.h:18
void * malloc()
int i
Definition: rletorla.c:82
int alpha
Definition: rle.h:100
int height
Definition: rle.c:25
void rle_get_setup_ok(rle_hdr *the_hdr, const char *prog_name, const char *file_name)
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
void rasterRowGet ( unsigned char *  red,
unsigned char *  green,
unsigned char *  blue 
)

Definition at line 75 of file rle.c.

77 {
78  int i, max;
79 
80  if (Globals.row < hdr.ymin || Globals.row > hdr.ymax) {
81  for (i = 0; i < Globals.width; i++) {
82  red[i] = 0;
83  green[i] = 0;
84  blue[i] = 0;
85  }
86  } else {
87  rle_getrow(&hdr, Globals.scan);
88  max = hdr.xmax < Globals.width ?
89  hdr.xmax : Globals.width;
90  for (i = 0 ; i < max; i++) {
91  red[i] = Globals.scan[0][i];
92  green[i] = Globals.scan[1][i];
93  blue[i] = Globals.scan[2][i];
94  }
95  for (; i < Globals.width; i++) {
96  red[i] = green[i] = blue[i] = 0;
97  }
98  }
99  Globals.row++;
100 }
static unsigned char blue[256]
Definition: rastorle.c:71
rle_hdr hdr
Definition: rle.c:21
int ymin
Definition: rle.h:100
static struct @5 Globals
int xmax
Definition: rle.h:100
static unsigned char green[256]
Definition: rastorle.c:71
int ymax
Definition: rle.h:100
int i
Definition: rletorla.c:82
static unsigned char red[256]
Definition: rastorle.c:71
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])

Variable Documentation

struct { ... } Globals
rle_hdr hdr

Definition at line 21 of file rle.c.

int height

Definition at line 25 of file rle.c.

char rcsid[] = "$Header:$"
static

Definition at line 8 of file rle.c.

int row

Definition at line 27 of file rle.c.

unsigned char** scan

Definition at line 26 of file rle.c.

int width

Definition at line 24 of file rle.c.