- id_len = (unsigned char)tga[0];
- /*cmap_type = (unsigned char)tga[1];*/
- image_type = (unsigned char)tga[2];
- /*cmap_index = get_ushort(*(unsigned short*)(&tga[3]));*/
- cmap_len = get_ushort(*(unsigned short*)(&tga[5]));
- cmap_entry_size = (unsigned char)tga[7];
+ id_len = tga[0];
+ /*cmap_type = tga[1];*/
+ image_type = tga[2];
+ /*cmap_index = get_ushort(&tga[3]);*/
+ cmap_len = get_ushort(&tga[5]);
+ cmap_entry_size = tga[7];
- image_w = get_ushort(*(unsigned short*)(&tga[12]));
- image_h = get_ushort(*(unsigned short*)(&tga[14]));
- pixel_depth = (unsigned char)tga[16];
- image_desc = (unsigned char)tga[17];
+ image_w = get_ushort(&tga[12]);
+ image_h = get_ushort(&tga[14]);
+ pixel_depth = tga[16];
+ image_desc = tga[17];
if ( !fread(id, id_len, 1, fp) )
{
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
if ( !fread(id, id_len, 1, fp) )
{
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
v = *blue + adjustB; ++blue;
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
v = *blue + adjustB; ++blue;
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
- fprintf(fdest, "%c", (unsigned char)v);
- v = *blue++;
- if(v > 255) v = 255; else if(v < 0) v = 0;
+ fprintf(fdest, "%c", (unsigned char)v);
+ v = *blue++;
+ if(v > 255) v = 255; else if(v < 0) v = 0;
fprintf(stderr," is written to the file\n");
}
destname = (char*)malloc(strlen(outfile) + 8);
fprintf(stderr," is written to the file\n");
}
destname = (char*)malloc(strlen(outfile) + 8);
- if (ncomp > 1)
- {
- /*sprintf(destname, "%d.%s", compno, outfile);*/
- const size_t olen = strlen(outfile);
- const size_t dotpos = olen - 4;
-
- strncpy(destname, outfile, dotpos);
- sprintf(destname+dotpos, "_%u.pgm", compno);
- }
+ if (ncomp > 1)
+ {
+ /*sprintf(destname, "%d.%s", compno, outfile);*/
+ const size_t olen = strlen(outfile);
+ const size_t dotpos = olen - 4;
+
+ strncpy(destname, outfile, dotpos);
+ sprintf(destname+dotpos, "_%u.pgm", compno);
+ }
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
/* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);