14 |
|
#include <math.h> |
15 |
|
|
16 |
|
#include "platform.h" |
17 |
+ |
#include "rtio.h" |
18 |
|
#include "rtmisc.h" |
19 |
|
#include "color.h" |
20 |
|
#include "resolu.h" |
28 |
|
#define my_mapType(h) ((h)->mapType==CM_HASMAP && \ |
29 |
|
((h)->CMapBits==24 || (h)->CMapBits==32)) |
30 |
|
|
31 |
< |
#define taralloc(h) (BYTE *)emalloc((h)->x*(h)->y) |
31 |
> |
#define taralloc(h) (uby8 *)emalloc((h)->x*(h)->y) |
32 |
|
|
33 |
< |
BYTE clrtab[256][3]; |
33 |
> |
uby8 clrtab[256][3]; |
34 |
|
extern int samplefac; |
35 |
|
double gamv = 2.2; /* gamv correction */ |
36 |
|
int bradj = 0; /* brightness adjustment */ |
37 |
|
char *progname; |
38 |
|
char errmsg[128]; |
39 |
|
COLR *inl; |
40 |
< |
BYTE *tarData; |
40 |
> |
uby8 *tarData; |
41 |
|
int xmax, ymax; |
42 |
|
|
43 |
|
static int getint2(FILE *fp); |
49 |
|
static void tg2ra(struct hdStruct *hp); |
50 |
|
static void getmapped(int nc, int dith); |
51 |
|
static void getgrey(int nc); |
52 |
< |
static void writetarga(struct hdStruct *h, BYTE *d, FILE *fp); |
53 |
< |
static void readtarga(struct hdStruct *h, BYTE *data, FILE *fp); |
52 |
> |
static void writetarga(struct hdStruct *h, uby8 *d, FILE *fp); |
53 |
> |
static void readtarga(struct hdStruct *h, uby8 *data, FILE *fp); |
54 |
|
|
55 |
|
|
56 |
|
int |
310 |
|
) |
311 |
|
{ |
312 |
|
union { |
313 |
< |
BYTE c3[256][3]; |
314 |
< |
BYTE c4[256][4]; |
313 |
> |
uby8 c3[256][3]; |
314 |
> |
uby8 c4[256][4]; |
315 |
|
} map; |
316 |
|
COLR ctab[256]; |
317 |
|
COLR *scanline; |
411 |
|
) |
412 |
|
{ |
413 |
|
int y; |
414 |
< |
register BYTE *dp; |
414 |
> |
register uby8 *dp; |
415 |
|
register int x; |
416 |
|
|
417 |
|
setcolrgam(gamv); |
442 |
|
static void |
443 |
|
writetarga( /* write out targa data */ |
444 |
|
struct hdStruct *h, |
445 |
< |
BYTE *d, |
445 |
> |
uby8 *d, |
446 |
|
FILE *fp |
447 |
|
) |
448 |
|
{ |
452 |
|
for (j = 2; j >= 0; j--) |
453 |
|
putc(clrtab[i][j], fp); |
454 |
|
if (h->dataType == IM_CMAP) { /* uncompressed */ |
455 |
< |
if (fwrite((char *)d,h->x*sizeof(BYTE),h->y,fp) != h->y) |
455 |
> |
if (fwrite((char *)d,h->x*sizeof(uby8),h->y,fp) != h->y) |
456 |
|
quiterr("error writing targa file"); |
457 |
|
return; |
458 |
|
} |
463 |
|
static void |
464 |
|
readtarga( /* read in targa data */ |
465 |
|
struct hdStruct *h, |
466 |
< |
BYTE *data, |
466 |
> |
uby8 *data, |
467 |
|
FILE *fp |
468 |
|
) |
469 |
|
{ |
470 |
|
register int cnt, c; |
471 |
< |
register BYTE *dp; |
471 |
> |
register uby8 *dp; |
472 |
|
|
473 |
|
if (h->dataType == IM_CMAP) { /* uncompressed */ |
474 |
< |
if (fread((char *)data,h->x*sizeof(BYTE),h->y,fp) != h->y) |
474 |
> |
if (fread((char *)data,h->x*sizeof(uby8),h->y,fp) != h->y) |
475 |
|
goto readerr; |
476 |
|
return; |
477 |
|
} |