8 |
|
* 8/22/88 Adapted from ra_pr.c |
9 |
|
*/ |
10 |
|
|
11 |
– |
#include <stdio.h> |
12 |
– |
#include <string.h> |
13 |
– |
#include <time.h> |
11 |
|
#include <math.h> |
12 |
|
|
13 |
|
#include "platform.h" |
14 |
+ |
#include "rtio.h" |
15 |
|
#include "rtmisc.h" |
16 |
|
#include "color.h" |
17 |
|
#include "resolu.h" |
25 |
|
#define my_mapType(h) ((h)->mapType==CM_HASMAP && \ |
26 |
|
((h)->CMapBits==24 || (h)->CMapBits==32)) |
27 |
|
|
28 |
< |
#define taralloc(h) (BYTE *)emalloc((h)->x*(h)->y) |
28 |
> |
#define taralloc(h) (uby8 *)emalloc((h)->x*(h)->y) |
29 |
|
|
30 |
< |
BYTE clrtab[256][3]; |
30 |
> |
uby8 clrtab[256][3]; |
31 |
|
extern int samplefac; |
32 |
|
double gamv = 2.2; /* gamv correction */ |
33 |
|
int bradj = 0; /* brightness adjustment */ |
34 |
|
char *progname; |
35 |
|
char errmsg[128]; |
36 |
|
COLR *inl; |
37 |
< |
BYTE *tarData; |
37 |
> |
uby8 *tarData; |
38 |
|
int xmax, ymax; |
39 |
|
|
40 |
|
static int getint2(FILE *fp); |
46 |
|
static void tg2ra(struct hdStruct *hp); |
47 |
|
static void getmapped(int nc, int dith); |
48 |
|
static void getgrey(int nc); |
49 |
< |
static void writetarga(struct hdStruct *h, BYTE *d, FILE *fp); |
50 |
< |
static void readtarga(struct hdStruct *h, BYTE *data, FILE *fp); |
49 |
> |
static void writetarga(struct hdStruct *h, uby8 *d, FILE *fp); |
50 |
> |
static void readtarga(struct hdStruct *h, uby8 *data, FILE *fp); |
51 |
|
|
52 |
|
|
53 |
|
int |
307 |
|
) |
308 |
|
{ |
309 |
|
union { |
310 |
< |
BYTE c3[256][3]; |
311 |
< |
BYTE c4[256][4]; |
310 |
> |
uby8 c3[256][3]; |
311 |
> |
uby8 c4[256][4]; |
312 |
|
} map; |
313 |
|
COLR ctab[256]; |
314 |
|
COLR *scanline; |
408 |
|
) |
409 |
|
{ |
410 |
|
int y; |
411 |
< |
register BYTE *dp; |
411 |
> |
register uby8 *dp; |
412 |
|
register int x; |
413 |
|
|
414 |
|
setcolrgam(gamv); |
439 |
|
static void |
440 |
|
writetarga( /* write out targa data */ |
441 |
|
struct hdStruct *h, |
442 |
< |
BYTE *d, |
442 |
> |
uby8 *d, |
443 |
|
FILE *fp |
444 |
|
) |
445 |
|
{ |
449 |
|
for (j = 2; j >= 0; j--) |
450 |
|
putc(clrtab[i][j], fp); |
451 |
|
if (h->dataType == IM_CMAP) { /* uncompressed */ |
452 |
< |
if (fwrite((char *)d,h->x*sizeof(BYTE),h->y,fp) != h->y) |
452 |
> |
if (fwrite((char *)d,h->x*sizeof(uby8),h->y,fp) != h->y) |
453 |
|
quiterr("error writing targa file"); |
454 |
|
return; |
455 |
|
} |
460 |
|
static void |
461 |
|
readtarga( /* read in targa data */ |
462 |
|
struct hdStruct *h, |
463 |
< |
BYTE *data, |
463 |
> |
uby8 *data, |
464 |
|
FILE *fp |
465 |
|
) |
466 |
|
{ |
467 |
|
register int cnt, c; |
468 |
< |
register BYTE *dp; |
468 |
> |
register uby8 *dp; |
469 |
|
|
470 |
|
if (h->dataType == IM_CMAP) { /* uncompressed */ |
471 |
< |
if (fread((char *)data,h->x*sizeof(BYTE),h->y,fp) != h->y) |
471 |
> |
if (fread((char *)data,h->x*sizeof(uby8),h->y,fp) != h->y) |
472 |
|
goto readerr; |
473 |
|
return; |
474 |
|
} |