mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Comic input: Fix single color images having their colors changed by normalization. Fixes #1939908 [Normalize on CBZ conversion changes white pages to black pages](https://bugs.launchpad.net/calibre/+bug/1939908)
This commit is contained in:
parent
9ac68112b1
commit
30c411acd1
@ -9,6 +9,7 @@
|
||||
#include <stdexcept>
|
||||
#include <QVector>
|
||||
#include <cmath>
|
||||
#include <set>
|
||||
|
||||
// Macros {{{
|
||||
#define SQUARE(x) (x)*(x)
|
||||
@ -646,6 +647,7 @@ QImage normalize(const QImage &image) { // {{{
|
||||
QRgb pixel, *dest;
|
||||
unsigned char r, g, b;
|
||||
QImage img(image);
|
||||
std::set<QRgb> all_colors;
|
||||
|
||||
ENSURE32(img);
|
||||
|
||||
@ -656,11 +658,13 @@ QImage normalize(const QImage &image) { // {{{
|
||||
|
||||
for(i=0; i < count; ++i){
|
||||
pixel = *dest++;
|
||||
all_colors.insert(pixel);
|
||||
histogram[qRed(pixel)].red++;
|
||||
histogram[qGreen(pixel)].green++;
|
||||
histogram[qBlue(pixel)].blue++;
|
||||
histogram[qAlpha(pixel)].alpha++;
|
||||
}
|
||||
if (all_colors.size() < 2) return img;
|
||||
|
||||
// find the histogram boundaries by locating the .01 percent levels.
|
||||
threshold_intensity = count/1000;
|
||||
|
Loading…
x
Reference in New Issue
Block a user