Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
rle_rawrow.c
Go to the documentation of this file.
1 /*
2  * rle_rawrow.c - Convert RLE "raw" input to "row" input.
3  *
4  * Author: Spencer W. Thomas
5  * EECS Dept.
6  * University of Michigan
7  * Date: Mon Jun 18 1990
8  * Copyright (c) 1990, University of Michigan
9  */
10 
11 #include "rle.h"
12 #include "rle_raw.h"
13 
14 /*****************************************************************
15  * TAG( rle_rawtorow )
16  *
17  * Convert a "raw" scanline to a row format.
18  * Inputs:
19  * the_hdr: RLE header describing the image.
20  * raw: Pointer to pointers to vectors of "raw" data.
21  * nraw: Pointer to vector of lengths of raw data vectors.
22  * Outputs:
23  * outrows: Pointer to pointers to scanline data for
24  * this scanline.
25  * Algorithm:
26  * Interpret successive "op codes", filling in scanline array.
27  * Scanline between xmin and xmax is prefilled with background
28  * color, if one is given.
29  */
30 void
32 rle_hdr * the_hdr;
33 rle_op ** raw;
34 int * nraw;
35 rle_pixel ** outrows;
36 {
37  register int i, j;
38  register rle_pixel * outptr;
39  int chan;
40 
41  for (chan = -the_hdr->alpha; chan < the_hdr->ncolors; chan++)
42  if ( RLE_BIT( *the_hdr, chan ) )
43  {
44  if ( chan >= 0 && the_hdr->background == 2 && the_hdr->bg_color &&
45  the_hdr->bg_color[chan] != 0 )
46  {
47  j = the_hdr->bg_color[chan];
48  for ( i = the_hdr->xmin,
49  outptr = &outrows[chan][the_hdr->xmin];
50  i <= the_hdr->xmax;
51  i++, outptr++ )
52  *outptr = j;
53  }
54  else
55  bzero( (char *)&outrows[chan][the_hdr->xmin],
56  the_hdr->xmax - the_hdr->xmin + 1 );
57 
58  for( i = 0; i < nraw[chan]; i++ )
59  {
60  outptr = &(outrows[chan][raw[chan][i].xloc]);
61  switch (raw[chan][i].opcode)
62  {
63  case RByteDataOp:
64  bcopy( (char *)raw[chan][i].u.pixels, (char *)outptr,
65  raw[chan][i].length );
66  break;
67 
68  case RRunDataOp:
69  for ( j = raw[chan][i].length; j > 0; j--)
70  *(outptr++) = (rle_pixel) raw[chan][i].u.run_val;
71  break;
72  }
73  }
74  }
75 }
#define RRunDataOp
Definition: rle_code.h:41
int xmin
Definition: rle.h:100
int length
Definition: rle_raw.h:51
int opcode
Definition: rle_raw.h:49
int * bg_color
Definition: rle.h:100
void rle_rawtorow(rle_hdr *the_hdr, rle_op **raw, int *nraw, rle_pixel **outrows)
Definition: rle_rawrow.c:31
int xloc
Definition: rle_raw.h:50
int xmax
Definition: rle.h:100
int background
Definition: rle.h:100
unsigned char rle_pixel
Definition: rle.h:56
int alpha
Definition: rle.h:100
int ncolors
Definition: rle.h:100
#define RByteDataOp
Definition: rle_code.h:40
#define RLE_BIT(glob, bit)
Definition: rle.h:126