mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-03-03 07:30:01 -05:00
Merge branch 'improve-dominant_color' of https://github.com/un-pogaz/calibre
This commit is contained in:
commit
fe7b6227f5
@ -640,7 +640,17 @@ void overlay(const QImage &image, QImage &canvas, unsigned int left, unsigned in
|
||||
|
||||
QColor dominant_color(const QImage &image) { // {{{
|
||||
if (image.isNull()) return QColor();
|
||||
QImage img(image);
|
||||
QImage img;
|
||||
if (image.width() < 100 || image.height() < 100)
|
||||
img = QImage(image);
|
||||
else {
|
||||
float ratio;
|
||||
if (image.width() > image.height())
|
||||
ratio = 100.0 / image.width();
|
||||
else
|
||||
ratio = 100.0 / image.height();
|
||||
img = image.scaled(image.size() * ratio, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
ENSURE32(img);
|
||||
QHash<QRgb, int> colorCounts;
|
||||
const uchar* bits = img.constBits();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user