c - libtiff error: Old-style JPEG compression support is not configured -
while converting tiff bmp using libtiff on mac os x, got these errors:
scannerdata.tif: old-style jpeg compression support not configured. scannerdata.tif: sorry, requested compression method not configured.
i using libtiff in mac os x.
my implementation of tiff bmp:
static void tifftobmp(char *colormode){ dbg(1, ">> tifftobmp \n"); /* files , file header */ char infile[path_max] = {0}; char outfile[path_max] = {0}; char tempfile[path_max] = {0}; tiff *tiffile; file *bmpfile, *tmpbitmapfile; uint32 image_width, image_height, long_val, short_val; /* colour table */ unsigned char padding; unsigned short i; unsigned char value; /* image information */ image_information *image_info; image_info = (image_information *)malloc(sizeof(image_information)); sprintf(infile, tiff_image_data); sprintf(outfile, bmp_image_data); sprintf(tempfile, temp_image_data); /* open necessary files */ tiffile = tiffopen(infile, "r"); if (!tiffile){ dbg(128, "can't open %s reading\n", infile); tiffclose(tiffile); } bmpfile = fopen(outfile, "wb"); if (!bmpfile){ dbg(128, "can't open %s writing\n", outfile); fclose(bmpfile); } tmpbitmapfile = fopen(tempfile, "wb"); if (!tmpbitmapfile){ dbg(128, "can't open %s writing\n", tempfile); fclose(tmpbitmapfile); } tiffgetfield(tiffile, tifftag_imagelength, &image_height); tiffgetfield(tiffile, tifftag_imagewidth, &image_width); image_info->img_height = image_height; image_info->img_width = image_width; /* image info color */ if(strcmp(colormode,"color") == 0){ get_image_info_color(image_info); }else if (strcmp(colormode,"gray") == 0){ get_image_info_gray(image_info); }else if(strcmp(colormode,"mono") == 0){ get_image_info_mono(image_info); } /* set header */ fwrite("bm", 1, 2, bmpfile); /* signature */ long_val = sizeof(bitmapfileheader) + sizeof(bitmapinfoheader) + image_info->img_scansize * image_info->img_height; fwrite(&long_val, 4, 1, bmpfile); /* size in bytes of bitmap file */ short_val = 0; fwrite(&short_val, 2, 1, bmpfile); /* reserved, set 0 */ fwrite(&short_val, 2, 1, bmpfile); /* reserved, set 0 */ if(strcmp(colormode,"color") == 0){ /* offset of image file start */ long_val = 54; }else{ long_val = 54 + (4 * (1 << image_info->img_bits_per_pixel)); } fwrite(&long_val, 4, 1, bmpfile); long_val = sizeof(bitmapinfoheader); /* size of bmpinfoheader structure */ fwrite(&long_val, 4, 1, bmpfile); fwrite(&image_info->img_width, 4, 1, bmpfile); fwrite(&image_info->img_height, 4, 1, bmpfile); short_val = 1; /* number of image planes */ fwrite(&short_val, 2, 1, bmpfile); if(strcmp(colormode,"mono") == 0){ /* number of bits per pixel */ short_val = image_info->img_bits_per_pixel; }else if (strcmp(colormode,"color") == 0){ short_val = image_info->img_bits_per_pixel; }else if (strcmp(colormode,"gray") == 0){ short_val = image_info->img_bits_per_pixel; } fwrite(&short_val, 2, 1, bmpfile); long_val = 0; /* compression method */ fwrite(&long_val, 4, 1, bmpfile); long_val = 0; /* size of uncompressed image in bytes */ fwrite(&long_val, 4, 1, bmpfile); long_val = 0; /* x resolution, pixels per meter */ fwrite(&long_val, 4, 1, bmpfile); long_val = 0; /* y resolution, pixels per meter */ fwrite(&long_val, 4, 1, bmpfile); if(strcmp(colormode,"color") == 0){ /* size of colour table */ long_val = 0; }else{ long_val = 1 << image_info->img_bits_per_pixel; } fwrite(&long_val, 4, 1, bmpfile); long_val = 0; /* number of important colours */ fwrite(&long_val, 4, 1, bmpfile); /* colour table */ if(strcmp(colormode,"mono") == 0){ value = 0xff; padding = 0; /* white */ fwrite(&value, 1, 1, bmpfile); /* r component */ fwrite(&value, 1, 1, bmpfile); /* g component */ fwrite(&value, 1, 1, bmpfile); /* b component */ fwrite(&padding, 1, 1, bmpfile); /* padding */ /* black */ value = 0x00; fwrite(&value, 1, 1, bmpfile); /* r component */ fwrite(&value, 1, 1, bmpfile); /* g component */ fwrite(&value, 1, 1, bmpfile); /* b component */ fwrite(&padding, 1, 1, bmpfile); /* padding */ }else if (strcmp(colormode,"gray") == 0){ padding = 0; ( = 0; <= 255; i++ ){ fwrite(&i, 1, 1, bmpfile); /* r component */ fwrite(&i, 1, 1, bmpfile); /* g component */ fwrite(&i, 1, 1, bmpfile); /* b component */ fwrite(&padding, 1, 1, bmpfile); /* padding */ } } /* read , write image */ if(strcmp(colormode,"mono") == 0){ read_mono_image(tiffile, tmpbitmapfile, image_info); }else if(strcmp(colormode,"gray") == 0){ read_gray_image(tiffile, tmpbitmapfile, image_info); }else if(strcmp(colormode,"color") == 0){ read_color_image(tiffile, bmpfile, image_info); } if(strcmp(colormode,"color") != 0){ fclose(tmpbitmapfile); flip_image(image_info, bmpfile); } fclose(bmpfile); tiffclose(tiffile); dbg(1, "<< tifftobmp \n"); }
take @ source code of libtiff in "nmake.opt"
# # uncomment , edit following lines enable jpeg support. # #jpeg_support = 1
...
!ifdef jpeg_support libs = $(libs) $(jpeg_lib) extraflags = -djpeg_support -dojpeg_support $(extraflags) !endif
so, default jpeg support not enabled.
Comments
Post a Comment