本文整理汇总了C++中TIFFSetErrorHandler函数的典型用法代码示例。如果您正苦于以下问题:C++ TIFFSetErrorHandler函数的具体用法?C++ TIFFSetErrorHandler怎么用?C++ TIFFSetErrorHandler使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIFFSetErrorHandler函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IMG_isTIF
int IMG_isTIF(SDL_RWops* src)
{
TIFF* tiff;
TIFFErrorHandler prev_handler;
/* Suppress output from libtiff */
prev_handler = TIFFSetErrorHandler(NULL);
/* Attempt to process the given file data */
/* turn off memory mapped access with the m flag */
tiff = TIFFClientOpen("SDL_image", "rm", (thandle_t)src,
tiff_read, tiff_write, tiff_seek, tiff_close, tiff_size, NULL, NULL);
/* Reset the default error handler, since it can be useful for info */
TIFFSetErrorHandler(prev_handler);
/* If it's not a TIFF, then tiff will be NULL. */
if(!tiff)
return 0;
/* Free up any dynamically allocated memory libtiff uses */
TIFFClose(tiff);
return 1;
}
示例2: FileMatchTIF
int FileMatchTIF(Tcl_Channel chan,
CONST char *fileName,
Tcl_Obj *formatString,
int *widthPtr,
int *heightPtr,
Tcl_Interp *interp)
{
TIFF *tif;
TIFFErrorHandler prev_handler; /* Current TIFF error handler */
static TIFFErrorHandler temp_handler = tkTIFFErrorHandler;
/* Temporary TIFF error handler
(is used to avoid output of
libtiff error messages to stderr) */
prev_handler = TIFFSetErrorHandler(temp_handler);
/* tif = TIFFFdOpen(f, fileName, "r"); */ /* this did not work */
tif = TIFFOpen(fileName, "r");
if (tif != NULL) {
TIFFClose(tif);
/* printf("FileMatchTIF: TIFF file found !"); */
TIFFSetErrorHandler(prev_handler);
return (TIF);
} else {
/* printf("FileMatchTIF: No TIF file found !"); */
TIFFSetErrorHandler(prev_handler);
return (0);
}
}
示例3: run
static void
run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpParasite *parasite;
gint32 image;
gint32 drawable;
gint32 orig_image;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
GError *error = NULL;
run_mode = param[0].data.d_int32;
INIT_I18N ();
gegl_init (NULL, NULL);
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
TIFFSetWarningHandler (tiff_warning);
TIFFSetErrorHandler (tiff_error);
if ((strcmp (name, SAVE_PROC) == 0) ||
(strcmp (name, SAVE2_PROC) == 0))
{
/* Plug-in is either file_tiff_save or file_tiff_save2 */
image = orig_image = param[1].data.d_int32;
drawable = param[2].data.d_int32;
/* Do this right this time, if POSSIBLE query for parasites, otherwise
or if there isn't one, choose the default comment from the gimprc. */
/* eventually export the image */
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
case GIMP_RUN_WITH_LAST_VALS:
gimp_ui_init (PLUG_IN_BINARY, FALSE);
export = gimp_export_image (&image, &drawable, NULL,
(GIMP_EXPORT_CAN_HANDLE_RGB |
GIMP_EXPORT_CAN_HANDLE_GRAY |
GIMP_EXPORT_CAN_HANDLE_INDEXED |
GIMP_EXPORT_CAN_HANDLE_ALPHA ));
if (export == GIMP_EXPORT_CANCEL)
{
values[0].data.d_status = GIMP_PDB_CANCEL;
return;
}
break;
default:
break;
}
示例4: TIFFSetWarningHandler
WidthAndHeight TifImageInfo::getSize(boost::filesystem::path & aPath)
{
WidthAndHeight result;
static BOOL bFirstRun = true;
if (bFirstRun) {
TIFFSetWarningHandler(NULL);
TIFFSetErrorHandler(NULL);
bFirstRun = false;
}
TIFF *tif = TIFFOpen(aPath.file_string().data(), "r");
if (!tif)
{
throw std::runtime_error("cannot open file [" + aPath.file_string() + "]");
}
BOOL success = FALSE;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &result.width);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &result.height);
TIFFClose(tif);
return result;
}
示例5: TERAFLY_TIME_START
char *readTiff3DFile2Buffer ( char *filename, unsigned char *img, unsigned int img_width, unsigned int img_height, unsigned int first, unsigned int last,
int downsamplingFactor, int starti, int endi, int startj, int endj ) {
// 2015-01-30. Alessandro. @ADDED performance (time) measurement in all most time-consuming methods.
#ifdef _VAA3D_TERAFLY_PLUGIN_MODE
TERAFLY_TIME_START(TiffLoadData)
#endif
TIFF *input;
//disable warning and error handlers to avoid messages on unrecognized tags
TIFFSetWarningHandler(0);
TIFFSetErrorHandler(0);
input=TIFFOpen(filename,"r");
if (!input)
{
//throw iim::IOException(strprintf("in IOManager::readTiffMultipage(...): Cannot open the file %s",finName).c_str());
return ((char *) "Cannot open the file.");
}
int b_swap=TIFFIsByteSwapped(input);
char *err_msg = readTiff3DFile2Buffer(input,img,img_width,img_height,first,last,b_swap,downsamplingFactor,starti,endi,startj,endj);
TIFFClose(input);
// 2015-01-30. Alessandro. @ADDED performance (time) measurement in all most time-consuming methods.
#ifdef _VAA3D_TERAFLY_PLUGIN_MODE
TERAFLY_TIME_STOP(TiffLoadData, tf::IO, tf::strprintf("loaded block x(%d), y(%d), z(%d-%d) from 3D tiff \"%s\"", img_width, img_height, first, last, filename))
#endif
return err_msg;
}
示例6: strlen
char *openTiff3DFile ( char *filename, char *mode, void *&fhandle ) {
char *completeFilename = (char *) 0;
int fname_len = (int) strlen(filename);
char *suffix = strstr(filename,".tif");
while ( suffix && (fname_len - (suffix-filename) > 5) )
suffix = strstr(suffix+4,".tif");
//if ( (suffix != 0) && (fname_len - (suffix-filename) <= 5) ) { // a substring ".tif is already at the end of the filename
if ( suffix ) { // a substring ".tif is already at the very end of the filename
completeFilename = new char[fname_len+1];
strcpy(completeFilename,filename);
}
else {
completeFilename = new char[fname_len+4+1];
strcpy(completeFilename,filename);
strcat(completeFilename,".");
strcat(completeFilename,TIFF3D_SUFFIX);
}
//disable warning and error handlers to avoid messages on unrecognized tags
TIFFSetWarningHandler(0);
TIFFSetErrorHandler(0);
fhandle = TIFFOpen(completeFilename,mode);
if (!fhandle)
{
return ((char *) "Cannot open the file.");
}
return ((char *) 0);
}
示例7: TIFFSetErrorHandler
Tiio::Reader *Tiio::makeTziReader() {
#ifdef _DEBUG
TIFFSetErrorHandler(MyErrorHandler);
TIFFSetWarningHandler(MyWarningHandler);
#endif
return new TifReader(true);
}
示例8: lock
bool
TIFFInput::seek_subimage (int subimage, int miplevel, ImageSpec &newspec)
{
if (subimage < 0) // Illegal
return false;
if (m_emulate_mipmap) {
// Emulating MIPmap? Pretend one subimage, many MIP levels.
if (subimage != 0)
return false;
subimage = miplevel;
} else {
// No MIPmap emulation
if (miplevel != 0)
return false;
}
if (subimage == m_subimage) {
// We're already pointing to the right subimage
newspec = m_spec;
return true;
}
// If we're emulating a MIPmap, only resolution is allowed to change
// between MIP levels, so if we already have a valid level in m_spec,
// we don't need to re-parse metadata, it's guaranteed to be the same.
bool read_meta = !(m_emulate_mipmap && m_tif && m_subimage >= 0);
if (! m_tif) {
// Use our own error handler to keep libtiff from spewing to stderr
lock_guard lock (lasterr_mutex);
TIFFSetErrorHandler (my_error_handler);
TIFFSetWarningHandler (my_error_handler);
}
if (! m_tif) {
m_tif = TIFFOpen (m_filename.c_str(), "rm");
if (m_tif == NULL) {
error ("Could not open file: %s",
lasterr.length() ? lasterr.c_str() : m_filename.c_str());
return false;
}
m_subimage = 0;
}
m_next_scanline = 0; // next scanline we'll read
if (TIFFSetDirectory (m_tif, subimage)) {
m_subimage = subimage;
readspec (read_meta);
newspec = m_spec;
if (newspec.format == TypeDesc::UNKNOWN) {
error ("No support for data format of \"%s\"", m_filename.c_str());
return false;
}
return true;
} else {
error ("%s", lasterr.length() ? lasterr.c_str() : m_filename.c_str());
m_subimage = -1;
return false;
}
}
示例9: sendRecvStatus
void
sendRecvStatus(const char* modem, char* tag)
{
DIR* dir = opendir(FAX_RECVDIR);
if (dir != NULL) {
struct dirent* dp;
TIFFSetErrorHandler(NULL);
TIFFSetWarningHandler(NULL);
while (dp = readdir(dir)) {
char entry[1024];
struct stat sb;
int fd;
if (strncmp(dp->d_name, "fax", 3) != 0)
continue;
sprintf(entry, "%s/%s", FAX_RECVDIR, dp->d_name);
if (stat(entry, &sb) < 0 || (sb.st_mode & S_IFMT) != S_IFREG)
continue;
fd = open(entry, RECV_OMODE);
if (fd > 0) {
int beingReceived =
(flock(fd, LOCK_EX|LOCK_NB) < 0 && errno == EWOULDBLOCK);
(void) readQFile(fd, entry, beingReceived, &sb);
close(fd);
}
}
closedir(dir);
} else
sendAndLogError("Can not access receive queue directory \"%s\".",
FAX_RECVDIR);
}
示例10: tiff_open
TIFF *
tiff_open (GFile *file,
const gchar *mode,
GError **error)
{
gchar *filename = g_file_get_path (file);
TIFFSetWarningHandler (tiff_warning);
TIFFSetErrorHandler (tiff_error);
#ifdef G_OS_WIN32
gunichar2 *utf16_filename = g_utf8_to_utf16 (filename, -1, NULL, NULL, error);
if (utf16_filename)
{
TIFF *tif = TIFFOpenW (utf16_filename, mode);
g_free (utf16_filename);
return tif;
}
return NULL;
#else
return TIFFOpen (filename, mode);
#endif
}
示例11: TIFFSetWarningHandler
void tiff_reader<T>::init()
{
TIFFSetWarningHandler(0);
// Note - we intentially set the error handling to null
// when opening the image for the first time to avoid
// leaking in TiffOpen: https://github.com/mapnik/mapnik/issues/1783
TIFFSetErrorHandler(0);
TIFF* tif = open(stream_);
if (!tif) throw image_reader_exception("Can't open tiff file");
TIFFSetErrorHandler(on_error);
char msg[1024];
if (TIFFRGBAImageOK(tif,msg))
{
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width_);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height_);
if (TIFFIsTiled(tif))
{
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tile_width_);
TIFFGetField(tif, TIFFTAG_TILELENGTH, &tile_height_);
read_method_=tiled;
}
else if (TIFFGetField(tif,TIFFTAG_ROWSPERSTRIP,&rows_per_strip_)!=0)
{
read_method_=stripped;
}
//TIFFTAG_EXTRASAMPLES
uint16 extrasamples;
uint16* sampleinfo;
TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
&extrasamples, &sampleinfo);
if (extrasamples == 1 &&
sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA)
{
premultiplied_alpha_ = true;
}
}
else
{
throw image_reader_exception(msg);
}
}
示例12: raster_keys
static void
raster_keys(unsigned char key, int x, int y)
{
(void) x;
(void) y;
switch (key) {
case 'b': /* photometric MinIsBlack */
photo = PHOTOMETRIC_MINISBLACK;
initImage();
break;
case 'l': /* lsb-to-msb FillOrder */
order = FILLORDER_LSB2MSB;
initImage();
break;
case 'm': /* msb-to-lsb FillOrder */
order = FILLORDER_MSB2LSB;
initImage();
break;
case 'w': /* photometric MinIsWhite */
photo = PHOTOMETRIC_MINISWHITE;
initImage();
break;
case 'W': /* toggle warnings */
owarning = TIFFSetWarningHandler(owarning);
initImage();
break;
case 'E': /* toggle errors */
oerror = TIFFSetErrorHandler(oerror);
initImage();
break;
case 'z': /* reset to defaults */
case 'Z':
order = order0;
photo = photo0;
if (owarning == NULL)
owarning = TIFFSetWarningHandler(NULL);
if (oerror == NULL)
oerror = TIFFSetErrorHandler(NULL);
initImage();
break;
case 'q': /* exit */
case '\033':
cleanup_and_exit();
}
glutPostRedisplay();
}
示例13: tiff_push_handlers
static void
tiff_push_handlers (void)
{
if (global_error)
g_warning ("TIFF loader left crufty global_error around, FIXME");
orig_error_handler = TIFFSetErrorHandler (tiff_error_handler);
orig_warning_handler = TIFFSetWarningHandler (tiff_warning_handler);
}
示例14: wxT
wxTIFFHandler::wxTIFFHandler()
{
m_name = wxT("TIFF file");
m_extension = wxT("tif");
m_type = wxBITMAP_TYPE_TIF;
m_mime = wxT("image/tiff");
TIFFSetWarningHandler((TIFFErrorHandler) TIFFwxWarningHandler);
TIFFSetErrorHandler((TIFFErrorHandler) TIFFwxErrorHandler);
}
示例15: process
static gboolean
process(GeglOperation *operation,
GeglBuffer *input,
const GeglRectangle *result,
int level)
{
GeglProperties *o = GEGL_PROPERTIES(operation);
Priv *p = g_new0(Priv, 1);
gboolean status = TRUE;
GError *error = NULL;
g_assert(p != NULL);
o->user_data = (void*) p;
p->stream = gegl_gio_open_output_stream(NULL, o->path, &p->file, &error);
if (p->stream != NULL && p->file != NULL)
p->can_seek = g_seekable_can_seek(G_SEEKABLE(p->stream));
if (p->stream == NULL)
{
status = FALSE;
g_warning("%s", error->message);
goto cleanup;
}
TIFFSetErrorHandler(error_handler);
TIFFSetWarningHandler(warning_handler);
p->tiff = TIFFClientOpen("GEGL-tiff-save", "w", (thandle_t) p,
read_from_stream, write_to_stream,
seek_in_stream, close_stream,
get_file_size, NULL, NULL);
if (p->tiff == NULL)
{
status = FALSE;
g_warning("failed to open TIFF from %s", o->path);
goto cleanup;
}
if (export_tiff(operation, input, result))
{
status = FALSE;
g_warning("could not export TIFF file");
goto cleanup;
}
cleanup:
cleanup(operation);
if (o->user_data != NULL)
g_free(o->user_data);
o->user_data = NULL;
if (error != NULL)
g_error_free(error);
return status;
}