1 #include "ColorFilter.h"
2 #include "DlgFilterWorker.h"
6 const int NO_DELAY = 0;
7 const int COLUMNS_PER_PIECE = 5;
11 m_imageOriginal (pixmapOriginal.toImage()),
12 m_rgbBackground (rgbBackground),
13 m_colorFilterMode (NUM_COLOR_FILTER_MODES),
17 m_restartTimer.setSingleShot (
false);
18 connect (&m_restartTimer, SIGNAL (timeout ()),
this, SLOT (slotRestartTimeout()));
25 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgFilterWorker::slotNewParameters filterMode=" << colorFilterMode
33 m_inputCommandQueue.push_back (command);
35 if (!m_restartTimer.isActive()) {
38 m_restartTimer.start (NO_DELAY);
42 void DlgFilterWorker::slotRestartTimeout ()
44 if (m_inputCommandQueue.count() > 0) {
47 m_inputCommandQueue.clear ();
57 m_restartTimer.start (NO_DELAY);
59 }
else if (m_xLeft < m_imageOriginal.width ()) {
62 int xStop = m_xLeft + COLUMNS_PER_PIECE;
63 if (xStop >= m_imageOriginal.width()) {
64 xStop = m_imageOriginal.width();
73 int processedWidth = xStop - m_xLeft;
74 QImage imageProcessed (processedWidth,
75 m_imageOriginal.height(),
76 QImage::Format_RGB32);
77 for (
int xFrom = m_xLeft, xTo = 0; (xFrom < xStop) && (m_inputCommandQueue.count() == 0); xFrom++, xTo++) {
78 for (
int y = 0; (y < m_imageOriginal.height ()) && (m_inputCommandQueue.count() == 0); y++) {
79 QColor pixel = m_imageOriginal.pixel (xFrom, y);
81 if (pixel.rgb() != m_rgbBackground) {
90 imageProcessed.setPixel (xTo, y, (isOn ?
91 QColor (Qt::black).rgb () :
92 QColor (Qt::white).rgb ()));
96 if (m_inputCommandQueue.count() == 0) {
99 m_xLeft += processedWidth;
102 if ((xStop < m_imageOriginal.width()) ||
103 (m_inputCommandQueue.count () > 0)) {
106 m_restartTimer.start (NO_DELAY);
Command pattern object for receiving new parameters in DlgFilterWorker from GUI thread.
double low0To1() const
Get method for low value.
Class for filtering image to remove unimportant information.
void slotNewParameters(ColorFilterMode colorFilterMode, double low, double high)
Start processing with a new set of parameters. Any ongoing processing is interrupted when m_filterMod...
void signalTransferPiece(int xLeft, QImage image)
Send a processed vertical piece of the original pixmap. The destination is between xLeft and xLeft+pi...
double high0To1() const
Get method for high value.
bool pixelUnfilteredIsOn(ColorFilterMode colorFilterMode, const QColor &pixel, QRgb rgbBackground, double low0To1, double high0To1) const
Return true if specified unfiltered pixel is on.
ColorFilterMode colorFilterMode() const
Get method for filter mode.
DlgFilterWorker(const QPixmap &pixmapOriginal, QRgb m_rgbBackground)
Single constructor.