Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
imgtiff.h File Reference
`#include "host.h"`

Go to the source code of this file.

## Functions
int | CountTiffPages (FILE *fp)

## Function Documentation

int CountTiffPages | ( | FILE * | fp | ) |

Definition at line 80 of file imgtiff.cpp.

{
if (fp == NULL) return 0;
// Read header
inT16 filetype = 0;
if (fread(&filetype, sizeof(filetype), 1, fp) != 1 ||
(filetype != INTEL && filetype != MOTO)) {
return 0;
}
fseek(fp, 4L, SEEK_SET);
int npages = 0;
do {
inT32 start; // Start of tiff directory.
if (fread(&start, sizeof(start), 1, fp) != 1) {
return npages;
}
if (filetype != __NATIVE__)
ReverseN(&start, sizeof(start));
if (start <= 0) {
return npages;
}
fseek(fp, start, SEEK_SET);
inT16 entries; // No of tiff entries.
if (fread(&entries, sizeof(entries), 1, fp) != 1) {
return npages;
}
if (filetype != __NATIVE__)
ReverseN(&entries, sizeof(entries));
// Skip the tags and get to the next start.
fseek(fp, entries * sizeof(TIFFENTRY), SEEK_CUR);
++npages;
} while (1);
return 0;
}