Esempio n. 1
0
void ImageWidget::contextMenuEvent(QContextMenuEvent *event)
{
    QMenu menu;

    if (mType == Photo) {
        if (!mReadOnly) {
            menu.addAction(i18n("Change photo..."), this, SLOT(changeImage()));
            menu.addAction(i18n("Change URL..."), this, SLOT(changeUrl()));
        }

        if (mHasImage) {
            menu.addAction(i18n("Save photo..."), this, SLOT(saveImage()));

            if (!mReadOnly) {
                menu.addAction(i18n("Remove photo"), this, SLOT(deleteImage()));
            }
        }
    } else {
        if (!mReadOnly) {
            menu.addAction(i18n("Change logo..."), this, SLOT(changeImage()));
            menu.addAction(i18n("Change URL..."), this, SLOT(changeUrl()));
        }

        if (mHasImage) {
            menu.addAction(i18n("Save logo..."), this, SLOT(saveImage()));

            if (!mReadOnly) {
                menu.addAction(i18n("Remove logo"), this, SLOT(deleteImage()));
            }
        }
    }

    menu.exec(event->globalPos());
}
Esempio n. 2
0
skeletonVisualization::skeletonVisualization(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
{
	ui.setupUi(this);

	ui.centralWidget->setContentsMargins(6, 6, 6, 6);
	ui.centralWidget->setLayout(ui.horizontalLayout);

    connect(ui.buttonOpen, SIGNAL(clicked()),
            this, SLOT(openImage()));
    connect(ui.actionOpen, SIGNAL(activated()),
            this, SLOT(openImage()));

    connect(ui.buttonRefresh, SIGNAL(clicked()),
            this, SLOT(updateSkeleton()));
    connect(ui.actionRefresh, SIGNAL(activated()),
            this, SLOT(updateSkeleton()));

    connect(ui.buttonSave, SIGNAL(clicked()),
            this, SLOT(saveImage()));
    connect(ui.actionSave, SIGNAL(activated()),
            this, SLOT(saveImage()));

    connect(ui.buttonConnect, SIGNAL(clicked()),
            this, SLOT(breaksConnector()));
    connect(ui.actionConnect, SIGNAL(activated()),
            this, SLOT(breaksConnector()));

    connect(ui.buttonQuit, SIGNAL(clicked()),
            this, SLOT(exitMethod()));
    connect(ui.actionQuit, SIGNAL(activated()),
            this, SLOT(exitMethod()));

    connect(ui.sliderScale, SIGNAL(valueChanged(int)),
            this, SLOT(setScaleValue(int)));
    connect(ui.checkBoxCircles, SIGNAL(stateChanged(int)),
            this, SLOT(checkBoxesChanged(int)));
    connect(ui.checkBoxBones, SIGNAL(stateChanged(int)),
            this, SLOT(checkBoxesChanged(int)));
    connect(ui.checkBoxContours, SIGNAL(stateChanged(int)),
            this, SLOT(checkBoxesChanged(int)));
    connect(ui.checkBoxImage, SIGNAL(stateChanged(int)),
            this, SLOT(checkBoxesChanged(int)));

    connect(ui.actionOn, SIGNAL(activated()), this, SLOT(scaleOn()));
    connect(ui.actionOff, SIGNAL(activated()), this, SLOT(scaleOff()));
    connect(ui.actionOriginal, SIGNAL(activated()), this, SLOT(scaleOrig()));
    connect(ui.actionInternal, SIGNAL(activated()), this, SLOT(internal()));
    connect(ui.actionExternal, SIGNAL(activated()), this, SLOT(external()));

    scene = 0;
    drawCircles = ready = 0;
    drawBones = drawImage = drawContours = skeletonView = 1;
    scale = 1.0;
}
void saveAs(int fileType) {
	if (fileType == PNG) 
		printf("Saving as .png (Rendering %d pixels)\n", mVar->png_h * mVar->png_w);
	else
		printf("Saving as .ppm (Rendering %d pixels)\n", mVar->png_h * mVar->png_w);
	//Create arrays to load pixels into
	int i;
	rgb_t **tex;
	int **texIter;
	char filename[20] = {0};

	tex = (rgb_t**)malloc(sizeof(rgb_t*) * mVar->png_h);
	texIter = (int**)malloc(sizeof(int*) * mVar->png_h);
	for(i=0; i < mVar->png_h; i++) {
		tex[i] = (rgb_t*)malloc(sizeof(rgb_t) * mVar->png_w);
		texIter[i] = (int*)malloc(sizeof(int) * mVar->png_w);
	}

	switch (mVar->function) {
		case MANDEL_AND_JULIA:
			i = 0; // This statement does nothing but prevents a silly error
			// Adjust zoom so that the saved image will be approximately the
			// same as the displayed image, but of the corrext resolution.
			double tempZoomM = mVar->zoomM;
			double tempZoomJ = mVar->zoomJ;
			mVar->zoomM *= mVar->width / (double)mVar->png_w;
			mVar->zoomJ *= mVar->width / (double)mVar->png_w;
			calcComplexFunction(mVar->png_w, mVar->png_h, tex, texIter, WHOLE_SCREEN, MANDELBROT);
			sprintf(filename, "mandelbrot%i", mVar->imgCount);
			saveImage(mVar->png_w, mVar->png_h, tex, filename, fileType);
			printf("Image Saved as %s\n", filename);
			calcComplexFunction(mVar->png_w, mVar->png_h, tex, texIter, WHOLE_SCREEN, JULIA);
			sprintf(filename, "julia%i", mVar->imgCount);
			saveImage(mVar->png_w, mVar->png_h, tex, filename, fileType);
			mVar->zoomM = tempZoomM;
			mVar->zoomJ = tempZoomJ;
			printf("Image Saved as %s\n", filename);
			mVar->imgCount++;
			break;
		default:
			calcComplexFunction(mVar->png_w, mVar->png_h, tex, texIter, WHOLE_SCREEN, mVar->function);
			sprintf(filename, "complexfunction%i", mVar->imgCount);
			saveImage(mVar->png_w, mVar->png_h, tex, filename, fileType);
			printf("Image Saved as %s\n", filename);
			mVar->imgCount++;
	}

	for(i=0; i < mVar->png_h; i++) {
		free(tex[i]);
		free(texIter[i]);
	}
	free(tex);
	free(texIter);
}
Esempio n. 4
0
void MathDisplay::buildActions()
{
	setContextMenuPolicy(Qt::ActionsContextMenu);

	act_copyText = new QAction(tr("Copy text"), this);
	connect(act_copyText, SIGNAL(triggered()), this, SLOT(copyText()));
	this->addAction(act_copyText);

	act_copyLatex = new QAction(tr("Copy LaTeX code"), this);
	connect(act_copyLatex, SIGNAL(triggered()), this, SLOT(copyLatex()));
	this->addAction(act_copyLatex);

	act_copyMml = new QAction(tr("Copy MathML code"), this);
	connect(act_copyMml, SIGNAL(triggered()), this, SLOT(copyMml()));
	this->addAction(act_copyMml);

	act_copyImage = new QAction(tr("Copy image"), this);
	connect(act_copyImage, SIGNAL(triggered()), this, SLOT(copyImage()));
	act_copyImage->setEnabled(false);
	this->addAction(act_copyImage);

	act_saveImage = new QAction(tr("Save image"), this);
	connect(act_saveImage, SIGNAL(triggered()), this, SLOT(saveImage()));
	act_saveImage->setEnabled(false);
	this->addAction(act_saveImage);
}
Esempio n. 5
0
void MyQGraphicsView::mouseReleaseEvent(QMouseEvent * e)
{
//    emit viewClicked();
    if (e->button() == Qt::RightButton) {
       saveImage();
    }
}
Esempio n. 6
0
int main()
{
    int w = 400, h = 300;
    cout << "Input image's width,height:" << endl;
    cin >> w >> h;
    assert(w > 0 && h > 0);

    std::vector<char> buf;
    buf.resize(w * h * 4);

    setupScene();
    {
        clock_t c = clock();
        onDrawBuffer(&buf[0], w, h, w * 4);
        cout << "cost time : " << (clock() - c) / 1000.f << endl;
    }
    cleanupScene();

    saveImage("scene.png", &buf[0], w, h, w * 4);
    
    {
        cout << "Press any key to continue..." << endl;
        char buf[32];
        cin.getline(buf, sizeof(buf));
        cin.getline(buf, sizeof(buf));
    }
}
Esempio n. 7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->horizontalSlider, SIGNAL(valueChanged(int)), ui->widget, SLOT(setPosX(int)));
    connect(ui->horizontalSlider_2, SIGNAL(valueChanged(int)), ui->widget, SLOT(setPosY(int)));
    connect(ui->horizontalSlider_3, SIGNAL(valueChanged(int)), ui->widget, SLOT(setR(int)));

    connect(ui->actionLoad_config, SIGNAL(triggered()), this, SLOT(openConfig()));
    connect(ui->actionSave_config, SIGNAL(triggered()), this, SLOT(saveConfig()));
    connect(ui->actionSave_image, SIGNAL(triggered()), this, SLOT(saveImage()));

    ui->horizontalSlider->setValue(0);
    ui->horizontalSlider->setMinimum(-10000);
    ui->horizontalSlider->setMaximum(10000);
    ui->spinBox->setValue(0);
    ui->spinBox->setMinimum(-10000);
    ui->spinBox->setMaximum(10000);

    ui->horizontalSlider_2->setValue(0);
    ui->horizontalSlider_2->setMinimum(-10000);
    ui->horizontalSlider_2->setMaximum(10000);
    ui->spinBox_2->setValue(0);
    ui->spinBox_2->setMinimum(-10000);
    ui->spinBox_2->setMaximum(10000);

    ui->horizontalSlider_3->setValue(20);
    ui->horizontalSlider_3->setMinimum(0);
    ui->horizontalSlider_3->setMaximum(10000);
    ui->spinBox_3->setValue(20);
    ui->spinBox_3->setMinimum(0);
    ui->spinBox_3->setMaximum(10000);
}
Esempio n. 8
0
BOOL saveDialog(HWND hWnd, Image &img)
{
	WCHAR *pszFileName;
	BOOL bReturn = FALSE;
	OPENFILENAME ofn = { sizeof(OPENFILENAME) };

	pszFileName = (WCHAR *)calloc(4096, sizeof(WCHAR));

	ofn.hwndOwner = hWnd;
	ofn.lpstrFilter = L"Portable Network Graphic (*.PNG)\0*.png\0";
	ofn.lpstrFile = pszFileName;
	ofn.lpstrDefExt = L"png";
	ofn.nMaxFile = 4096;
	ofn.lpstrTitle = L"Save Image";
	ofn.Flags = OFN_DONTADDTORECENT | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;

	if (GetSaveFileName(&ofn))
	{
		if ((ofn.Flags & OFN_EXTENSIONDIFFERENT) == OFN_EXTENSIONDIFFERENT)
			wcscat_s(pszFileName, 4096, L".png");

		saveImage(img, pszFileName);

		bReturn = TRUE;
	}

	free(pszFileName);

	return bReturn;
}
Esempio n. 9
0
  void callbackWithoutCameraInfo(const sensor_msgs::ImageConstPtr& image_msg)
  {
    if (is_first_image_) {
      is_first_image_ = false;

      // Wait a tiny bit to see whether callbackWithCameraInfo is called
      ros::Duration(0.001).sleep();
    }

    if (has_camera_info_)
      return;

    // saving flag priority:
    //  1. request by service.
    //  2. request by topic about start and end.
    //  3. flag 'save_all_image'.
    if (!save_image_service && request_start_end) {
      if (start_time_ == ros::Time(0))
        return;
      else if (start_time_ > image_msg->header.stamp)
        return;  // wait for message which comes after start_time
      else if ((end_time_ != ros::Time(0)) && (end_time_ < image_msg->header.stamp))
        return;  // skip message which comes after end_time
    }

    // save the image
    std::string filename;
    if (!saveImage(image_msg, filename))
      return;

    count_++;
  }
