示例#1
0
//警报显示
void dlpy_main::alertFrame()
{
    Mat roi_alert,roi_alert_tmp,roi_temp;
    if(times_alert>0)
    {
        if(times_alert%2==0)
        {
            if(last_alert==1){roi_temp=img_temp(roi_l);roi_alert_tmp = img_alert_1(roi_l);}
            if(last_alert==2){roi_temp=img_temp(roi_r);roi_alert_tmp = img_alert_1(roi_r);}
            if(last_alert==3){roi_temp=img_temp(roi_l);roi_alert_tmp = img_alert_2(roi_l);}
            if(last_alert==4){roi_temp=img_temp(roi_r);roi_alert_tmp = img_alert_2(roi_r);}
            roi_alert_tmp.copyTo(roi_temp);
        }else{
            img_alert.copyTo(img_temp);
        }
        times_alert--;      //控制闪烁
        QGraphicsScene *scene = new QGraphicsScene;
        QImage *qimg=new QImage;
        *qimg=mat2qimage(img_temp);
        scene->addPixmap(QPixmap::fromImage(*qimg));
        ui->graphicsView->setScene(scene);
        ui->graphicsView->resize(qimg->width() + 10, qimg->height() + 10);
        ui->graphicsView->show();
    }else{

    }
}
示例#2
0
void MainWindow::do_open(const QString &initial_file)
{
	QString path_temp;
	QString start_dir;

	QStringList picture_locations =
			QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);

	if(initial_file.isNull() || initial_file.isEmpty()) {
		if(img_path_.isEmpty()) {
			if(!picture_locations.empty()) {
				start_dir = picture_locations.first();
			} else {
				start_dir = ".";
			}
		} else {
			start_dir = QFileInfo(img_path_).absolutePath();
		}

		path_temp = QFileDialog::getOpenFileName(
			this,
			tr("Choose source image"),
			start_dir,
			supported_file_patterns()
		);
	}
	else {
		path_temp = initial_file;
	}

	if(path_temp.isNull() && img_original_.isNull()) {
		// it's null if we've just setup the window
		throw no_initial_file();
	}

	QImage img_temp(path_temp);
	if(img_temp.isNull()) {
		if(path_temp.isNull() != true) {
			MosUi::error(
				this, tr("Could not load %1.").arg(path_temp));
		}

		if(img_original_.isNull()) {
			throw no_initial_file();
		}

		mos_remove_recent_file(path_temp);

		return;
	}

	img_path_ = path_temp;
	// We want to work on actual ARGB data
	img_original_ = img_temp.convertToFormat(QImage::Format_ARGB32);

	// Refresh UI
	mos_add_recent_file(img_path_);
	update_recent_files_menu();
	update_window_title(img_path_);
	refresh_previews();
}