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

Go to the source code of this file.

Functions

int rle_row_alloc (rle_hdr *the_hdr, rle_pixel ***scanp)
 
void rle_row_free (rle_hdr *the_hdr, rle_pixel **scanp)
 

Function Documentation

int rle_row_alloc ( rle_hdr the_hdr,
rle_pixel ***  scanp 
)

Definition at line 56 of file rle_row_alc.c.

Referenced by get_scanlines(), RLE::open:, write_ppm_data(), write_rlb_data(), and write_rle_data().

59 {
60  rle_pixel ** scanbuf, * pixbuf;
61  int rowlen, nchan = 0, i, ncol;
62 
63  rowlen = the_hdr->xmax + 1;
64  if ( the_hdr->alpha && RLE_BIT( *the_hdr, RLE_ALPHA ) )
65  nchan++;
66  for ( i = 0; i < the_hdr->ncolors; i++ )
67  if ( RLE_BIT( *the_hdr, i ) )
68  nchan++;
69 
70  ncol = the_hdr->ncolors + the_hdr->alpha;
71 
72  if ( (scanbuf = (rle_pixel **)malloc( ncol * sizeof(rle_pixel *) )) == 0 )
73  return -1;
74  if ( (pixbuf = (rle_pixel *)malloc( nchan * rowlen *
75  sizeof(rle_pixel) )) == 0 )
76  {
77  free( scanbuf );
78  return -1;
79  }
80 
81  if ( the_hdr->alpha )
82  scanbuf++;
83 
84  for ( i = -the_hdr->alpha; i < the_hdr->ncolors; i++ )
85  if ( RLE_BIT( *the_hdr, i ) )
86  {
87  scanbuf[i] = pixbuf;
88  pixbuf += rowlen;
89  }
90  else
91  scanbuf[i] = 0;
92  *scanp = scanbuf;
93 
94  return 0;
95 }
static gif_pixel ** scanbuf
Definition: rletogif.c:39
int xmax
Definition: rle.h:100
unsigned char rle_pixel
Definition: rle.h:56
void * malloc()
int i
Definition: rletorla.c:82
int alpha
Definition: rle.h:100
#define RLE_ALPHA
Definition: rle.h:65
int nchan
Definition: fant.c:104
int ncolors
Definition: rle.h:100
#define RLE_BIT(glob, bit)
Definition: rle.h:126

Here is the caller graph for this function:

void rle_row_free ( rle_hdr the_hdr,
rle_pixel **  scanp 
)

Definition at line 114 of file rle_row_alc.c.

Referenced by RLE::open:, write_ppm_data(), and write_rle_data().

117 {
118  int i;
119 
120  if ( the_hdr->alpha )
121  scanp--;
122  for ( i = 0; i < the_hdr->ncolors + the_hdr->alpha; i++ )
123  if ( scanp[i] != 0 )
124  {
125  free( (char *)scanp[i] );
126  break;
127  }
128  free( (char *)scanp );
129 }
int i
Definition: rletorla.c:82
int alpha
Definition: rle.h:100
int ncolors
Definition: rle.h:100

Here is the caller graph for this function: