74 #include <sys/types.h>
78 #define GETSHORT(N) (((unsigned short)(*(N+1
))<<8
) + (unsigned short)(*(N)))
120 unsigned char getbyte();
140 "% h%-hdrfile!s n%-nchannels!d o%-outfile!s infile%s\n(\
141 \tConvert TARGA file to URT format.\n\
142 \t-h\tSpecify separate header file.\n\
143 \t-n\tNumber of channels to write, defaults to same as input.)",
145 &oflag
, &outfname
, &infname
) == 0 )
158 if ( hdrfile == outfile )
161 "%s: Can't write header and RLE data to same file.\n",
170 fprintf(stderr,
"targatorle: Read Error.\n");
200 fprintf (hdrfile,
"Color Map Type = 0 \n");
206 fprintf (hdrfile,
"cmap_origin = %u \n",
208 fprintf (hdrfile,
"cmap_length = %u \n",
210 fprintf (hdrfile,
"cmap_size = %u \n",
216 "%s: Invalid Color Map Type Code (%d)\n", out_hdr
.cmd,
222 fprintf (hdrfile,
"image_x_origin = %u \n",
224 fprintf (hdrfile,
"image_y_origin = %u \n",
226 fprintf (hdrfile,
"image_width = %u \n",
228 fprintf (hdrfile,
"image_height = %u \n",
230 fprintf (hdrfile,
"image_pix_size = %u \n",
242 fprintf(stderr,
"%s: Image file is header only, no data.\n",
282 fprintf(stderr,
"%s: Image type (%d) not supported by this program.\n",
293 fprintf(stderr,
"%s: B/W image pixel size must be 8.\n", out_hdr
.cmd);
304 "%s: Real-color image pixel size must be 16, 24 or 32.\n",
336 fprintf (stderr,
"%s: Invalid color map width (%u bits)\n",
380 fprintf(stderr,
"%s: Image is too large for this program.\n",
421 for (j=0;j<numpix;j++)
redline[j] = getbyte();
426 for (j=0;j<numpix;j++)
428 pxltmp = (
unsigned)getbyte();
429 pxltmp |= ((
unsigned)getbyte())<<8;
431 bluline[j] = (pxltmp & 0x1f) << 3;
432 grnline[j] = ((pxltmp >> 5) & 0x1f) << 3;
433 redline[j] = ((pxltmp >> 10) & 0x1f) << 3;
434 alfline[j] = ((pxltmp & 0x8000) ? 0xff : 0);
440 for (j=0;j<numpix;j++)
451 fprintf(stderr,
"targatorle: Invalid pixel size (%d bytes) for this program.\n",
461 unsigned char getbyte()
465 unsigned char pixdata[4];
471 next = (
unsigned)getc(
infile)&0xff;
486 *(pp++) = pixdata[j];
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
#define RLE_SET_BIT(glob, bit)
unsigned char image_pix_size
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
unsigned short image_width
char * cmd_name(char **argv)
void main(int argc, char **argv)
unsigned char image_descriptor
unsigned char rlbuf[4 *128]
int scanargs(int argc, char **argv, const char *format,...)
void rle_puteof(rle_hdr *the_hdr)
void rle_putrow(rows, int rowlen, rle_hdr *the_hdr)
void rle_addhist(argv, rle_hdr *in_hdr, rle_hdr *out_hdr)
unsigned short cmap_origin
unsigned short image_x_origin
void rle_put_setup(rle_hdr *the_hdr)
unsigned short cmap_length
struct targafile tga_head
unsigned char num_char_id
unsigned short image_height
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
unsigned short image_y_origin
unsigned char * outrows[4]
unsigned char * cmap_data