Esempio n. 10
0
    void HeatMapSaver::saveHeatMaps(const std::vector<Array<float>>& heatMaps, const std::string& fileName) const
    {
        try
        {
            // Record cv::mat
            if (!heatMaps.empty())
            {
                // File path (no extension)
                const auto fileNameNoExtension = getNextFileName(fileName) + "_heatmaps";

                // Get names for each heatMap
                std::vector<std::string> fileNames(heatMaps.size());
                for (auto i = 0; i < fileNames.size(); i++)
                    fileNames[i] = {fileNameNoExtension + (i != 0 ? "_" + std::to_string(i) : "") + "." + mImageFormat};

                // heatMaps -> cvOutputDatas
                std::vector<cv::Mat> cvOutputDatas(heatMaps.size());
                for (auto i = 0; i < cvOutputDatas.size(); i++)
                    unrollArrayToUCharCvMat(cvOutputDatas[i], heatMaps[i]);

                // Save each heatMap
                for (auto i = 0; i < cvOutputDatas.size(); i++)
                    saveImage(cvOutputDatas[i], fileNames[i]);
            }
        }
        catch (const std::exception& e)
        {
            error(e.what(), __LINE__, __FUNCTION__, __FILE__);
        }
    }
Esempio n. 11
0
void OmniFEMMainFrame::createTopToolBar()
{
    wxStandardPaths path = wxStandardPaths::Get();
	wxImage::AddHandler(new wxPNGHandler);
	std::string resourcesDirectory = path.GetAppDocumentsDir().ToStdString() + std::string("/GitHub/Omni-FEM/src/UI/MainFrame/resources/");// equilivant to ~ in command line. This is for the path for the source code of the resources
    
    mainFrameToolBar->Create(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_TOP | wxNO_BORDER);

	/* This section will need to load the images into memory */
	wxImage saveImage(resourcesDirectory + "save.png", wxBITMAP_TYPE_PNG);
	wxImage openImage(resourcesDirectory + "Open.png", wxBITMAP_TYPE_PNG);
	wxImage newFileImage(resourcesDirectory + "new_file.png", wxBITMAP_TYPE_PNG);
	
	/* This section will convert the images into bitmaps */
	wxBitmap saveBitmap(saveImage);
	wxBitmap openImageBitmap(openImage);
	wxBitmap newFileBitmap(newFileImage);
	
	/* This section will add the tool to the toolbar */
	mainFrameToolBar->AddTool(toolbarID::ID_ToolBarNew, newFileBitmap, "New File");
	mainFrameToolBar->AddTool(toolbarID::ID_ToolBarOpen, openImageBitmap, "Open");
	mainFrameToolBar->AddTool(toolbarID::ID_ToolBarSave, saveBitmap, "Save");
	
	/* Enable the tooolbar and associate it with the main frame */
	mainFrameToolBar->Realize();
	this->SetToolBar(mainFrameToolBar);
}
Esempio n. 12
0
void Interface::connection(void)
{
	QObject::connect(clearButton, SIGNAL(clicked()), this, SLOT(clearImage()));
	QObject::connect(saveButton, SIGNAL(clicked()), this, SLOT(saveImage()));
	QObject::connect(evaluateButton, SIGNAL(clicked()), this, SLOT(evaluateImage()));
	QObject::connect(penWidthSlider, SIGNAL(sliderReleased()), this, SLOT(penWidthChanged()));
}
Esempio n. 13
0
void
Viewer::graphContextMenu(const QPoint& pos)
{
    QPoint globalPos = this->ui.scrollArea->mapToGlobal(pos);

    QAction* selectedItem = graphMenu.exec(globalPos);
    if (selectedItem) {
        if (selectedItem->iconText() == GRAPH_UPDATE_ACTION)
        {
            updateGraphView();
        }
        else if (selectedItem->iconText() == GRAPH_OPTIONS_ACTION)
        {
            showGraphOptions();
        }
        else if (selectedItem->iconText() == GRAPH_VIEW_TO_FILE)
        {
            if (graphView != 0) {
                saveImage(graphView->pixmap());
            }
            else {
                this->ui.statusbar->showMessage( tr("No image to save."));
            }
        }
    }
}
Esempio n. 14
0
/**
 * Activates all action buttons.
 */
void FotoLab::activateActions()
{
	connect(ui.actionClose, SIGNAL(triggered()), qApp, SLOT(quit()));
	connect(ui.actionOpen, SIGNAL(triggered()), this, SLOT(openImage()));
	connect(ui.actionReload, SIGNAL(triggered()), this, SLOT(reloadImageData()));
	connect(ui.actionSaveAs, SIGNAL(triggered()), this, SLOT(saveImage()));
	connect(ui.actionAreaColor, SIGNAL(triggered()), this, SLOT(showColorDialog()));

	connect(ui.actionFillArea, SIGNAL(triggered()), ui.graphicsView, SLOT(fillArea()));
	connect(ui.actionCut, SIGNAL(triggered()), this, SLOT(cutArea()));
	connect(ui.actionEdges, SIGNAL(triggered()), this, SLOT(proposeEdges()));
	connect(ui.actionLines, SIGNAL(triggered()), this, SLOT(proposeLines()));

	connect(ui.actionDrawArea, SIGNAL(triggered()), ui.graphicsView, SLOT(switchDrawing()));

	//	connect(ui.actionProcess, SIGNAL(triggered()), ui.graphicsView, SLOT(processErase()));
	connect(ui.actionProcess, SIGNAL(triggered()), ui.graphicsView, SLOT(processShowEdges()));
	connect(ui.actionProperties, SIGNAL(triggered()), this, SLOT(showProperties()));

	connect(ui.actionHelpAbout, SIGNAL(triggered()), this, SLOT(showHelpAbout()));
	//	processShowEdges

	connect(ui.actionZoomIn, SIGNAL(triggered()), ui.graphicsView, SLOT(zoomIn()));
	connect(ui.actionZoomOut, SIGNAL(triggered()), ui.graphicsView, SLOT(zoomOut()));
	connect(ui.actionZoomNormal, SIGNAL(triggered()), ui.graphicsView, SLOT(zoomNormal()));

	connect(ui.actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

	connect(&tlowSpin, SIGNAL(valueChanged(double)), this, SLOT(validateLowTreshold(double)));
	connect(&thighSpin, SIGNAL(valueChanged(double)), this, SLOT(validateHighTreshold(double)));
}
Esempio n. 15
0
LRESULT CMainWindow::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    if (!imageModel.IsImageSaved())
    {
        TCHAR programname[20];
        TCHAR saveprompttext[100];
        TCHAR temptext[500];
        LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname));
        LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, saveprompttext, SIZEOF(saveprompttext));
        _stprintf(temptext, saveprompttext, filename);
        switch (MessageBox(temptext, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
        {
            case IDNO:
                DestroyWindow();
                break;
            case IDYES:
                saveImage(FALSE);
                if (imageModel.IsImageSaved())
                    DestroyWindow();
                break;
        }
    }
    else
    {
        DestroyWindow();
    }
    return 0;
}
Esempio n. 16
0
  void callbackWithCameraInfo(const sensor_msgs::ImageConstPtr& image_msg, const sensor_msgs::CameraInfoConstPtr& info)
  {
    has_camera_info_ = true;

    if (!save_image_service && request_start_end) {
      if (start_time_ == ros::Time(0))
        return;
      else if (start_time_ > image_msg->header.stamp)
        return;  // wait for message which comes after start_time
      else if ((end_time_ != ros::Time(0)) && (end_time_ < image_msg->header.stamp))
        return;  // skip message which comes after end_time
    }

    // save the image
    std::string filename;
    if (!saveImage(image_msg, filename))
      return;

    // save the CameraInfo
    if (info) {
      filename = filename.replace(filename.rfind("."), filename.length(), ".ini");
      camera_calibration_parsers::writeCalibration(filename, "camera", *info);
    }

    count_++;
  }
