win32: Show TIFF warnings on console

Showing them in a window (default) is not acceptable for a console
application like Tesseract which must be able to work in batch mode.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2016-07-15 23:00:00 +02:00
parent 669c7397aa
commit 896e80d9a7

View File

@ -33,6 +33,23 @@
#include "openclwrapper.h"
#include "osdetect.h"
#if 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 /* _WIN32 */
void PrintVersionInfo() {
char *versionStrP;
@ -352,6 +369,11 @@ int main(int argc, char **argv) {
int arg_i = 1;
tesseract::PageSegMode pagesegmode = tesseract::PSM_AUTO;
#if defined(_WIN32)
/* Show libtiff warnings on console (not in GUI). */
TIFFSetWarningHandler(Win32WarningHandler);
#endif /* _WIN32 */
ParseArgs(argc, argv,
&lang, &image, &outputbase, &datapath,
&list_langs, &print_parameters,