File jasper-2.0.17.patch of Package kdelibs4

From: Wolfgang Bauer <wbauer@tmo.at>
Subject: Fix build with jasper 2.0.17 or higher

The `cnt` parameters have been changed from int to unsigned in 2.0.17, and
later to size_t in 3.0 (which also changed the return codes to ssize_t),
resulting in -fpermissive errors.

Additionally, `char *buf` was changed to `const char *buf` for the
write function in 2.0.20.

And jp2_encode() is an internal function not to be used by applications
(it's no longer exported at all in 3.0), so use jas_image_encode() instead.

diff --git a/kimgio/jp2.cpp b/kimgio/jp2.cpp
--- a/kimgio/jp2.cpp
+++ b/kimgio/jp2.cpp
@@ -103,13 +103,13 @@ static void jas_stream_initbuf(jas_stream_t *stream, int bufmode, char *buf,
         stream->bufmode_ |= bufmode & JAS_STREAM_BUFMODEMASK;
 }
 
-static int qiodevice_read(jas_stream_obj_t *obj, char *buf, int cnt)
+static ssize_t qiodevice_read(jas_stream_obj_t *obj, char *buf, size_t cnt)
 {
         QIODevice *io = (QIODevice*) obj;
         return io->read(buf, cnt);
 }
 
-static int qiodevice_write(jas_stream_obj_t *obj, char *buf, int cnt)
+static ssize_t qiodevice_write(jas_stream_obj_t *obj, const char *buf, size_t cnt)
 {
         QIODevice *io = (QIODevice*) obj;
         return io->write(buf, cnt);
@@ -385,7 +385,8 @@ write_image( const QImage &image, QIODevice* io, int quality )
         // use sprintf for locale-aware string
         char rateBuffer[16];
         sprintf(rateBuffer, "rate=%.2g\n", (quality < 0) ? DEFAULT_RATE : quality / 100.0);
-        int i = jp2_encode( ji, stream, rateBuffer);
+        int fmt = jas_image_strtofmt(QByteArray("jp2").data());
+        int i = jas_image_encode( ji, stream, fmt, rateBuffer);
 
         jas_image_destroy( ji );
         jas_stream_close( stream );
openSUSE Build Service is sponsored by