Esempio n. 17
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent),
      ui(new Ui::MainWindow)
{
    currLayerNumber = 0;

    ui->setupUi(this);

    ui->qwtPlot->setTitle("Error");
    ui->qwtPlot->setAxisTitle(ui->qwtPlot->xBottom, "Epoch");
    ui->qwtPlot->setAxisTitle(ui->qwtPlot->yLeft,"Error");

    QPen pen = QPen(Qt::red);
    curve = new QwtPlotCurve;
    curve->setRenderHint(QwtPlotItem::RenderAntialiased);
    curve->setPen(pen);
    curve->attach(ui->qwtPlot);

    Preprocessor p;
    Dataset d = p.readFile("1.dat");
    showResults(d);

    connect(ui->saveImageButton,SIGNAL(clicked()),this,SLOT(saveImage()));
    connect(ui->numberOfLayers,SIGNAL(valueChanged(int)),this,SLOT(changeLayers(int)));
}
    void ResAtlasGeneric::applyAtlas(atlas_data& ad, bool linear, bool clamp2edge)
    {
        if (!ad.texture)
            return;

        spMemoryTexture mt = new MemoryTexture;
        Rect bounds = ad.atlas.getBounds();

        //int w = nextPOT(bounds.getRight());
        //int h = nextPOT(bounds.getBottom());
        int w = bounds.getRight();
        int h = bounds.getBottom();

        mt->init(ad.mt.lock().getRect(Rect(0, 0, w, h)));
#if 0
        static int n = 0;
        n++;
        char name[255];
        safe_sprintf(name, "test%d.tga", n);
        saveImage(image_data, name);
#endif

        CreateTextureTask task;
        task.linearFilter = linear;
        task.clamp2edge = clamp2edge;
        task.src = mt;
        task.dest = ad.texture;
        LoadResourcesContext::get()->createTexture(task);
    }
