コード例 #1
0
  void showHistogram(std::string& name, const cv::Mat& img, float binsize, float min, float max)
  {
    if(shutdown_ || !checkImageSize(name, img)) return;

    CreateHistogramFunc f(this, name, img, binsize, min, max);

    histogram_queue_.push_front(f);
  }
コード例 #2
0
ファイル: romselection.cpp プロジェクト: MaxLeiter/CEmu
void RomSelection::nextPageOne() {
    if (ui->radioBrowse->isChecked()) {
        if (checkImageSize(ui->rompath->text().toLatin1()) == false) {
            QMessageBox::critical(this, tr("Invalid ROM image"), tr("You have selected an invalid ROM image."));
            return;
        }
        romImagePath = ui->rompath->text().toLatin1().toStdString();
        close();
    } else {
        ui->stackedWidget->setCurrentIndex(ui->stackedWidget->currentIndex()+1);
    }
}
コード例 #3
0
err_t JpegDecoder::readImage(Image& image)
{
  JpegLibrary& jpeg = reinterpret_cast<JpegCodecProvider*>(_provider)->_jpegLibrary;
  FOG_ASSERT(jpeg.err == ERR_OK);

  err_t err = ERR_OK;

  struct jpeg_decompress_struct cinfo;
  MyJpegSourceMgr srcmgr;
  MyJpegErrorMgr jerr;
  JSAMPROW rowptr[1];

  uint32_t format = IMAGE_FORMAT_RGB24;
  int bpp = 3;

  // Create a decompression structure and load the header.
  cinfo.err = jpeg.std_error(&jerr.errmgr);
  jerr.errmgr.error_exit = MyJpegErrorExit;
  jerr.errmgr.output_message = MyJpegMessage;

  if (setjmp(jerr.escape))
  {
    // Error condition.
    jpeg.destroy_decompress(&cinfo);
    return ERR_IMAGE_LIBJPEG_ERROR;
  }

  jpeg.create_decompress(&cinfo, JPEG_LIB_VERSION, sizeof(struct jpeg_decompress_struct));

  cinfo.src = (struct jpeg_source_mgr *)&srcmgr;
  srcmgr.pub.init_source = MyJpegInitSource;
  srcmgr.pub.fill_input_buffer = MyJpegFillInputBuffer;
  srcmgr.pub.skip_input_data = MyJpegSkipInputData;
  srcmgr.pub.resync_to_restart = jpeg.resync_to_restart;
  srcmgr.pub.term_source = MyJpegTermSource;
  srcmgr.pub.next_input_byte = srcmgr.buffer;
  srcmgr.pub.bytes_in_buffer = 0;
  srcmgr.stream = &_stream;

  jpeg.read_header(&cinfo, true);
  jpeg.calc_output_dimensions(&cinfo);

  _size.w = cinfo.output_width;
  _size.h = cinfo.output_height;
  _planes = 1;
  _actualFrame = 0;
  _framesCount = 1;

  // Check whether the image size is valid.
  if (!checkImageSize())
  {
    err = ERR_IMAGE_INVALID_SIZE;
    goto _End;
  }

  jpeg.start_decompress(&cinfo);

  // Set 8 or 24-bit output.
  if (cinfo.out_color_space == JCS_GRAYSCALE)
  {
    if (cinfo.output_components != 1)
    {
      err = ERR_IMAGEIO_UNSUPPORTED_FORMAT;
      goto _End;
    }

    format = IMAGE_FORMAT_I8;
    bpp = 1;
  }
  else if (cinfo.out_color_space == JCS_RGB)
  {
    if (cinfo.output_components != 3)
    {
      err = ERR_IMAGEIO_UNSUPPORTED_FORMAT;
      goto _End;
    }
  }
  else
  {
    cinfo.out_color_space = JCS_RGB;
    cinfo.quantize_colors = false;
  }

  // Create the image.
  if (FOG_IS_ERROR(err = image.create(_size, format))) goto _End;

  if (format == IMAGE_FORMAT_I8)
  {
    image.setPalette(ImagePalette::fromGreyscale(256));

    uint8_t* pixels = image.getFirstX();
    ssize_t stride = image.getStride();

    while (cinfo.output_scanline < cinfo.output_height)
    {
      rowptr[0] = (JSAMPROW)(pixels + (ssize_t)cinfo.output_scanline * stride);
      jpeg.read_scanlines(&cinfo, rowptr, (JDIMENSION)1);

      if ((cinfo.output_scanline & 15) == 0)
        updateProgress(cinfo.output_scanline, cinfo.output_height);
    }
  }
  else
  {
    ImageConverter converter;
    err = converter.create(
      ImageFormatDescription::getByFormat(format),
      ImageFormatDescription::fromArgb(24, IMAGE_FD_NONE, 0,
        FOG_JPEG_RGB24_RMASK,
        FOG_JPEG_RGB24_GMASK,
        FOG_JPEG_RGB24_BMASK));
    if (FOG_IS_ERROR(err)) goto _End;

    ImageConverterClosure closure;
    converter.setupClosure(&closure, PointI(0, 0));

    uint8_t* pixels = image.getFirstX();
    ssize_t stride = image.getStride();

    while (cinfo.output_scanline < cinfo.output_height)
    {
      rowptr[0] = (JSAMPROW)(pixels + (ssize_t)cinfo.output_scanline * stride);
      jpeg.read_scanlines(&cinfo, rowptr, (JDIMENSION)1);

      if (!converter.isCopy())
        converter.getBlitFn()((uint8_t*)rowptr[0], (uint8_t*)rowptr[0], _size.w, &closure);

      if ((cinfo.output_scanline & 15) == 0)
        updateProgress(cinfo.output_scanline, cinfo.output_height);

      closure.ditherOrigin.y++;
    }
  }

  jpeg.finish_decompress(&cinfo);

_End:
  jpeg.destroy_decompress(&cinfo);
  image._modified();

  return err;
}
コード例 #4
0
err_t JpegDecoder::readHeader()
{
  JpegLibrary& jpeg = reinterpret_cast<JpegCodecProvider*>(_provider)->_jpegLibrary;
  FOG_ASSERT(jpeg.err == ERR_OK);

  // Don't read header more than once.
  if (isHeaderDone()) return getHeaderResult();

  err_t err = ERR_OK;

  struct jpeg_decompress_struct cinfo;
  MyJpegSourceMgr srcmgr;
  MyJpegErrorMgr jerr;

  // create a decompression structure and load the header
  cinfo.err = jpeg.std_error(&jerr.errmgr);
  jerr.errmgr.error_exit = MyJpegErrorExit;
  jerr.errmgr.output_message = MyJpegMessage;

  if (setjmp(jerr.escape))
  {
    err = ERR_IMAGE_LIBJPEG_ERROR;
    goto _Fail;
  }

  jpeg.create_decompress(&cinfo, /* version */ 62, sizeof(struct jpeg_decompress_struct));

  cinfo.src = (struct jpeg_source_mgr *)&srcmgr;
  srcmgr.pub.init_source = MyJpegInitSource;
  srcmgr.pub.fill_input_buffer = MyJpegFillInputBuffer;
  srcmgr.pub.skip_input_data = MyJpegSkipInputData;
  srcmgr.pub.resync_to_restart = jpeg.resync_to_restart;
  srcmgr.pub.term_source = MyJpegTermSource;
  srcmgr.pub.next_input_byte = srcmgr.buffer;
  srcmgr.pub.bytes_in_buffer = 0;
  srcmgr.stream = &_stream;

  jpeg.read_header(&cinfo, true);
  jpeg.calc_output_dimensions(&cinfo);

  _headerDone = true;
  _size.w = cinfo.output_width;
  _size.h = cinfo.output_height;
  _planes = 1;
  _actualFrame = 0;
  _framesCount = 1;

  switch (cinfo.out_color_space)
  {
    case JCS_GRAYSCALE:
      _depth = 8;
      break;
    default:
      _depth = 24;
      break;
  }

  // Check whether the image size is valid.
  if (!checkImageSize())
  {
    err = ERR_IMAGE_INVALID_SIZE;
    goto _Fail;
  }

_Fail:
  jpeg.destroy_decompress(&cinfo);
  return (_headerResult = err);
}
コード例 #5
0
  void show(std::string& name, const cv::MatExpr& img, Visualizer::ImageModifier modifier)
  {
    if(shutdown_ || !checkImageSize(name, img)) return;

    internalShow(name, img, modifier);
  }
