Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortamasmeszaros <meszaros.q@gmail.com>2020-08-03 19:50:43 +0300
committertamasmeszaros <meszaros.q@gmail.com>2020-08-28 00:14:42 +0300
commitad0df8fd098cfead66f9ede7456cd783a88ba049 (patch)
tree95175cdfb12b91ed5576930a14bd82840e5122e5
parentb09552e56faced8580fde7c4648a5116ae578d61 (diff)
Be compatible with earlier libpng versions.
-rw-r--r--src/libslic3r/PNGRead.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libslic3r/PNGRead.cpp b/src/libslic3r/PNGRead.cpp
index 695ceba3d..5b5b9ffec 100644
--- a/src/libslic3r/PNGRead.cpp
+++ b/src/libslic3r/PNGRead.cpp
@@ -27,8 +27,18 @@ bool is_png(const ReadBuf &rb)
{
static const constexpr int PNG_SIG_BYTES = 8;
- return rb.sz >= PNG_SIG_BYTES &&
- !png_sig_cmp(static_cast<png_const_bytep>(rb.buf), 0, PNG_SIG_BYTES);
+#if PNG_LIBPNG_VER_MINOR <= 2
+ // Earlier libpng versions had png_sig_cmp(png_bytep, ...) which is not
+ // a const pointer. It is not possible to cast away the const qualifier from
+ // the input buffer so... yes... life is challenging...
+ png_byte buf[PNG_SIG_BYTES];
+ auto inbuf = static_cast<const std::uint8_t *>(rb.buf);
+ std::copy(inbuf, inbuf + PNG_SIG_BYTES, buf);
+#else
+ auto buf = static_cast<png_const_bytep>(rb.buf);
+#endif
+
+ return rb.sz >= PNG_SIG_BYTES && !png_sig_cmp(buf, 0, PNG_SIG_BYTES);
}
// A wrapper around ReadBuf to be read repeatedly like a stream. libpng needs