image/imgio.cpp File Reference

#include "mfcpch.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include "scanutils.h"
#include "stderr.h"
#include "fileerr.h"
#include "imgerrs.h"
#include "memry.h"
#include "imgs.h"
#include "imgbmp.h"
#include "imgtiff.h"
#include "imgio.h"

Go to the source code of this file.

Classes

Defines

Functions

Variables


Define Documentation

#define DEFAULTIMAGETYPE   "tif"

Note:
File: imgio.cpp (Formerly imageio.c)
Controls image input/output and selection of format.
Author:
Ray Smith
Date:
Jun 11 11:47:26 BST 1990
 * (C) Copyright 1990, Hewlett-Packard Ltd.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 40 of file imgio.cpp.

Referenced by name_to_image_type().

#define MAXIMAGETYPES   (sizeof(imagetypes)/sizeof(IMAGETYPE))

Definition at line 81 of file imgio.cpp.

Referenced by name_to_image_type().


Function Documentation

static INT8 name_to_image_type ( const char *  name  )  [static]

Convert a file name to an image type, picking defaults if it is has no extension, and complaining if the extension is not supported.

Definition at line 87 of file imgio.cpp.

References BADIMAGETYPE, DEFAULTIMAGETYPE, ERRCODE::error(), imagetypes, LOG, MAXIMAGETYPES, and NULL.

Referenced by IMAGE::read_header(), and IMAGE::write().

00089                                 {
00090   const char *nametype;          //type part of name
00091   INT8 type;                     //imagetypes index
00092 
00093   nametype = strrchr (name, '.');//find extension
00094   if (nametype != NULL)
00095     nametype++;                  //ptr to extension
00096   else
00097     nametype = DEFAULTIMAGETYPE; //had none
00098 
00099                                  //find type of image
00100   for (type = 0;
00101    type < MAXIMAGETYPES && strcmp (imagetypes[type].string, nametype); type++);
00102   if (type >= MAXIMAGETYPES) {
00103                                  //unrecognized type
00104     BADIMAGETYPE.error ("name_to_image_type", LOG, name);
00105     return -1;
00106   }
00107   return type;
00108 }


Variable Documentation

IMAGETYPE imagetypes[] [static]

Initial value:

All the image types that Tesseract 1.02 supports and each's driver

Definition at line 55 of file imgio.cpp.

Referenced by name_to_image_type(), IMAGE::read_header(), and IMAGE::write().


Generated on Wed Feb 28 19:49:24 2007 for Tesseract by  doxygen 1.5.1