Use binary search to find the right file size

This commit is contained in:
hunbernd 2017-06-11 00:31:20 +02:00
parent c17a8e7d51
commit f434e6559b
3 changed files with 47 additions and 22 deletions

View file

@ -14,7 +14,7 @@ public:
static void optimizeSize(QString &html, const QImage& original, QImage &optimized, int maxPixels = -1, int maxBytes = -1);
private:
static bool checkSize(QString& embeddedImage, const QImage& img, int maxBytes = -1);
static int checkSize(QString& embeddedImage, const QImage& img, int maxBytes = -1);
static void quantization(const QImage& img, QVector<QRgb>& palette);
static void quantization(QList<QRgb>::iterator begin, QList<QRgb>::iterator end, int depth, QVector<QRgb>& palette);
static void avgbucket(QList<QRgb>::iterator begin, QList<QRgb>::iterator end, QVector<QRgb>& palette);