Esempio n. 19
0
void TGLFunWidget::showContextMenu(const QPoint &pos)
{
    QPoint globalPos;
    QAction* selectedItem;
    QString fileName;

    if (sender()->inherits("QAbstractScrollArea"))
        globalPos = ((QAbstractScrollArea*)sender())->viewport()->mapToGlobal(pos);
    else
        globalPos = ((QWidget*)sender())->mapToGlobal(pos);

    if ((selectedItem = menu.exec(globalPos)))
    {
        if (selectedItem == action1)
        {
            bool isOk;
            QString exp = QInputDialog::getText(this, tr("Selection condition nodes"),tr("Predicate:"), QLineEdit::Normal, predicate,&isOk);

            if (isOk && exp.length())
            {
                predicate = exp;
                processPredicate();
            }
        }
        else if (selectedItem == action2)
        {
            fileName = QFileDialog::getSaveFileName(this,tr("Saving the image"),fileName,tr("Image files (*.png)"));

            if (!fileName.isEmpty())
                saveImage(fileName);
        }
    }
}
Esempio n. 20
0
void MaskStriple::saveImage()
{
    QString filename = QFileDialog::getSaveFileName(this, "Имя картинки", "", "Images (*.jpg)");
    if(filename.isEmpty())
        return;
    saveImage(filename);
}
Esempio n. 21
0
// Restore image from off-screen pixmap
long ShutterBug::onCmdSnap(FXObject*,FXSelector,void*){
  FXColor *pixels=NULL;

  // Try grab pixels
  if(snapRectangle(pixels,rectangle)){

    // Construct file dialog
    FXFileDialog savedialog(this,tr("Save Image"));
    savedialog.setSelectMode(SELECTFILE_ANY);
    savedialog.setPatternList(patterns);
    savedialog.setCurrentPattern(fileformat);
    savedialog.setFilename(FXPath::absolute(filename));

    // Run file dialog
    if(savedialog.execute()){
      filename=savedialog.getFilename();
      fileformat=savedialog.getCurrentPattern();
      if(FXStat::exists(filename) && FXMessageBox::question(this,MBOX_YES_NO,tr("Overwrite File"),tr("Overwrite existing image file: %s?"),filename.text())!=MBOX_CLICKED_YES) goto x;
      if(!saveImage(filename,pixels,rectangle.w,rectangle.h)){
        FXMessageBox::error(this,MBOX_OK,tr("Error Saving Image"),tr("Unable to save image to file: %s."),filename.text());
        }
      }

    // Free pixels
x:  freeElms(pixels);
    }
  return 1;
  }
