27 qDeleteAll (m_strategies);
33 const long MASK = 0xf0f0f0f0;
34 return (rgb1 & MASK) == (rgb2 & MASK);
37 void ColorFilter::createStrategies ()
47 QImage &imageFiltered,
57 for (
int x = 0; x < imageOriginal.width(); x++) {
58 for (
int y = 0; y < imageOriginal.height (); y++) {
60 QColor pixel = imageOriginal.pixel (x, y);
62 if (pixel.rgb() != rgbBackground) {
71 imageFiltered.setPixel (x, y, (isOn ?
72 QColor (Qt::black).rgb () :
73 QColor (Qt::white).rgb ()));
81 ColorList colorCounts;
82 for (
int x = 0; x < image->width (); x++) {
83 mergePixelIntoColorCounts (image->pixel (x, 0), colorCounts);
84 mergePixelIntoColorCounts (image->pixel (x, image->height () - 1), colorCounts);
86 for (
int y = 0; y < image->height (); y++) {
87 mergePixelIntoColorCounts (image->pixel (0, y), colorCounts);
88 mergePixelIntoColorCounts (image->pixel (image->width () - 1, y), colorCounts);
94 for (ColorList::const_iterator itr = colorCounts.begin (); itr != colorCounts.end (); itr++) {
95 if ((*itr).count > entryMax.
count) {
100 return entryMax.
color.rgb();
103 void ColorFilter::mergePixelIntoColorCounts (QRgb pixel,
104 ColorList &colorCounts)
const
112 for (ColorList::iterator itr = colorCounts.begin (); itr != colorCounts.end (); itr++) {
114 (*itr).color.rgb())) {
122 colorCounts.append (entry);
134 (x < image.width()) &&
135 (y < image.height())) {
139 const int BLACK_WHITE_THRESHOLD = 255 / 2;
140 int gray = qGray (
pixelRGB (image, x, y));
141 rtn = (gray < BLACK_WHITE_THRESHOLD);
152 double high0To1)
const
160 if (low0To1 <= high0To1) {
163 rtn = (low0To1 <= s) && (s <= high0To1);
168 rtn = (s <= high0To1) || (low0To1 <= s);
178 QRgb rgbBackground)
const
180 if (m_strategies.contains (colorFilterMode)) {
198 if (m_strategies.contains (colorFilterMode)) {