When libpng is not found, default to GIF output

This commit is contained in:
Robin Stuart 2016-08-26 11:44:02 +01:00
parent 085ec8477c
commit 542ec7c7a5
3 changed files with 12 additions and 2 deletions

View File

@ -22,7 +22,9 @@ add_library(zint SHARED ${zint_SRCS})
set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}" set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}"
VERSION ${ZINT_VERSION}) VERSION ${ZINT_VERSION})
target_link_libraries(zint ${PNG_LIBRARIES} ) if(PNG_FOUND)
target_link_libraries(zint ${PNG_LIBRARIES} )
endif(PNG_FOUND)
target_link_libraries(zint -lm) target_link_libraries(zint -lm)
install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS} ) install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS} )

View File

@ -781,7 +781,11 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt
} }
if (strcmp(symbol->outfile, "") == 0) { if (strcmp(symbol->outfile, "") == 0) {
#ifdef NO_PNG
strcpy(symbol->outfile, "out.gif");
#else
strcpy(symbol->outfile, "out.png"); strcpy(symbol->outfile, "out.png");
#endif
} }
#ifndef _MSC_VER #ifndef _MSC_VER
unsigned char local_source[length + 1]; unsigned char local_source[length + 1];
@ -1085,6 +1089,11 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
return ZINT_ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if (error_number == ZINT_ERROR_INVALID_OPTION) {
/* If libpng is not installed */
strcpy(symbol->errtxt, "Unknown output format");
}
error_tag(symbol->errtxt, error_number); error_tag(symbol->errtxt, error_number);
return error_number; return error_number;
} }

View File

@ -927,7 +927,6 @@ int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type) {
#ifdef NO_PNG #ifdef NO_PNG
if (file_type == OUT_PNG_FILE) { if (file_type == OUT_PNG_FILE) {
printf("libpng not found");
return ZINT_ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
#endif /* NO_PNG */ #endif /* NO_PNG */