Skip to content

Commit

Permalink
Merge pull request tesseract-ocr#367 from stweil/windows
Browse files Browse the repository at this point in the history
win32: Show TIFF warnings on console
  • Loading branch information
zdenop authored Jul 17, 2016
2 parents 74d5126 + 0be0c93 commit 155e5bf
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@
#include "openclwrapper.h"
#include "osdetect.h"

#if defined(HAVE_TIFFIO_H) && defined(_WIN32)

#include <tiffio.h>
#include <windows.h>

static void Win32WarningHandler(const char* module, const char* fmt,
va_list ap) {
if (module != NULL) {
fprintf(stderr, "%s: ", module);
}
fprintf(stderr, "Warning, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, ".\n");
}

#endif /* HAVE_TIFFIO_H && _WIN32 */

void PrintVersionInfo() {
char *versionStrP;

Expand Down Expand Up @@ -352,6 +369,11 @@ int main(int argc, char **argv) {
int arg_i = 1;
tesseract::PageSegMode pagesegmode = tesseract::PSM_AUTO;

#if defined(HAVE_TIFFIO_H) && defined(_WIN32)
/* Show libtiff warnings on console (not in GUI). */
TIFFSetWarningHandler(Win32WarningHandler);
#endif /* HAVE_TIFFIO_H && _WIN32 */

ParseArgs(argc, argv,
&lang, &image, &outputbase, &datapath,
&list_langs, &print_parameters,
Expand Down

0 comments on commit 155e5bf

Please sign in to comment.