コード例 #6
0
void LLFacebookPhotoPanel::updateResolution(BOOL do_update)
{
	LLComboBox* combobox = static_cast<LLComboBox *>(mResolutionComboBox);
	LLComboBox* filterbox = static_cast<LLComboBox *>(mFilterComboBox);

	std::string sdstring = combobox->getSelectedValue();
	LLSD sdres;
	std::stringstream sstream(sdstring);
	LLSDSerialize::fromNotation(sdres, sstream, sdstring.size());

	S32 width = sdres[0];
	S32 height = sdres[1];

    // Note : index 0 of the filter drop down is assumed to be "No filter" in whichever locale
    std::string filter_name = (filterbox->getCurrentIndex() ? filterbox->getSimple() : "");

	LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get());
	if (previewp && combobox->getCurrentIndex() >= 0)
	{
		// <FS:Ansariel> FIRE-15112: Allow custom resolution for SLShare; moved up
		checkAspectRatio(width);

		S32 original_width = 0 , original_height = 0 ;
		previewp->getSize(original_width, original_height) ;

		if (width == 0 || height == 0)
		{
			// take resolution from current window size
			LL_DEBUGS() << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL;
			previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw());
		}
		// <FS:Ansariel> FIRE-15112: Allow custom resolution for SLShare
		else if (width == -1 || height == -1)
		{
			// take resolution from custom size
			LLSpinCtrl* width_spinner = getChild<LLSpinCtrl>("custom_snapshot_width");
			LLSpinCtrl* height_spinner = getChild<LLSpinCtrl>("custom_snapshot_height");
			S32 custom_width = width_spinner->getValue().asInteger();
			S32 custom_height = height_spinner->getValue().asInteger();
			if (checkImageSize(previewp, custom_width, custom_height, TRUE, previewp->getMaxImageSize()))
			{
				width_spinner->set(custom_width);
				height_spinner->set(custom_height);
			}
			LL_DEBUGS() << "Setting preview res from custom: " << custom_width << "x" << custom_height << LL_ENDL;
			previewp->setSize(custom_width, custom_height);
		}
		// </FS:Ansariel>
		else
		{
			// use the resolution from the selected pre-canned drop-down choice
			LL_DEBUGS() << "Setting preview res selected from combo: " << width << "x" << height << LL_ENDL;
			previewp->setSize(width, height);
		}

		// <FS:Ansariel> FIRE-15112: Allow custom resolution for SLShare; moved up
		//checkAspectRatio(width);

		previewp->getSize(width, height);
        
        // Recompute quality setting
        mQuality = compute_jpeg_quality(width, height);
        previewp->setSnapshotQuality(mQuality, false);
		
		if (original_width != width || original_height != height)
		{
			previewp->setSize(width, height);
			if (do_update)
			{
                previewp->updateSnapshot(TRUE);
				updateControls();
			}
		}
        // Get the old filter, compare to the current one "filter_name" and set if changed
        std::string original_filter = previewp->getFilter();
		if (original_filter != filter_name)
		{
            previewp->setFilter(filter_name);
			if (do_update)
			{
                previewp->updateSnapshot(FALSE, TRUE);
				updateControls();
			}
		}
	}

	// <FS:Ansariel> FIRE-15112: Allow custom resolution for SLShare
	BOOL custom_resolution = static_cast<LLComboBox *>(mResolutionComboBox)->getSelectedValue().asString() == "[i-1,i-1]";
	getChild<LLSpinCtrl>("custom_snapshot_width")->setEnabled(custom_resolution);
	getChild<LLSpinCtrl>("custom_snapshot_height")->setEnabled(custom_resolution);
	getChild<LLCheckBoxCtrl>("keep_aspect_ratio")->setEnabled(custom_resolution);
	// </FS:Ansariel>
}
コード例 #7
0
GVSpectrogramWDialogSettings::GVSpectrogramWDialogSettings(GVSpectrogram *parent)
    : QDialog((QWidget*)parent)
    , m_lastimgsize(-1)
    , ui(new Ui::GVSpectrogramWDialogSettings)
{
    ui->setupUi(this);

    m_spectrogram = parent;

    gMW->m_settings.add(ui->cbSpectrogramWindowSizeForcedOdd);
    gMW->m_settings.add(ui->cbSpectrogramWindowType);
    gMW->m_settings.add(ui->spSpectrogramWindowNormPower);
    gMW->m_settings.add(ui->spSpectrogramWindowNormSigma);
    gMW->m_settings.add(ui->spSpectrogramWindowExpDecay);
    ui->lblWindowNormSigma->hide();
    ui->spSpectrogramWindowNormSigma->hide();
    ui->lblWindowNormPower->hide();
    ui->spSpectrogramWindowNormPower->hide();
    ui->lblWindowExpDecay->hide();
    ui->spSpectrogramWindowExpDecay->hide();
    gMW->m_settings.add(ui->sbSpectrogramStepSize);
    gMW->m_settings.add(ui->sbSpectrogramWindowSize);
    gMW->m_settings.add(ui->sbSpectrogramDFTSize);
    gMW->m_settings.add(ui->sbSpectrogramOversamplingFactor);
    gMW->m_settings.add(ui->cbSpectrogramDFTSizeType);
    if(ui->cbSpectrogramDFTSizeType->currentIndex()==0){
        ui->sbSpectrogramOversamplingFactor->hide();
        ui->sbSpectrogramDFTSize->show();
        DFTSizeChanged(ui->sbSpectrogramDFTSize->value());
    }
    else if(ui->cbSpectrogramDFTSizeType->currentIndex()==1){
        ui->sbSpectrogramOversamplingFactor->show();
        ui->sbSpectrogramDFTSize->hide();
        DFTSizeChanged(ui->sbSpectrogramOversamplingFactor->value());
    }
    connect(ui->cbSpectrogramDFTSizeType, SIGNAL(currentIndexChanged(int)), this, SLOT(DFTSizeTypeChanged(int)));
    connect(ui->sbSpectrogramDFTSize, SIGNAL(valueChanged(int)), this, SLOT(DFTSizeChanged(int)));
    connect(ui->sbSpectrogramOversamplingFactor, SIGNAL(valueChanged(int)), this, SLOT(DFTSizeChanged(int)));
    gMW->m_settings.add(ui->cbSpectrogramTransform);

    gMW->m_settings.add(ui->gbSpectrogramCepstralLiftering);
    gMW->m_settings.add(ui->sbSpectrogramCepstralLifteringOrder);
    gMW->m_settings.add(ui->cbSpectrogramCepstralLifteringPreserveDC);
    QStringList colormaps = QAEColorMap::getAvailableColorMaps();
    for(QStringList::Iterator it=colormaps.begin(); it!=colormaps.end(); ++it)
        ui->cbSpectrogramColorMaps->addItem(*it);
    ui->cbSpectrogramColorMaps->setCurrentIndex(1);
    gMW->m_settings.add(ui->cbSpectrogramColorMaps);
    gMW->m_settings.add(ui->cbSpectrogramColorMapReversed);
    gMW->m_settings.add(ui->cbSpectrogramLoudnessWeighting);

    gMW->m_settings.add(ui->cbSpectrogramColorRangeMode);
    colorRangeModeCurrentIndexChanged(ui->cbSpectrogramColorRangeMode->currentIndex());
    gMW->m_qxtSpectrogramSpanSlider->setLowerValue(gMW->m_settings.value("m_qxtSpectrogramSpanSlider_lower", gMW->m_qxtSpectrogramSpanSlider->lowerValue()).toInt());
    gMW->m_qxtSpectrogramSpanSlider->setUpperValue(gMW->m_settings.value("m_qxtSpectrogramSpanSlider_upper", gMW->m_qxtSpectrogramSpanSlider->upperValue()).toInt());

    checkImageSize();
    adjustSize();

    connect(ui->cbSpectrogramWindowType, SIGNAL(currentIndexChanged(QString)), this, SLOT(windowTypeCurrentIndexChanged(QString)));
    connect(ui->cbSpectrogramColorRangeMode, SIGNAL(currentIndexChanged(int)), this, SLOT(colorRangeModeCurrentIndexChanged(int)));
}