#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.
#define DEFAULTIMAGETYPE "tif" |
* (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)) |
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 }
IMAGETYPE imagetypes[] [static] |
Initial value:
{ { "TIF", open_tif_image, read_tif_image, write_moto_tif }, { "itf", open_tif_image, read_tif_image, write_inverse_tif }, { "tif", open_tif_image, read_tif_image, write_intel_tif }, { "bmp", open_bmp_image, read_bmp_image, write_bmp_image }, }
Definition at line 55 of file imgio.cpp.
Referenced by name_to_image_type(), IMAGE::read_header(), and IMAGE::write().