#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 |
|
|
static char * | Malloc (long int) |
|
static char * | read_file (FILE *, int *) |
|
static long | filelen (FILE *) |
|
static int | read_alias (FILE *, bitmap_hdr *) |
|
static void | write_rle (FILE *, bitmap_hdr *) |
|
static void | read_alias_header (FILE *, alias_hdr *) |
|
static void | create_alias_cmap (bitmap_hdr *) |
|
static void | uncode_alias24 (unsigned char *, unsigned char *, unsigned char *, unsigned char *, unsigned char *) |
|
static void | uncode_alias (unsigned char *, unsigned char *, unsigned char *) |
|
static int | read_line_alias24 (FILE *, unsigned char *, unsigned char *, unsigned char *, int) |
|
static int | read_line_alias (FILE *, unsigned char *, int) |
|
static void | error (int) |
|
void | main (int argc, char **argv) |
|
static void | bitmapcmap_to_rlecmap (bitmap_hdr *bitmap, rle_hdr *rle) |
|
|
static char | rcs_id [] = "$Header: /l/spencer/src/urt/cnv/RCS/aliastorle.c,v 3.0.1.1 1992/04/29 20:01:12 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) |
Definition at line 399 of file aliastorle.c.
417 for (i= 0; i< bitmap->
colors; i++) {
418 *rch++ = (*ptr++ << 8);
419 *gch++ = (*ptr++ << 8);
420 *bch++ = (*ptr++ << 8);
static char * Malloc(long int)
static void create_alias_cmap |
( |
bitmap_hdr * |
image | ) |
|
|
static |
static void error |
( |
int |
code | ) |
|
|
static |
Definition at line 559 of file aliastorle.c.
566 case 1: fprintf(stderr,
"Cannot open file\n");
568 case 2: fprintf(stderr,
"Out of memory\n");
570 case 3: fprintf(stderr,
"Error while reading input file\n");
572 case 4: fprintf(stderr,
"Error while writing output file\n");
574 case 5: fprintf(stderr,
"Input file is not an Alias pix\n");
576 case 6: fprintf(stderr,
"File corrupt ( uncompress too bytes )\n");
578 case 99: fprintf(stderr,
"Not ready\n");
580 default: fprintf(stderr,
"Unknow error code (%d)\n", code);
static long filelen |
( |
FILE * |
handle | ) |
|
|
static |
Definition at line 643 of file aliastorle.c.
650 current_pos= ftell(handle);
657 fseek(handle, current_pos, 0);
void main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 121 of file aliastorle.c.
126 char *outname = NULL;
136 if ( !
scanargs( argc, argv,
"% v%- o%-outfile!s infile%s",
137 &
verbose, &oflag, &outname, &inname ))
int scanargs(int argc, char **argv, const char *format,...)
static int read_alias(FILE *, bitmap_hdr *)
static void write_rle(FILE *, bitmap_hdr *)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
void rle_close_f(FILE *fd)
gpr_ $bitmap_desc_t bitmap
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
char * cmd_name(char **argv)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
static char * Malloc |
( |
long int |
size | ) |
|
|
static |
Definition at line 163 of file aliastorle.c.
187 can_read_all = (handle != stdin);
188 VPRINTF(stderr,
"Reading Alias from %s\n",
189 (can_read_all ?
"file" :
"stdin"));
197 VPRINTF(stderr,
"File size: %d\n", filesize);
206 VPRINTF(stderr,
"Reading Alias header\n");
218 allplanes = ( image->
depth > 8 );
237 cmapsize= image->
colors * 3;
240 VPRINTF(stderr,
"Creating cmap\n");
247 VPRINTF(stderr,
"Uncompressing Alias file\n");
252 end = r + total_size;
266 xsize = image->
xsize;
267 for (i= 0; i< image->
ysize; i++) {
281 fprintf(stderr,
"Error while reading line %d\n", i);
static char * read_file(FILE *, int *)
static void uncode_alias(unsigned char *, unsigned char *, unsigned char *)
static void read_alias_header(FILE *, alias_hdr *)
static int read_line_alias(FILE *, unsigned char *, int)
static void uncode_alias24(unsigned char *, unsigned char *, unsigned char *, unsigned char *, unsigned char *)
static int read_line_alias24(FILE *, unsigned char *, unsigned char *, unsigned char *, int)
static void create_alias_cmap(bitmap_hdr *)
static char * Malloc(long int)
static void read_alias_header |
( |
FILE * |
handle, |
|
|
alias_hdr * |
header |
|
) |
| |
|
static |
Definition at line 299 of file aliastorle.c.
307 if ( header->
xsize < 1 || header ->
xsize > 2560 ||
310 if ( header->
depth > 24 || header->
depth < 1 )
#define Fread(p, s, n, f)
static char * read_file |
( |
FILE * |
handle, |
|
|
int * |
bytes |
|
) |
| |
|
static |
Definition at line 607 of file aliastorle.c.
617 buffer= (
char *)
Malloc(*bytes);
620 Fread(buffer, (
int) (*bytes), 1, handle);
624 int n = 0, bufsize = 0;
626 buffer =
Malloc( BUFSIZ );
627 while ( (n = fread( buffer + bufsize, 1, BUFSIZ, handle )) == BUFSIZ )
630 buffer = realloc( buffer, bufsize + BUFSIZ );
static long filelen(FILE *)
#define Fread(p, s, n, f)
static char * Malloc(long int)
#define RLE_CHECK_ALLOC(pgm, ptr, name)
static int read_line_alias |
( |
FILE * |
handle, |
|
|
unsigned char * |
r, |
|
|
int |
size |
|
) |
| |
|
static |
Definition at line 349 of file aliastorle.c.
355 register int count = 0;
360 while (count < size) {
364 if ( !fread(buffer, 2, 1, handle) )
369 for (i= 0; i< buffer[0]; i++) {
static int read_line_alias24 |
( |
FILE * |
handle, |
|
|
unsigned char * |
r, |
|
|
unsigned char * |
g, |
|
|
unsigned char * |
b, |
|
|
int |
size |
|
) |
| |
|
static |
Definition at line 315 of file aliastorle.c.
321 register int count = 0;
326 while (count < size) {
330 if ( !fread(buffer, 4, 1, handle) )
335 for (i= 0; i< buffer[0]; i++) {
static void uncode_alias |
( |
unsigned char * |
ptr, |
|
|
unsigned char * |
rbuf, |
|
|
unsigned char * |
end |
|
) |
| |
|
static |
static void uncode_alias24 |
( |
unsigned char * |
ptr, |
|
|
unsigned char * |
rbuf, |
|
|
unsigned char * |
gbuf, |
|
|
unsigned char * |
bbuf, |
|
|
unsigned char * |
end |
|
) |
| |
|
static |
static void write_rle |
( |
FILE * |
handle, |
|
|
bitmap_hdr * |
image |
|
) |
| |
|
static |
Definition at line 473 of file aliastorle.c.
482 VPRINTF(stderr,
"Writing RLE file\n");
491 if (image->
depth > 8) {
512 VPRINTF(stderr,
"Compressing RLE lines\n");
513 if (image->
depth > 8) {
524 row[0] = image->
r + offset_last;
525 row[1] = image->
g + offset_last;
526 row[2] = image->
b + offset_last;
529 for (i= 0; i< image->
ysize; i++) {
534 for ( j = 0; j < 3; j++ )
535 row[0] -= image->
xsize;
545 r = image->
r + offset_last;
546 for (i= 0; i< image->
ysize; i++) {
void rle_putrow(rle_pixel *rows[], int rowlen, rle_hdr *the_hdr)
void rle_puteof(rle_hdr *the_hdr)
static void bitmapcmap_to_rlecmap(bitmap_hdr *bitmap, rle_hdr *rle)
static char * Malloc(long int)
void rle_put_setup(rle_hdr *the_hdr)
char rcs_id[] = "$Header: /l/spencer/src/urt/cnv/RCS/aliastorle.c,v 3.0.1.1 1992/04/29 20:01:12 spencer Exp $" |
|
static |