From 7702d8c200c11c42ec743269504ec425365bb498 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 27 May 2022 18:10:01 +0200 Subject: [PATCH] libpng option in build script --- build.sh | 8 +++++++ src/laybasic/laybasic/layLayoutViewBase.cc | 26 +++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index daafa8c93..6c6c61c9a 100755 --- a/build.sh +++ b/build.sh @@ -36,6 +36,7 @@ HAVE_QT_DESIGNER=1 HAVE_QT_XML=1 HAVE_64BIT_COORD=0 HAVE_QT=1 +HAVE_PNG=0 HAVE_CURL=0 HAVE_EXPAT=0 @@ -199,6 +200,9 @@ while [ "$*" != "" ]; do -dry-run) RUN_MAKE=0 ;; + -libpng) + HAVE_PNG=1 + ;; -libcurl) HAVE_CURL=1 ;; @@ -260,6 +264,7 @@ while [ "$*" != "" ]; do echo "" echo " -libcurl Use libcurl instead of QtNetwork (for Qt<4.7)" echo " -libexpat Use libexpat instead of QtXml" + echo " -libpng Use libpng instead of Qt for PNG generation" echo "" echo "Environment Variables:" echo "" @@ -487,6 +492,9 @@ fi if [ $HAVE_CURL != 0 ]; then echo " Uses libcurl for network access" fi +if [ $HAVE_PNG != 0 ]; then + echo " Uses libpng for PNG generation" +fi if [ "$RPATH" = "" ]; then RPATH="$BIN" fi diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index f91536907..853da6195 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -2549,7 +2549,7 @@ LayoutViewBase::save_screenshot (const std::string &fn) tl::log << "Saved screen shot to " << fn; } -#else +#elif defined(HAVE_PNG) void LayoutViewBase::save_screenshot (const std::string &fn) { @@ -2565,6 +2565,12 @@ LayoutViewBase::save_screenshot (const std::string &fn) tl::log << "Saved screen shot to " << fn; } +#else +void +LayoutViewBase::save_screenshot (const std::string &) +{ + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot - PNG library not compiled in"))); +} #endif #if defined(HAVE_QT) @@ -2656,7 +2662,7 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned tl::log << "Saved image to " << fn; } -#else +#elif defined(HAVE_PNG) void LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) { @@ -2675,6 +2681,12 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned tl::log << "Saved image to " << fn; } +#else +void +LayoutViewBase::save_image (const std::string &, unsigned int, unsigned int) +{ + throw tl::Exception (tl::to_string (tr ("Unable to save image - PNG library not compiled in"))); +} #endif #if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE) @@ -2708,7 +2720,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn, tl::log << "Saved image to " << fn; } -#else +#elif defined(HAVE_PNG) void LayoutViewBase::save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, @@ -2739,6 +2751,14 @@ LayoutViewBase::save_image_with_options (const std::string &fn, tl::log << "Saved image to " << fn; } +#else +void +LayoutViewBase::save_image_with_options (const std::string &, + unsigned int, unsigned int, int, int, double, + lay::Color, lay::Color, lay::Color, const db::DBox &, bool) +{ + throw tl::Exception (tl::to_string (tr ("Unable to save image - PNG library not compiled in"))); +} #endif void