Esempio n. 22
0
bool DirectoryInput::nextImage() {
    if (_itFilename == _filenameList.end()) {
        return false;
    }
    std::string path = _directory.fullpath(*_itFilename);

    _img = cv::imread(path.c_str());

    // read time from file name
    struct tm date;
    memset(&date, 0, sizeof(date));
    date.tm_year = atoi(_itFilename->substr(0, 4).c_str()) - 1900;
    date.tm_mon = atoi(_itFilename->substr(4, 2).c_str()) - 1;
    date.tm_mday = atoi(_itFilename->substr(6, 2).c_str());
    date.tm_hour = atoi(_itFilename->substr(9, 2).c_str());
    date.tm_min = atoi(_itFilename->substr(11, 2).c_str());
    date.tm_sec = atoi(_itFilename->substr(13, 2).c_str());
    _time = mktime(&date);

    log4cpp::Category::getRoot() << log4cpp::Priority::INFO << "Processing " << *_itFilename << " of " << ctime(&_time);

    // save copy of image if requested
    if (!_outDir.empty()) {
        saveImage();
    }

    _itFilename++;
    return true;
}
Esempio n. 23
0
/*!
  Worker method, checks if the thumb does not exist and starts saving to file.
*/
bool ImageScaler::convertToThumb(const QFileInfo& info)
{
    bool retVal = false;

    // The thumbnails are saved under a hidden folder in order
    // to avoid showing the thumbnails in the Media Gallery.
    const QString privatePath("/home/user/.mediabrowser/thumbs");
    QDir saveDir(privatePath + info.path());

    if (!saveDir.exists()) {
        if (!saveDir.mkpath(saveDir.path())) {
            qDebug() << "Thumbs folder creation failed. Quitting!";
            return false;
        }
    }
    // Create the thumb file path to the private save folder.
    QString saveName = saveDir.path() + "/" + info.fileName();

    // Check if the file already exists
    if (QFile::exists(saveName)) {
        qDebug() << "File: " << saveName << " already exist!";
    } else {
        // Does not exist yet, read, scale & save the image!
        retVal = saveImage(info, saveName);
    }

    return retVal;
}
Esempio n. 24
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    centralW = new QWidget;
    orignW = new QWidget;
    transW = new QWidget;
    qDebug("original");
    original = new Image(orignW, this);
    qDebug("transformed");
    transformed = new Image(transW, this);
    imageLayout = new QHBoxLayout;
    imageLayout->addWidget(orignW);
    imageLayout->addWidget(transW);
    centralW->setLayout(imageLayout);

    setCentralWidget(centralW);

    createActions();
    createMenus();

    setWindowTitle(tr("Transformation"));
    resize(1350, 700);

    connect(this, SIGNAL(saveImages(QString)), transformed, SLOT(saveImage(QString)));
}
Esempio n. 25
0
bool CoverUtils::coverFromFile(QString dir, Album *album) {
    static QList<QRegExp> coverREs;
    if (coverREs.isEmpty()) {
        QLatin1String ext(".(jpe?g|gif|png|bmp)");
        coverREs << QRegExp(".*cover.*" + ext, Qt::CaseInsensitive)
                 << QRegExp(".*front.*" + ext, Qt::CaseInsensitive)
                 << QRegExp(".*folder.*" + ext, Qt::CaseInsensitive);
    }

    const QFileInfoList flist = QDir(dir).entryInfoList(
                QDir::NoDotAndDotDot | QDir::Files | QDir::Readable
                );

    foreach (QFileInfo fileInfo, flist) {
        const QString filename = fileInfo.fileName();
        foreach (QRegExp re, coverREs) {
            if (filename.contains(re)) {
                qDebug() << "Found local cover" << filename;
                QImage image(fileInfo.absoluteFilePath());
                if (isAcceptableImage(image))
                    return saveImage(image, album);
                break;
            }
        }
    }

    return false;
}
Esempio n. 26
0
/**
 * Saves the image if full debugging mode is enabled.
 */
