7 #include "ColorFilter.h" 8 #include "DlgFilterWorker.h" 12 const int NO_DELAY = 0;
13 const int COLUMNS_PER_PIECE = 5;
17 m_imageOriginal (pixmapOriginal.toImage()),
18 m_rgbBackground (rgbBackground),
19 m_colorFilterMode (NUM_COLOR_FILTER_MODES),
23 m_restartTimer.setSingleShot (
false);
24 connect (&m_restartTimer, SIGNAL (timeout ()),
this, SLOT (slotRestartTimeout()));
31 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgFilterWorker::slotNewParameters filterMode=" << colorFilterMode
39 m_inputCommandQueue.push_back (command);
41 if (!m_restartTimer.isActive()) {
44 m_restartTimer.start (NO_DELAY);
48 void DlgFilterWorker::slotRestartTimeout ()
50 if (m_inputCommandQueue.count() > 0) {
53 m_inputCommandQueue.clear ();
63 m_restartTimer.start (NO_DELAY);
65 }
else if (m_xLeft < m_imageOriginal.width ()) {
68 int xStop = m_xLeft + COLUMNS_PER_PIECE;
69 if (xStop >= m_imageOriginal.width()) {
70 xStop = m_imageOriginal.width();
79 int processedWidth = xStop - m_xLeft;
80 QImage imageProcessed (processedWidth,
81 m_imageOriginal.height(),
82 QImage::Format_RGB32);
83 for (
int xFrom = m_xLeft, xTo = 0; (xFrom < xStop) && (m_inputCommandQueue.count() == 0); xFrom++, xTo++) {
84 for (
int y = 0; (y < m_imageOriginal.height ()) && (m_inputCommandQueue.count() == 0); y++) {
85 QColor pixel = m_imageOriginal.pixel (xFrom, y);
87 if (pixel.rgb() != m_rgbBackground) {
96 imageProcessed.setPixel (xTo, y, (isOn ?
97 QColor (Qt::black).rgb () :
98 QColor (Qt::white).rgb ()));
102 if (m_inputCommandQueue.count() == 0) {
105 m_xLeft += processedWidth;
108 if ((xStop < m_imageOriginal.width()) ||
109 (m_inputCommandQueue.count () > 0)) {
112 m_restartTimer.start (NO_DELAY);
ColorFilterMode colorFilterMode() const
Get method for filter mode.
Command pattern object for receiving new parameters in DlgFilterWorker from GUI thread.
double high0To1() const
Get method for high value.
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...
bool pixelUnfilteredIsOn(ColorFilterMode colorFilterMode, const QColor &pixel, QRgb rgbBackground, double low0To1, double high0To1) const
Return true if specified unfiltered pixel is on.
DlgFilterWorker(const QPixmap &pixmapOriginal, QRgb m_rgbBackground)
Single constructor.