void on_mouse(int event, int x, int y, int flags, void * params ){ switch(event){ case CV_EVENT_LBUTTONDOWN: // set rect if( rectState == 0 ){ rectState = 1; rect = cvRect( x, y, 1, 1 ); } break; case CV_EVENT_LBUTTONUP: if( rectState == 1 ) { rect = cvRect(rect.x, rect.y,x,y); rectState = 2; rect.x = fmax(0, rect.x); rect.y = fmax(0, rect.y); rect.width = fmin(rect.width, Mbvimg->cols-rect.x); rect.height = fmin(rect.height, Mbvimg->rows-rect.y); updateImage(); } break; case CV_EVENT_MOUSEMOVE: if( rectState == 1 ) { rect = cvRect(rect.x, rect.y,x,y ); updateImage(); } break; } }
void CATextView::AndroidWillInsertText(int start, const char* str, int before, int count) { CCAssert(str != NULL, ""); CCAssert(count > 0, ""); for (int i = 0; i < before; i++) { if (m_iCurPos == 0 || m_szText.empty()) break; int nDeleteLen = 1; while (0x80 == (0xC0 & m_szText.at(m_iCurPos - nDeleteLen))) { ++nDeleteLen; } std::string cszDelStr = m_szText.substr(m_iCurPos - nDeleteLen, nDeleteLen); CC_RETURN_IF(m_pTextViewDelegate && m_pTextViewDelegate->onTextViewDeleteBackward(this, cszDelStr.c_str(), (int)cszDelStr.length(), m_iCurPos - (int)cszDelStr.length())); CC_RETURN_IF(m_pTextViewDelegate && m_pTextViewDelegate->onTextViewDeleteBackward(this, cszDelStr.c_str(), (int)cszDelStr.length())); m_szText.erase(m_iCurPos - nDeleteLen, nDeleteLen); m_iCurPos -= nDeleteLen; } updateImage(); CC_RETURN_IF(str == NULL || count <= 0); std::string s = str; CC_RETURN_IF(m_pTextViewDelegate && m_pTextViewDelegate->onTextViewDeleteBackward(this, s.c_str(), (int)s.size(), m_iCurPos - (int)s.size())); CC_RETURN_IF(m_pTextViewDelegate && m_pTextViewDelegate->onTextViewInsertText(this, s.c_str(), (int)s.size())); m_szText.insert(m_iCurPos, s.c_str(), s.length()); m_iCurPos += s.length(); updateImage(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); default_scale = 1; current_scale = 1; image.load(":/aliceA.png"); scaled = image; files_names = QStringList(); pImage_lbl = new QLabel(); pImage_lbl->setAlignment(Qt::AlignCenter); ui->imageArea->setWidget(pImage_lbl); ui->imageArea->setBackgroundRole(QPalette::NoRole); loadListOfFiles(); setAcceptDrops(true); connect(&interpret, SIGNAL(ready(QImage)), this, SLOT(updateImage(QImage))); connect(ui->gammaSlider, SIGNAL(sliderReleased()), this, SLOT(refreshGamma())); connect(ui->zoomSlider, SIGNAL(sliderReleased()), this, SLOT(scaleImage())); connect(ui->filesList, SIGNAL(itemSelectionChanged()), this, SLOT(restoreDefaultScale())); connect(ui->filesList, SIGNAL(currentTextChanged(QString)), this, SLOT(updateImage(QString))); updateImage("aliceA.png"); }
void CATextView::AndroidWillInsertText(int start, const char* str, int before, int count) { CCAssert(str != NULL, ""); CCAssert(count > 0, ""); for (int i=0; i<before; i++) { if (m_iCurPos == 0 || m_szText.empty()) break; int nDeleteLen = 1; while (0x80 == (0xC0 & m_szText.at(m_iCurPos - nDeleteLen))) { ++nDeleteLen; } m_szText.erase(m_iCurPos - nDeleteLen, nDeleteLen); m_iCurPos -= nDeleteLen; } updateImage(); CC_RETURN_IF(str == NULL || count <= 0); std::string s = str; m_szText.insert(m_iCurPos, s.c_str(), s.length()); m_iCurPos += s.length(); updateImage(); }
void TB_PokemonBody::connectWithAdvanced(TB_Advanced *ptr) { connect(ptr, SIGNAL(abilityChanged()), this, SLOT(updateAbility())); connect(ptr, SIGNAL(levelChanged()), this, SLOT(updateLevel())); connect(ptr, SIGNAL(imageChanged()), this, SLOT(updateImage())); connect(ptr, SIGNAL(genderChanged()), this, SLOT(updateGender())); connect(ptr, SIGNAL(genderChanged()), this, SLOT(updateImage())); connect(ptr, SIGNAL(statChanged()), this, SLOT(updateEVs())); connect(ptr, SIGNAL(pokeFormeChanged(Pokemon::uniqueId)), this, SLOT(changeForme(Pokemon::uniqueId)), Qt::QueuedConnection); connect(this, SIGNAL(EVChanged(int)), ptr, SLOT(updateStat(int))); connect(this, SIGNAL(natureChanged()), ptr, SLOT(updateStats())); connect(this, SIGNAL(pokeImageChanged()), ptr, SLOT(updatePokeImage())); connect(ptr, SIGNAL(levelChanged()), this, SIGNAL(levelChanged())); }
void LowFrameRateImageProvider::logCurrentImage(LowFrameRateImage& lowFrameRateImage) { if(theFrameInfo.getTimeSince(lastUpdateTime) >= 60000 / frameRate) { // Generate new image lastUpdateTime = theFrameInfo.time; updateImage(lowFrameRateImage); storeNextImage = true; // Store next image as well to make sure to get both upper and lower cam images } else if(storeNextImage) { updateImage(lowFrameRateImage); storeNextImage = false; } }
void PieceAvailabilityBar::setAvailability(const std::vector<int>& avail) { pieces = std::vector<int>(avail); updateImage(); update(); }
void deleteBackward() { CC_RETURN_IF(m_iCurPos == 0 || m_szText.empty()); if (m_curSelCharRange.first != m_curSelCharRange.second) { if (!textValueChanged(m_curSelCharRange.first, m_curSelCharRange.second - m_curSelCharRange.first, "")) return; CC_RETURN_IF(execCurSelCharRange()); } else { int nDeleteLen = 1; while (0x80 == (0xC0 & m_szText.at(m_iCurPos - nDeleteLen))) { ++nDeleteLen; } if (!textValueChanged(m_iCurPos, nDeleteLen, "")) return; m_iCurPos = MAX(m_iCurPos, nDeleteLen); m_szText.erase(m_iCurPos - nDeleteLen, nDeleteLen); m_iCurPos -= nDeleteLen; updateImage(); } }
void insertText(const char * text, int len) { if (!strcmp(text, "\n")) { if (m_pCATextView->getReturnType() != CrossApp::CATextView::Default) { m_pCATextView->resignFirstResponder(); if (m_pCATextView->getDelegate()) { m_pCATextView->getDelegate()->textViewShouldReturn(m_pCATextView); } return; } } std::string cszAddText; cszAddText.append(text, len); if (m_curSelCharRange.first != m_curSelCharRange.second) { if (!textValueChanged(m_curSelCharRange.first, m_curSelCharRange.second - m_curSelCharRange.first, cszAddText)) return; } else { if (!textValueChanged(m_iCurPos, 0, cszAddText)) return; } execCurSelCharRange(); m_szText.insert(m_iCurPos, text, len); m_iCurPos += len; m_curSelCharRange = std::make_pair(m_iCurPos, m_iCurPos); updateImage(); }
void PaintChatWindow::on_haveUpdate(){ std::cerr<<"PaintChatWindow::on_haveUpdate()"<<std::endl; if(chatType == ChatWidget::CHATTYPE_PRIVATE) { updateImage(); } if(chatType == ChatWidget::CHATTYPE_LOBBY) { QImage i = ui->paintWidget->getImage(); QPainter p(&i); p.setPen(Qt::black); p.setBrush(Qt::NoBrush); p.drawRect(0, 0, 302, 102); ui->paintWidget->setImage(i); QImage img = ui->paintWidget->getImage().copy(1, 1, 301, 101); std::string html = imgToHtmlString(img); ui->progressBar->setValue((html.size()*100)/MAX_LOBBY_MSG_SIZE); if(html.size()>MAX_LOBBY_MSG_SIZE) { ui->progressBar->setValue(100); } } }
/** * Rebuild the scrollbars and image due to a change in the range xmin, xmax * or step size. It should be invoked when the user changes the values in * the xmin, xmax or step controls. It should not be called directly from * other threads. */ void SpectrumDisplay::updateRange() { if ( m_dataSource == 0 ) return; // No image data to update if ( dataSourceRangeChanged() ) setDataSource( m_dataSource ); // Re-initialize with the altered source QRect displayRect; getDisplayRectangle( displayRect ); // Range controls now determine the number of bins double min = m_totalXMin; double max = m_totalXMax; double step = (m_totalXMax - m_totalXMin) / 2000; m_rangeHandler->getRange( min, max, step ); int numBins = SVUtils::NumSteps( min, max, step ); if ( numBins == 0 ) return; m_sliderHandler->configureHSlider( numBins, displayRect.width() ); updateImage(); }
/** * Change the control parameter (0...100) used to brighten the image. * If the control parameter is 0, the mapping from data values to color * table index will be linear. As the control parameter is increased * the mapping becomes more and more non-linear in a way that emphasizes * the lower level values. This is similar to a log intensity scale. * * @param controlParameter This is clamped between 0 (linear) and * 100 (most emphasis on low intensity values) */ void SpectrumDisplay::setIntensity( double controlParameter ) { size_t DEFAULT_SIZE = 100000; ColorMaps::GetIntensityMap( controlParameter, DEFAULT_SIZE, m_intensityTable); m_spectrumPlotItem->setIntensityTable( &m_intensityTable ); updateImage(); }
void skeletonVisualization::updateSkeleton() { if (imagepath.size() != 0) { image = QImage(imagepath); byte* img = new byte[image.height() * image.width()]; for (int i = 0; i < image.height(); i++) for(int j = 0; j < image.width(); j++) if (skeletonView) img[i * image.width() + j] = toGrayscale(image.pixel(j, image.height() - 1 - i)); else img[i * image.width() + j] = 255 - toGrayscale(image.pixel(j, image.height() - 1 - i)); SkeletonMaker::SourceImage srcimg; srcimg.height = image.height(); srcimg.width = image.width(); srcimg.pixels = img; skeleton = skeletonMaker.createSkeleton(&srcimg, ui.spinBoxPruning->value(), ui.spinBoxArea->value()); ui.labelTime->setText( QString("Elapsed time:\n%1 ms - DLL\n%2 ms - C++"). arg(skeleton.totalTime).arg(skeleton.cppTime)); ready = true; updateImage(); } }
void PicManager::readFile(const QString &fullPath) { QFileInfo fileInfo(fullPath); if(curPath == fileInfo.absoluteFilePath() )//! if the image needs refresh? return; curPath = fileInfo.absoluteFilePath(); curName = fileInfo.fileName(); curImage->recycle(); curImage = ImageFactory::getImageWrapper(curPath); if(curImage->isAnimation()) { connect(curImage, SIGNAL(animationUpdated()), SLOT(updateAnimation())); curImage->startAnimation(); } else if (curImage->frameCount() > 1){ // like ico format connect(curImage, SIGNAL(frameUpdated()), SLOT(updateImage())); } QImage image = curImage->currentImage(); QString errorMsg = image.isNull() ? Global::LoadFileErrorInfo().arg(curPath) : QString::null; loadImage(image, errorMsg); // state = image.isNull() ? FileNoPicture : FilePicture; emit imageChanged(curName); }
/** * Repaints the view. If the view has been invalidated before, * the view is redrawn from scratch. Otherwise, only a cached * buffer is drawn (very fast). * * \see invalidate */ void RGraphicsViewQt::paintEvent(QPaintEvent* e) { // enable timer for performance monitoring: //RDebug::startTimer(); RDocumentInterface* di = getDocumentInterface(); if (di!=NULL && di->isSuspended()) { QPainter wPainter(this); //wPainter.drawImage(0, 0, graphicsBuffer); wPainter.drawImage(getRect(), graphicsBuffer); //QPixmap pm; //pm.convertFromImage(graphicsBuffer); //wPainter.drawPixmap(this->rect(), pm); wPainter.end(); return; } updateImage(); // event is NULL for fake paint events (testing): if (e!=NULL) { QPainter wPainter(this); //wPainter.drawImage(0, 0, graphicsBufferWithPreview); wPainter.drawImage(getRect(), graphicsBufferWithPreview); //QPixmap pm; //pm.convertFromImage(graphicsBufferWithPreview); //wPainter.drawPixmap(this->rect(), pm); wPainter.end(); } //RDebug::stopTimer("paintEvent"); }
void KisNormalPreviewWidget::setBlueChannel(int index) { if (index>=0 && index<6){ m_blueChannel=index; } updateImage(); }
void MainWindow::on_actionRename_triggered(bool) { if (images_.count()==0) return; QString folder = images_[0].folder(); for (int i=0; i<images_.count(); ++i) { //get EXIF date QByteArray date; if (!getExifDate(images_[i].filename(), date)) { QMessageBox::warning(this, "EXIF data not found!", "EXIF creation date not found for file:\n" + images_[i].filename() + "\nMessage: " + date + "\nAborting!"); break; } //format '2004:04:23 13:05:04' to '20040423_130504' date.replace(":", "").replace(" ","_"); //determine new file name QString file_o = images_[i].filename(false); QString ext = file_o.right(4); int number = 1; while (QFile::exists(folder + "\\" + date + "-" + QString::number(number) + ext)) { ++number; } //rename QFile::rename(images_[i].filename(), folder + "\\" + date + "-" + QString::number(number) + ext); } updateImageList(folder); updateImage(0); }
/* void CPixmap::toLuminosity(int value) { m_effects.push_back(...); QImage img = this->toImage(); QImage dest(img.size(), img.format()); QColor pixel; for(int x=0; x<img.width();x++) { for (int y=0; y<img.height(); y++) { pixel = img.pixel(x, y); int green = pixel.green() + value; int red = pixel.red() + value; int blue = pixel.blue() + value; if(green > 255) green = 255; else if(green < 0) green = 0; if(red > 255) red = 255; else if(red < 0) red = 0; if(blue > 255) blue = 255; else if(blue <0) blue = 0; pixel.setGreen(green); pixel.setBlue(blue); pixel.setRed(red); dest.setPixel(x,y,pixel.rgb()); } } updateImage(dest); } */ void CPixmap::crop(const QRect &cropingRect) { if(cropingRect.isNull()) return; m_effects.push_back(PictureEffect(PictureEffect::Crop, PictureEffect::Crop, cropingRect)); QImage img = this->toImage().copy(cropingRect); updateImage(img); }
Tile::Tile(std::string in) : img(""), sprite("none"), slowness(1,1), jumping(false), solid(true), shading(false) { raw = in; std::vector<std::string> toks = split(raw,';'); for (unsigned int i = 0; i < toks.size(); i++) { std::vector<std::string> kv = split(stripspaces(toks[i]),':',2); if (kv.size() != 2) continue; std::string key = kv[0], value = kv[1]; if (key == "img") img = value; if (key == "sprite") sprite = value; if (key == "slowness"){ std::vector<std::string> toks = split(value,','); if (toks.size() != 2) continue; slowness = vec2(toint(toks[0]),toint(toks[1])); } if (key == "jumping") jumping = tobool(value); if (key == "solid") solid = tobool(value); if (key == "shading") shading = tobool(value); if (startswith(key,"on_")) scripts[key] = value; } updateImage(); }
cVideoLabel::cVideoLabel(QWidget *parent) : QLabel(parent) { //Need this to allow the object to track mouse events setFocusPolicy(Qt::ClickFocus); //JJV DEBUG - hardcoded stuff this->moveForwardKey = Qt::Key_E; this->moveBackwardKey = Qt::Key_D; this->moveLeftKey = Qt::Key_S; this->moveRightKey = Qt::Key_F; //Setup the OpenCV thread this->thread = new QThread; this->openCVObj = new OPENCV_HANDLER(); this->openCVObj->moveToThread(this->thread); connect(this->openCVObj, SIGNAL(error(QString)), this, SLOT(videoError(QString))); connect(this->thread, SIGNAL(started()), this->openCVObj, SLOT(process())); connect(this->openCVObj, SIGNAL(finished()), this->thread, SLOT(quit())); connect(this->openCVObj, SIGNAL(finished()), this->openCVObj, SLOT(deleteLater())); connect(this->thread, SIGNAL(finished()), this->thread, SLOT(deleteLater())); connect(this->openCVObj, SIGNAL(imageReady(QPixmap)), this, SLOT(updateImage(QPixmap))); this->thread->start(); }
static void visualizeNeuron(const NeuralNetwork& network, Image& image, unsigned int outputNeuron) { Matrix matrix; std::string solverClass = util::KnobDatabase::getKnobValue( "NeuronVisualizer::SolverClass", "Differentiable"); if(solverClass == "Differentiable") { matrix = optimizeWithDerivative(&network, image, outputNeuron); } else if(solverClass == "NonDifferentiable") { matrix = optimizeWithoutDerivative(&network, image, outputNeuron); } else if(solverClass == "Analytical") { matrix = optimizeAnalytically(&network, image, outputNeuron); } else { throw std::runtime_error("Invalid neuron visializer solver class " + solverClass); } size_t x = 0; size_t y = 0; util::getNearestToSquareFactors(x, y, network.getInputBlockingFactor()); updateImage(image, matrix, x, y); }
void PaintChatWindow::on_haveUpdate(){ std::cerr<<"PaintChatWindow::on_haveUpdate()"<<std::endl; if(chatType == ChatWidget::CHATTYPE_PRIVATE) { updateImage(); } if(chatType == ChatWidget::CHATTYPE_LOBBY) { QImage i = ui->paintWidget->getImage(); // QPainter p(&i); // p.setPen(Qt::black); // p.setBrush(Qt::NoBrush); // p.drawRect(0, 0, 302, 102); // ui->paintWidget->setImage(i); QImage img = ui->paintWidget->getImage(); std::string html; bool scaled = imgToHtmlString(html, img, MAX_LOBBY_MSG_SIZE); ui->progressBar->setValue((html.size()*100)/MAX_LOBBY_MSG_SIZE); if(html.size()>MAX_LOBBY_MSG_SIZE) { ui->progressBar->setValue(100); } ui->lblImageSize->setText(QString("Image size: %1 bytes").arg(html.size())); ui->lblWarning->setVisible(scaled); } }
void TerrainProceduralDialog::makePertrub(float frequency, float distance) { setWorking(true); PerlinNoise perlin; perlin.setSeed(1); perlin.initGradients(); int u, v; float * temp = new float[m_mapWidth*m_mapDepth]; for (int i = 0; i < m_mapWidth; ++i) for (int j = 0; j < m_mapDepth; ++j) { u = i + (int)(perlin.noise(frequency * i / (float)m_mapWidth, frequency * j / (float)m_mapDepth, 0) * distance); v = j + (int)(perlin.noise(frequency * i / (float)m_mapWidth, frequency * j / (float)m_mapDepth, 1) * distance); if (u < 0) u = 0; if (u >= m_mapWidth) u = m_mapWidth - 1; if (v < 0) v = 0; if (v >= m_mapDepth) v = m_mapDepth - 1; temp[i*m_mapWidth+j] = data[u*m_mapWidth+v]; } for(int i=0;i<m_mapWidth*m_mapDepth;i++) data[i]=temp[i]; delete temp; updateImage(); setWorking(false); }
/** * @brief ProcessAux * @param imgIn * @param imgOut * @return */ Image *ProcessAux(ImageVec imgIn, Image *imgOut) { updateImage(imgIn[0]); //luminance image images[2] = flt_lum.Process(imgIn, images[2]); //bilateral filter seperation bilateralSeparation(images[2], images, -1.0f, 0.4f, true); Image *base = images[0]; Image *detail = images[1]; float min_log_base, max_log_base; base->getMinVal(NULL, &min_log_base); base->getMaxVal(NULL, &max_log_base); float compression_factor = log10fPlusEpsilon(target_contrast) / (max_log_base - min_log_base); float log_absoulte = compression_factor * max_log_base; *base *= compression_factor; *base += detail; *base -= log_absoulte; base->applyFunction(powf10fMinusEpsilon); *imgOut = *imgIn[0]; *imgOut *= base; *imgOut /= images[2]; imgOut->removeSpecials(); return imgOut; }
void CATextView::deleteBackward() { CC_RETURN_IF(m_iCurPos == 0 || m_szText.empty()); std::string cszDelStr; if (m_curSelCharRange.first != m_curSelCharRange.second) { cszDelStr = m_szText.substr(m_curSelCharRange.first, m_curSelCharRange.second - m_curSelCharRange.first); } else { int nDeleteLen = 1; while (1) { CC_BREAK_IF(m_iCurPos - nDeleteLen < 0); CC_BREAK_IF(0x80 != (0xC0 & m_szText.at(m_iCurPos - nDeleteLen))); ++nDeleteLen; } cszDelStr = m_szText.substr(m_iCurPos - nDeleteLen, nDeleteLen); } CC_RETURN_IF(m_pTextViewDelegate && m_pTextViewDelegate->onTextViewDeleteBackward(this, cszDelStr.c_str(), (int)cszDelStr.length())); CC_RETURN_IF(execCurSelCharRange()); int nDeleteLen = (int)cszDelStr.size(); m_iCurPos = MAX(m_iCurPos, nDeleteLen); m_szText.erase(m_iCurPos - nDeleteLen, nDeleteLen); m_iCurPos -= nDeleteLen; updateImage(); m_pTextArrView->hideTextArrView(); }
void ColorButton::pickColor() { QColor newColor = QColorDialog::getColor(_color, this, QString(), QColorDialog::ColorDialogOptions(_alpha ? QColorDialog::ShowAlphaChannel : 0)); if(newColor.isValid()) { _color = newColor; updateImage(); emit colorChanged(_color); } }
void DownloadedPiecesBar::setProgress(const QBitArray &pieces, const QBitArray &downloadedPieces) { m_pieces = pieces; m_downloadedPieces = downloadedPieces; updateImage(); update(); }
void FixedAspectLabel::setImageFromData(uint8_t *data, int width, int height, const double *ddata) { if(buffer) delete [] buffer; if(dbuffer) delete [] dbuffer; buffer = data; dbuffer = ddata; image = new QImage((uchar*) buffer, width, height, QImage::Format_ARGB32); updateImage(); }
CameraEngine::CameraEngine(QObject *parent) : QThread(parent) { QSettings settings("RobotStation"); m_camera = settings.value("camera",0).toInt(); m_stop = false; connect(this,SIGNAL(imageReady(Mat)),this,SLOT(updateImage(Mat))); }
void CPixmap::clearEffects() { if (!m_image.isNull()) updateImage(m_image); else if (!m_filePath.isEmpty()) load(m_filePath); m_effects.clear(); }