From 9a884b7bf77471c324bb27ea9e57ea224e1b42b4 Mon Sep 17 00:00:00 2001 From: hunbernd Date: Fri, 5 Jul 2019 13:41:30 +0200 Subject: [PATCH] Rise max public chat message size to 31000 bytes Rise color palette size from 16 to 256 colors Note: Max chat item size is 32000 without splitting the message. 31000 = 32000 - some place left for other fields --- libretroshare/src/chat/p3chatservice.cc | 2 +- retroshare-gui/src/util/imageutil.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libretroshare/src/chat/p3chatservice.cc b/libretroshare/src/chat/p3chatservice.cc index 482120940..e446bfdef 100644 --- a/libretroshare/src/chat/p3chatservice.cc +++ b/libretroshare/src/chat/p3chatservice.cc @@ -47,7 +47,7 @@ * #define CHAT_DEBUG 1 ****/ -static const uint32_t MAX_MESSAGE_SECURITY_SIZE = 6000 ; // Max message size to forward other friends +static const uint32_t MAX_MESSAGE_SECURITY_SIZE = 31000 ; // Max message size to forward other friends static const uint32_t MAX_AVATAR_JPEG_SIZE = 32767; // Maximum size in bytes for an avatar. Too large packets // don't transfer correctly and can kill the system. // Images are 96x96, which makes approx. 27000 bytes uncompressed. diff --git a/retroshare-gui/src/util/imageutil.cpp b/retroshare-gui/src/util/imageutil.cpp index cefa22906..648fe392c 100644 --- a/retroshare-gui/src/util/imageutil.cpp +++ b/retroshare-gui/src/util/imageutil.cpp @@ -99,9 +99,9 @@ bool ImageUtil::optimizeSize(QString &html, const QImage& original, QImage &opti } //Use binary search to find a suitable image size + linear regression to guess the file size - double maxsize = (double)checkSize(html, optimized = original.scaledToWidth(maxwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct), maxBytes); + double maxsize = (double)checkSize(html, optimized = original.scaledToWidth(maxwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct, Qt::ThresholdDither), maxBytes); if(maxsize <= maxBytes) return true; //success - double minsize = (double)checkSize(html, optimized = original.scaledToWidth(minwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct), maxBytes); + double minsize = (double)checkSize(html, optimized = original.scaledToWidth(minwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct, Qt::ThresholdDither), maxBytes); if(minsize > maxBytes) return false; //impossible // std::cout << "maxS: " << maxsize << " minS: " << minsize << std::endl; @@ -114,7 +114,7 @@ bool ImageUtil::optimizeSize(QString &html, const QImage& original, QImage &opti double b = maxsize - m * ((double)maxwidth * (double)maxwidth / whratio); double a = ((double)(maxBytes - region/2) - b) / m; //maxBytes - region/2 target the center of the accepted region int nextwidth = (int)sqrt(a * whratio); - int nextsize = checkSize(html, optimized = original.scaledToWidth(nextwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct), maxBytes); + int nextsize = checkSize(html, optimized = original.scaledToWidth(nextwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct, Qt::ThresholdDither), maxBytes); if(nextsize <= maxBytes) { minsize = nextsize; minwidth = nextwidth; @@ -188,7 +188,7 @@ bool blueLessThan(const QRgb &c1, const QRgb &c2) //median cut algoritmh void ImageUtil::quantization(const QImage &img, QVector &palette) { - int bits = 4; // bits/pixel + int bits = 8; // bits/pixel int samplesize = 100000; //only take this many color samples rstime::RsScopeTimer st("Quantization");