Hello,
i found a little c-Source-code called "sff2tiff.c".
I was not able to compile it! There were missing header-files(like
tiffiop.h) and after i downloaded an other tifflib i still got errors
like "variable-size type declariation outside any function" and many,
many more...
I'am using SUSE Linux 6.3
I had to attach the source, because i don't remember where i found it -
Sorry!
Please help me! I need this prg!
Carsten
carsten.feh...@cityweb.de
p.S.: As you might have noticed, i am not an expert, so please keep your
answers simple..
[
sff2tiff2.c 15K ]
/* Umgeschrieben am 16.02. von a...@brickwedde.de
* mit dem Ziel sff-Dateien statt G3 einzulesen.
* Kaum Errorchecking, keine speziellen Funktionen...
* Originaldatei: "fax2tiff.c"
* Kompilieren mit "cc sff2tiff -L ../libtiff -ltiff -o sff2tiff"
* nachdem mit "configure" die passenden Headerdateien erzeugt wurden.
*/
/* $Header: /usr/people/sam/tiff/tools/RCS/fax2tiff.c,v 1.40 1996/01/10 19:35:27 sam Rel $ */
/*
* Copyright (c) 1990-1996 Sam Leffler
* Copyright (c) 1991-1996 Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the names of
* Sam Leffler and Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Sam Leffler and Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
/*
* Convert a CCITT Group 3 FAX file to TIFF Group 3 format.
*/
#include <stdio.h>
#include <stdlib.h> /* should have atof & getopt */
#include "tiffiop.h"
#ifndef BINMODE
#define BINMODE
#endif
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
#define XSIZE 1728
char rowbuf[TIFFhowmany(XSIZE,8)];
char refbuf[TIFFhowmany(XSIZE,8)];
unsigned char pow2[]={1,2,4,8,16,32,64,128};
int verbose;
int stretch;
uint16 badfaxrun;
uint32 badfaxlines;
typedef struct {
unsigned char bits[16];
unsigned char len;
unsigned int run;
unsigned char col;
{
{"00110101", 8, 0,0},
{"000111", 6, 1,0},
{"0111", 4, 2,0},
{"1000", 4, 3,0},
{"1011", 4, 4,0},
{"1100", 4, 5,0},
{"1110", 4, 6,0},
{"1111", 4, 7,0},
{"10011", 5, 8,0},
{"10100", 5, 9,0},
{"00111", 5, 10,0},
{"01000", 5, 11,0},
{"001000", 6, 12,0},
{"000011", 6, 13,0},
{"110100", 6, 14,0},
{"110101", 6, 15,0},
{"101010", 6, 16,0},
{"101011", 6, 17,0},
{"0100111", 7, 18,0},
{"0001100", 7, 19,0},
{"0001000", 7, 20,0},
{"0010111", 7, 21,0},
{"0000011", 7, 22,0},
{"0000100", 7, 23,0},
{"0101000", 7, 24,0},
{"0101011", 7, 25,0},
{"0010011", 7, 26,0},
{"0100100", 7, 27,0},
{"0011000", 7, 28,0},
{"00000010", 8, 29,0},
{"00000011", 8, 30,0},
{"00011010", 8, 31,0},
{"00011011", 8, 32,0},
{"00010010", 8, 33,0},
{"00010011", 8, 34,0},
{"00010100", 8, 35,0},
{"00010101", 8, 36,0},
{"00010110", 8, 37,0},
{"00010111", 8, 38,0},
{"00101000", 8, 39,0},
{"00101001", 8, 40,0},
{"00101010", 8, 41,0},
{"00101011", 8, 42,0},
{"00101100", 8, 43,0},
{"00101101", 8, 44,0},
{"00000100", 8, 45,0},
{"00000101", 8, 46,0},
{"00001010", 8, 47,0},
{"00001011", 8, 48,0},
{"01010010", 8, 49,0},
{"01010011", 8, 50,0},
{"01010100", 8, 51,0},
{"01010101", 8, 52,0},
{"00100100", 8, 53,0},
{"00100101", 8, 54,0},
{"01011000", 8, 55,0},
{"01011001", 8, 56,0},
{"01011010", 8, 57,0},
{"01011011", 8, 58,0},
{"01001010", 8, 59,0},
{"01001011", 8, 60,0},
{"00110010", 8, 61,0},
{"00110011", 8, 62,0},
{"00110100", 8, 63,0},
{"11011", 5, 64,1},
{"10010", 5, 128,1},
{"010111", 6, 192,1},
{"0110111", 7, 256,1},
{"00110110", 8, 320,1},
{"00110111", 8, 384,1},
{"01100100", 8, 448,1},
{"01100101", 8, 512,1},
{"01101000", 8, 576,1},
{"01100111", 8, 640,1},
{"011001100", 9, 704,1},
{"011001101", 9, 768,1},
{"011010010", 9, 832,1},
{"011010011", 9, 896,1},
{"011010100", 9, 960,1},
{"011010101", 9, 1024,1},
{"011010110", 9, 1088,1},
{"011010111", 9, 1152,1},
{"011011000", 9, 1216,1},
{"011011001", 9, 1280,1},
{"011011010", 9, 1344,1},
{"011011011", 9, 1408,1},
{"010011000", 9, 1472,1},
{"010011001", 9, 1536,1},
{"010011010", 9, 1600,1},
{"011000", 6, 1664,1},
{"010011011", 9, 1728,1},
{"0000110111", 10, 0,2},
{"010", 3, 1,2},
{"11", 2, 2,2},
{"10", 2, 3,2},
{"011", 3, 4,2},
{"0011", 4, 5,2},
{"0010", 4, 6,2},
{"00011", 5, 7,2},
{"000101", 6, 8,2},
{"000100", 6, 9,2},
{"0000100", 7, 10,2},
{"0000101", 7, 11,2},
{"0000111", 7, 12,2},
{"00000100", 8, 13,2},
{"00000111", 8, 14,2},
{"000011000", 9, 15,2},
{"0000010111", 10, 16,2},
{"0000011000", 10, 17,2},
{"0000001000", 10, 18,2},
{"00001100111", 11, 19,2},
{"00001101000", 11, 20,2},
{"00001101100", 11, 21,2},
{"00000110111", 11, 22,2},
{"00000101000", 11, 23,2},
{"00000010111", 11, 24,2},
{"00000011000", 11, 25,2},
{"000011001010", 12, 26,2},
{"000011001011", 12, 27,2},
{"000011001100", 12, 28,2},
{"000011001101", 12, 29,2},
{"000001101000", 12, 30,2},
{"000001101001", 12, 31,2},
{"000001101010", 12, 32,2},
{"000001101011", 12, 33,2},
{"000011010010", 12, 34,2},
{"000011010011", 12, 35,2},
{"000011010100", 12, 36,2},
{"000011010101", 12, 37,2},
{"000011010110", 12, 38,2},
{"000011010111", 12, 39,2},
{"000001101100", 12, 40,2},
{"000001101101", 12, 41,2},
{"000011011010", 12, 42,2},
{"000011011011", 12, 43,2},
{"000001010100", 12, 44,2},
{"000001010101", 12, 45,2},
{"000001010110", 12, 46,2},
{"000001010111", 12, 47,2},
{"000001100100", 12, 48,2},
{"000001100101", 12, 49,2},
{"000001010010", 12, 50,2},
{"000001010011", 12, 51,2},
{"000000100100", 12, 52,2},
{"000000110111", 12, 53,2},
{"000000111000", 12, 54,2},
{"000000100111", 12, 55,2},
{"000000101000", 12, 56,2},
{"000001011000", 12, 57,2},
{"000001011001", 12, 58,2},
{"000000101011", 12, 59,2},
{"000000101100", 12, 60,2},
{"000001011010", 12, 61,2},
{"000001100110", 12, 62,2},
{"000001100111", 12, 63,2},
{"0000001111", 10, 64,3},
{"000011001000", 12, 128,3},
{"000011001001", 12, 192,3},
{"000001011011", 12, 256,3},
{"000000110011", 12, 320,3},
{"000000110100", 12, 384,3},
{"000000110101", 12, 448,3},
{"0000001101100", 13, 512,3},
{"0000001101101", 13, 576,3},
{"0000001001010", 13, 640,3},
{"0000001001011", 13, 704,3},
{"0000001001100", 13, 768,3},
{"0000001001101", 13, 832,3},
{"0000001110010", 13, 896,3},
{"0000001110011", 13, 960,3},
{"0000001110100", 13, 1024,3},
{"0000001110101", 13, 1088,3},
{"0000001110110", 13, 1152,3},
{"0000001110111", 13, 1216,3},
{"0000001010010", 13, 1280,3},
{"0000001010011", 13, 1344,3},
{"0000001010100", 13, 1408,3},
{"0000001010101", 13, 1472,3},
{"0000001011010", 13, 1536,3},
{"0000001011011", 13, 1600,3},
{"0000001100100", 13, 1664,3},
{"0000001100101", 13, 1728,3},
{"00000001000", 11, 1792,4},
{"00000001100", 11, 1856,4},
{"00000001101", 11, 1920,4},
{"000000010010", 12, 1984,4},
{"000000010011", 12, 2048,4},
{"000000010100", 12, 2112,4},
{"000000010101", 12, 2176,4},
{"000000010110", 12, 2240,4},
{"000000010111", 12, 2304,4},
{"000000011100", 12, 2368,4},
{"000000011101", 12, 2432,4},
{"000000011110", 12, 2496,4},
{"000000011111", 12, 2560,4},
{"1111111111111111",0,0,0}
static void usage(void);
static tsize_t
DummyReadProc(thandle_t fd, tdata_t buf, tsize_t size)
{
(void) fd; (void) buf; (void) size;
return (0);
DummyWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
{
(void) fd; (void) buf; (void) size;
return (size);
unsigned long int SFF_ID;
unsigned char version;
unsigned char reserved;
unsigned short int userinfo;
unsigned short int pagecount;
unsigned short int offsetfirst;
unsigned long int offsetlast;
unsigned long int offsetend;
unsigned char headerid;
unsigned char headerlen;
unsigned char resvert;
unsigned char reshor;
unsigned char coding;
unsigned char reserved;
unsigned short int linelen;
unsigned short int pagelen;
unsigned long int prevpage;
unsigned long int nextpage;
main(int argc, char* argv[])
{
FILE *in;
int inf;
page_header page;
sff_header head;
TIFF *out = NULL;
TIFFErrorHandler whandler;
int compression = COMPRESSION_CCITTFAX3;
int fillorder = FILLORDER_LSB2MSB;
uint32 group3options = GROUP3OPT_FILLBITS|GROUP3OPT_2DENCODING;
int photometric = PHOTOMETRIC_MINISWHITE;
int mode = FAXMODE_CLASSF;
int rows;
int c;
int pn, npages,res;
extern int optind;
extern char* optarg;
out = TIFFOpen(argv[2], "w");
if (out == NULL)
return (EXIT_FAILURE);
inf=open(argv[1],O_APPEND);
res=read(inf,&head,sizeof(sff_header));
pn=0;
if(head.SFF_ID==0x66666653) {
lseek(inf,head.offsetfirst,SEEK_SET);
res=read(inf,&page,sizeof(page));
while(page.headerid==254 && res==sizeof(page)) {
printf("Page %d\n",pn+1);
if(page.headerlen>0x10)
lseek(inf,page.headerlen-0x10,SEEK_CUR);
lseek(inf,-2,SEEK_CUR);
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, XSIZE);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1);
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1);
if (compression == COMPRESSION_CCITTFAX3) {
TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, group3options);
TIFFSetField(out, TIFFTAG_FAXMODE, mode);
}
if (compression == COMPRESSION_CCITTFAX3 ||
compression == COMPRESSION_CCITTFAX4)
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, -1L);
else
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
TIFFDefaultStripSize(out, 0));
TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
TIFFSetField(out, TIFFTAG_SOFTWARE, "sff2tiff");
TIFFSetField(out, TIFFTAG_XRESOLUTION, 204.0);
TIFFSetField(out,
...
read more »