Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
imgtiff.cpp File Reference
#include "mfcpch.h"
#include <stdio.h>
#include "imgtiff.h"
#include "helpers.h"

Go to the source code of this file.

Classes

struct  TIFFENTRY

Macros

#define INTEL   0x4949
#define MOTO   0x4d4d
#define ENTRIES   19 /*no of entries */
#define START   8 /*start of tag table */

Functions

int CountTiffPages (FILE *fp)

Macro Definition Documentation

#define ENTRIES   19 /*no of entries */

Definition at line 64 of file imgtiff.cpp.

#define INTEL   0x4949

Definition at line 36 of file imgtiff.cpp.

#define MOTO   0x4d4d

Definition at line 37 of file imgtiff.cpp.

#define START   8 /*start of tag table */

Definition at line 65 of file imgtiff.cpp.


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;
}