void saveDebug(char *filenameTemplate, int index, AVFrame *image) {
    if ( verbose >= VERBOSE_DEBUG_SAVE ) {
        char debugFilename[100];
        sprintf(debugFilename, filenameTemplate, index);
        saveImage(debugFilename, image, image->format);
    }
}
Esempio n. 27
0
void Gear_ImageCapture::runVideo()
{
    if (_CAPTURE_IN->type()->value()!=0.0f)
    {
        saveImage(_settings.get(SETTING_FILENAME)->valueStr(), _VIDEO_IN->type());
    }
}
void MainWindow::on_generateEnvironment_clicked()
{
    if(!Directory.exists()&&save){QMessageBox::warning(0,"Error","No such directory.", QMessageBox::Ok);return;}


    for(int i=0;i<generations;i++)
    {


        environmentobject->regenerate();

        RefreshEnvironment();
        qApp->processEvents();

        if(save)
        {
            QImage saveImage(GRID_X,GRID_Y,QImage::Format_RGB32);
            for (int n=0; n<GRID_X; n++)
                for (int m=0; m<GRID_Y; m++)
                    saveImage.setPixel(n,m,qRgb(environmentobject->environment[n][m][0], environmentobject->environment[n][m][1], environmentobject->environment[n][m][2]));
            QString dir2;
            if(i<10)dir2 = QString(Directory.path() + "/000%1.bmp").arg(i);
            if(i>9&&i<100)dir2 = QString(Directory.path() + "/00%1.bmp").arg(i);
            if(i>99&&i<1000)dir2 = QString(Directory.path() + "/0%1.bmp").arg(i);
            if(i>999)dir2 = QString(Directory.path() + "/%1.bmp").arg(i);
            saveImage.save(dir2);
        }

    }
}
Esempio n. 29
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void WriteImages::execute()
{
  int32_t err = 0;
  setErrorCondition(err);
  dataCheck();
  if(getErrorCondition() < 0) { return; }

  DataContainer::Pointer m = getDataContainerArray()->getDataContainer(m_ColorsArrayPath.getDataContainerName());
  size_t dims[3] = { 0, 0, 0 };
  m->getGeometryAs<ImageGeom>()->getDimensions(dims);

  if (0 == m_Plane) // XY plane
  {
    for (size_t z = 0; z < dims[2]; ++z)
    {
      err = saveImage(z, dims[0], dims[1], dims);
      if (-1 == err)
      {
        return;
      }
    }
  }
  else if (1 == m_Plane) // XZ plane
  {
    for (size_t y = 0; y < dims[1]; ++y)
    {
      err = saveImage(y, dims[0], dims[2], dims);
      if (-1 == err)
      {
        return;
      }
    }
  }
  else if (2 == m_Plane) // YZ plane
  {
    for (size_t x = 0; x < dims[0]; ++x)
    {
      err = saveImage(x, dims[1], dims[2], dims);
      if (-1 == err)
      {
        return;
      }
    }
  }

  notifyStatusMessage(getHumanLabel(), "Complete");
}
Esempio n. 30
0
void EditorWindow::createActions()
{
	openAct = new QAction(tr("&Open"), this);
	openAct->setShortcut(QKeySequence::Open);
	connect(openAct, SIGNAL(triggered()), this, SLOT(openImage()));

	saveAct = new QAction(tr("&Save"), this);
	saveAct->setShortcut(QKeySequence::Save);
	connect(saveAct, SIGNAL(triggered()), this, SLOT(saveImage()));

	saveAsAct = new QAction(tr("Save As"), this);
	saveAsAct->setShortcut(QKeySequence::SaveAs);
	connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveImageAs()));

	quitAct = new QAction(tr("Quit"), this);
	quitAct->setShortcut(QKeySequence::Quit);
	connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));

	zoomInAct = new QAction(tr("Zoom In"), this);
	zoomInAct->setShortcut(QKeySequence::ZoomIn);
	connect(zoomInAct, SIGNAL(triggered()), imageWidget, SLOT(zoomIn()));

	zoomOutAct = new QAction(tr("Zoom Out"), this);
	zoomOutAct->setShortcut(QKeySequence::ZoomOut);
	connect(zoomOutAct, SIGNAL(triggered()), imageWidget, SLOT(zoomOut()));
	connect(imageWidget, SIGNAL(zoomOutAvailableChanged(bool)), zoomOutAct, SLOT(setEnabled(bool)));

	zoomOriginalAct = new QAction(tr("Actual Size"), this);
	connect(zoomOriginalAct, SIGNAL(triggered()), imageWidget, SLOT(zoomOriginal()));

	zoomByWheelAct = new QAction(tr("Zoom by Mouse Wheel"), this);
	zoomByWheelAct->setCheckable(true);
	zoomByWheelAct->setChecked(false);
	connect(zoomByWheelAct, SIGNAL(toggled(bool)), imageWidget, SLOT(setWheelZoom(bool)));

	autoContrastAct = new QAction(tr("Auto Contrast"), this);
	autoContrastAct->setToolTip(tr("Apply luminance histogram stretching"));
	connect(autoContrastAct, SIGNAL(triggered()), this, SLOT(doAutoContrast()));

	autoLevelsAct = new QAction(tr("Auto Levels"), this);
	autoLevelsAct->setToolTip(tr("Apply channel-wise RGB histogram stretching"));
	connect(autoLevelsAct, SIGNAL(triggered()), this, SLOT(doAutoLevels()));

	whiteBalanceAct = new QAction(tr("Correct White Balance"), this);
	whiteBalanceAct->setToolTip(tr("Apply white balance correction using greyworld model"));
	connect(whiteBalanceAct, SIGNAL(triggered()), this, SLOT(doWhiteBalance()));

	geometryAct = new QAction(tr("Scale/Rotate"), this);
	geometryAct->setToolTip(tr("Scale and rotate image relative to the center"));
	connect(geometryAct, SIGNAL(triggered()), this, SLOT(doGeometryTransform()));

	filterAct = new QAction(tr("Filters && Effects"), this);
	filterAct->setToolTip(tr("Open filtration dialog"));
	connect(filterAct, SIGNAL(triggered()), this, SLOT(doFilter()));

	convolutionAct = new QAction(tr("Convolution"), this);
	convolutionAct->setToolTip(tr("Apply convolution with arbitrary kernel"));
	connect(convolutionAct, SIGNAL(triggered()), this, SLOT(doConvolution()));
}