#include <stdio.h>
#include <math.h>
#include "rle.h"
Go to the source code of this file.
#define incr |
( |
|
bp, |
|
|
|
fudge |
|
) |
| |
Value:bp += strlen( bp ); \
{ \
bp += strlen( bp ); \
}
Definition at line 253 of file rletovcr.c.
257 char *
infname = NULL, outfname = NULL;
259 unsigned char *VICARImage;
263 if (
scanargs( argc, argv,
"% v%- o%-outfile!s infile%s\n(\
264 \tConvert URT image to VICAR format (as currently understood).)",
265 &
VERBOSE, &oflag, &outfname, &infname ) == 0 )
int scanargs(int argc, char **argv, const char *format,...)
static unsigned char * read_image(rle_hdr *the_hdr)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
char * cmd_name(char **argv)
static void write_image(rle_hdr *the_hdr, FILE *outFD, unsigned char *VICARImage)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
static unsigned char* read_image |
( |
rle_hdr * |
the_hdr | ) |
|
|
static |
Definition at line 173 of file rletovcr.c.
177 unsigned char *VICARImage;
189 "%s: Only black & white images can be converted to VICAR.\n",
192 fprintf( stderr,
"\t%s has %d colors.\n",
195 fprintf( stderr,
"\t%s has a color map.\n",
203 width = the_hdr->
xmax + 1;
204 height = the_hdr->
ymax - the_hdr->
ymin + 1;
206 VICARImage = (
unsigned char *)
malloc(width * height);
210 for ( y = the_hdr->
ymin; y <= the_hdr->ymax; y++ )
212 rows[0] = VICARImage + width * (the_hdr->
ymax -
y);
#define RLE_CLR_BIT(glob, bit)
void rle_get_setup_ok(rle_hdr *the_hdr, const char *prog_name, const char *file_name)
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
#define RLE_CHECK_ALLOC(pgm, ptr, name)
static void write_image |
( |
rle_hdr * |
the_hdr, |
|
|
FILE * |
outFD, |
|
|
unsigned char * |
VICARImage |
|
) |
| |
|
static |
Definition at line 221 of file rletovcr.c.
228 if (
VERBOSE) fprintf(stderr,
"%s: Writing VICARHeader\n", the_hdr->
cmd);
230 width = the_hdr->
xmax - the_hdr->
xmin + 1;
231 height = the_hdr->
ymax - the_hdr->
ymin + 1;
234 if (
VERBOSE) fprintf(stderr,
"%s: Writing VICAR image", the_hdr->
cmd);
236 for ( y = 0; y <
height; y++ )
239 if (
VERBOSE) fprintf(stderr,
".");
242 if (
VERBOSE) fprintf(stderr,
"\n");
245 fprintf(stderr,
"%s: Error writing image\n", the_hdr->
cmd);
248 fprintf(stderr,
"%s: finished writing the image\n", the_hdr->
cmd);
WriteVICARHeader(FILE *fd, int width, int height, int BandsPerPixel)
static void WriteVICARScanLine(FILE *fd, unsigned char *VICARScanLine, int VICARScanLineLength)
WriteVICARHeader |
( |
FILE * |
fd, |
|
|
int |
width, |
|
|
int |
height, |
|
|
int |
BandsPerPixel |
|
) |
| |
Definition at line 86 of file rletovcr.c.
107 #define incr(bp,fudge) \
108 bp += strlen( bp ); \
109 if ( bp - buffer + fudge > LBLSIZE ) \
111 bp = buffer = realloc( buffer, LBLSIZE += width ); \
112 bp += strlen( bp ); \
115 sprintf(bp,
"LBLSIZE=%-d ",
LBLSIZE);
117 sprintf(bp,
" FORMAT='BYTE'");
119 sprintf(bp,
" TYPE='IMAGE'");
121 sprintf(bp,
" BUFSIZ=%-d",20*
LBLSIZE);
123 sprintf(bp,
" DIM=3");
125 sprintf(bp,
" EOL=0");
127 sprintf(bp,
" RECSIZE=%-d",
LBLSIZE);
129 sprintf(bp,
" ORG='BSQ'");
131 sprintf(bp,
" NL=%-d",
height);
133 sprintf(bp,
" NS=%-d",
width);
137 sprintf(bp,
" N1=%-d",
height);
139 sprintf(bp,
" N2=%-d",
width);
145 sprintf(bp,
" NBB=0");
147 sprintf(bp,
" NLB=0");
149 sprintf(bp,
" COMMENT='created by rletovcr'");
155 sprintf( buffer,
"LBLSIZE=%-d",
LBLSIZE );
157 while ( bp < buffer +
LBLSIZE )
static void WriteVICARScanLine |
( |
FILE * |
fd, |
|
|
unsigned char * |
VICARScanLine, |
|
|
int |
VICARScanLineLength |
|
) |
| |
|
static |
Definition at line 164 of file rletovcr.c.
169 (void)fwrite(VICARScanLine, 1, VICARScanLineLength,
fd);