#include <stdio.h>
#include <math.h>
#include "rle.h"
Go to the source code of this file.
|
#define | byte unsigned char |
|
#define | Fread(p, s, n, f) if ( fread(p, s, n, f) != n ) error(3) |
|
#define | Fwrite(p, s, n, f) if ( fwrite(p, s, n, f) != n ) error(4) |
|
#define | VPRINTF if (verbose) fprintf |
|
#define | PSEUDOCOLOR 1 |
|
#define | DIRECTCOLOR 2 |
|
#define | TRUECOLOR 3 |
|
#define | GRAYSCALE 4 |
|
|
static char | rcs_id [] = "$Header: /l/spencer/src/urt/cnv/RCS/rletoalias.c,v 3.0.1.1 1992/04/30 13:58:47 spencer Exp $" |
|
int | verbose = 0 |
|
rle_hdr | the_hdr |
|
#define byte unsigned char |
#define Fread |
( |
|
p, |
|
|
|
s, |
|
|
|
n, |
|
|
|
f |
|
) |
| if ( fread(p, s, n, f) != n ) error(3) |
#define Fwrite |
( |
|
p, |
|
|
|
s, |
|
|
|
n, |
|
|
|
f |
|
) |
| if ( fwrite(p, s, n, f) != n ) error(4) |
typedef unsigned char color_map[3] |
static void code_alias24 |
( |
unsigned char * |
rbuf, |
|
|
unsigned char * |
gbuf, |
|
|
unsigned char * |
bbuf, |
|
|
int |
xmax, |
|
|
FILE * |
handle |
|
) |
| |
|
static |
Definition at line 371 of file rletoalias.c.
377 unsigned int number= 0;
391 if (r== *
rbuf && g== *
gbuf && b== *
bbuf && repeat < 255) {
419 Fwrite(buf, number, 1, handle);
#define Fwrite(p, s, n, f)
static void error |
( |
int |
code | ) |
|
|
static |
Definition at line 423 of file rletoalias.c.
428 case 0: fprintf(stderr,
"Usage: %s [-v] [-o outfile] [infile] \n",
431 case 1: fprintf(stderr,
"Cannot open file.\n");
433 case 2: fprintf(stderr,
"Out of memory.\n");
435 case 3: fprintf(stderr,
"Error while reading input file\n");
437 case 4: fprintf(stderr,
"Error while writing output file\n");
439 case 5: fprintf(stderr,
"Input file is not an Alias pix\n");
441 case 6: fprintf(stderr,
"Incorrect # of planes or # of colors\n");
443 case 99: fprintf(stderr,
"Not ready\n");
445 default: fprintf(stderr,
"Unknow erro code (%d)\n", code);
void main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 112 of file rletoalias.c.
117 char *outname = NULL;
127 if ( !
scanargs( argc, argv,
"% v%- o%-outfile!s infile%s",
128 &
verbose, &oflag, &outname, &inname ))
int scanargs(int argc, char **argv, const char *format,...)
static void read_rle(FILE *, bitmap_hdr *)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
gpr_ $bitmap_desc_t bitmap
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
static void write_alias(FILE *, bitmap_hdr *)
char * cmd_name(char **argv)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
static char * Malloc |
( |
long int |
size | ) |
|
|
static |
static void read_rle |
( |
FILE * |
handle, |
|
|
bitmap_hdr * |
image |
|
) |
| |
|
static |
Definition at line 156 of file rletoalias.c.
183 offset_last = totalsize - image->
xsize;
184 two_lines = 2 * image->
xsize;
187 VPRINTF(stderr,
"%s colormap\n",
193 VPRINTF(stderr,
"Image type ");
197 VPRINTF(stderr,
"GRAYSCALE\n");
200 VPRINTF(stderr,
"PSEUDOCOLOR\n");
202 default:
VPRINTF(stderr,
"unkown\n");
209 VPRINTF(stderr,
"DIRECTCOLOR\n");
212 VPRINTF(stderr,
"TRUECOLOR\n");
214 default:
VPRINTF(stderr,
"unkown\n");
256 VPRINTF(stderr,
"Uncompressing RLE file\n");
260 for (j= 0; j< image->
ysize; j++) {
275 *r++ = map[row[0][
i]][0];
276 *g++ = map[row[1][
i]][1];
277 *
b++ = map[row[2][
i]][
i];
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
unsigned char color_map[3]
static void rlecmap_to_bitmapcmap(rle_hdr *, bitmap_hdr *)
static char * Malloc(long int)
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[])
Definition at line 300 of file rletoalias.c.
317 for (i= 0; i< bitmap->
colors; i++) {
318 *ptr++ = (
byte) (*rch++ >> 8);
319 *ptr++ = (
byte) (*gch++ >> 8);
320 *ptr++ = (
byte) (*bch++ >> 8);
static char * Malloc(long int)
static void write_alias |
( |
FILE * |
handle, |
|
|
bitmap_hdr * |
image |
|
) |
| |
|
static |
Definition at line 325 of file rletoalias.c.
337 if (image->
depth <= 8) {
338 fprintf(stderr,
"Bitmap with 8 planes\n");
342 VPRINTF(stderr,
"Writing Alias file\n");
357 for (i= 0; i< image->
ysize; i++) {
364 rbuf += image->
xsize;
365 gbuf += image->
xsize;
366 bbuf += image->
xsize;
static void code_alias24(unsigned char *, unsigned char *, unsigned char *, int, FILE *)
#define Fwrite(p, s, n, f)
char rcs_id[] = "$Header: /l/spencer/src/urt/cnv/RCS/rletoalias.c,v 3.0.1.1 1992/04/30 13:58:47 spencer Exp $" |
|
static |