Esempio n. 1
0
void Preprocessor::writeClipToOutputImage (const std::string& outputFile, const double& scalingFactor) const
{
	// Create a new Image object
	Magick::Image outputImage = Magick::Image(Magick::Geometry(clipWidth_, clipHeight_), Magick::ColorGray(1.0));
	outputImage.type( Magick::GrayscaleType );

	// Create a view over the image
	Magick::Pixels imageView(outputImage);
	Magick::PixelPacket *originPixel = imageView.get(0, 0, clipWidth_, clipHeight_);
	Magick::PixelPacket *pixel;

	// Assign values to the image pixels
	for ( unsigned int i = 0; i < imageView.rows(); ++i )
	{
		for ( unsigned int j = 0; j < imageView.columns(); ++j )
		{
			pixel = originPixel + (i * imageView.columns()) + j;

			*pixel = Magick::ColorGray ( static_cast<double>(clip_.at(i * clipWidth_ + j)) / scalingFactor );
		}
	}

	// Synchronize and write changes to disc
	imageView.sync();
	outputImage.syncPixels();
	outputImage.write(outputFile);
}
Esempio n. 2
0
Dali::Toolkit::ImageView ImageView::New()
{
  // Create the implementation
  ImageViewPtr imageView(new ImageView());

  // Pass ownership to CustomActor via derived handle
  Dali::Toolkit::ImageView handle(*imageView);

  // Second-phase init of the implementation
  // This can only be done after the CustomActor connection has been made...
  imageView->Initialize();

  return handle;
}
bool SDLSurface::renderToSurface(RGBVideoSample& videoSample) {
  if (!videoSample) {
    return false;
  }
  if (!isInitialized()) {
    return false;
  }
#ifdef DEBUG
  std::cout << "SDLSurface::renderToSurface" << std::endl;
#endif
  SDLSurfaceLock surfaceLock(m_pSurface);
  if (!surfaceLock) {
    return false;
  }
  RGBVideoFormat videoFormat(videoSample.sampleFormat());
  if (videoFormat.sizePixels() != sizePixels()) {
    return false;
  }
  if (videoFormat.bitsPerPixel() != bitsPerPixel()) {
    return false;
  }
  if (videoFormat.sizeRowBytes() != sizeRowBytes()) {
    return false;
  }
  if (videoFormat.sizeBytes() != sizeBytes()) {
    return false;
  }
  if (videoFormat.rgbFormat() != rgbFormat()) {
    return false;
  }
  RGBVideoFrameSharedPtr pVideoFrame(videoSample.sampleData());
  ImageViewType imageView(pVideoFrame->imageView());
  switch (rgbFormat()) {
    case RGB888:
      renderImageToSurface<rgb8_view_t, rgb8_ptr_t>(imageView);
      break;
    case RGBA8888:
      renderImageToSurface<rgba8_view_t, rgba8_ptr_t>(imageView);
      break;
    case BGR888:
      renderImageToSurface<bgr8_view_t, bgr8_ptr_t>(imageView);
      break;
    case ABGR8888:
      renderImageToSurface<abgr8_view_t, abgr8_ptr_t>(imageView);
      break;
    default:
      return false;
  }
  return true;
}
Esempio n. 4
0
Preprocessor::Preprocessor (const Magick::Image& page, const unsigned int& x, const unsigned int& y, const unsigned int& height, const unsigned int& width)
:	clip_(0),
	clipHeight_(height),
	clipWidth_(width),
	statistics_(),
	regions_(0),
	delimiters_(0),
	inlineRegions_(),
	patterns_(0),
	averageCharacterHeight_(0.0),
	averageCharacterWidth_(0.0),
	averageSpaceBetweenCharacters_(0.0)
{
	if ( (height == 0) && (width == 0) )
		throw NessieException ("Preprocessor::Preprocessor() : Constructor has 0 size.");

	if ( width > page.columns() )
		throw NessieException ("Preprocessor::Preprocessor() : The press clip's width cannot be wider than the underlying page's.");

	if ( height > page.rows() )
		throw NessieException ("Preprocessor::Preprocessor() : The press clip's height cannot be higher than the underlying page's.");

	if ( x >= page.rows() || y >= page.columns() )
		throw NessieException ("Preprocessor::Preprocessor() : The press clip's top leftmost pixel falls outside the page.");

	if( (x + height) > page.rows() || (y + width) > page.columns() )
		throw NessieException ("Preprocessor::Preprocessor() : The clip does not fall completely within the underlying page.");

	// Create a view over the input image
	Magick::Pixels imageView(const_cast<Magick::Image&>(page));
	Magick::PixelPacket *pixels = imageView.get(x, y, clipWidth_, clipHeight_);

	// Traverse the view to get the pixel values
	Magick::ColorGray grayLevel;
	for ( unsigned int i = 0; i < clipHeight_; ++i )
	{
		for ( unsigned int j = 0; j < clipWidth_; ++j )
		{
			grayLevel = *pixels++;
			clip_.push_back( static_cast<unsigned char>(round(grayLevel.shade() * 255.0)) );
		}
	}

	statistics_.clipSize(clip_.size());
}
Esempio n. 5
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    db1.openDB();
    db1.createSlamBookTable();

    QObject::connect(ui->pushButton_3,SIGNAL(clicked()),this,SLOT(close())); //Quit using a button
    QObject::connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(close())); //Quit in File menu

    // ui->lineEdit_1  Name on tab personal
    // ui->lineEdit_2  Nick on tab personal
    // ui->lineEdit_3  Mobile on tab personal
    // ui->lineEdit_4  Home on tab personal
    // ui->lineEdit_5  email on tab personal
    // ui->lineEdit_6  Website on tab personal
    // ui->tectEdit_1  Address

    //Button Clear_i is present in every tab, listening to shortcut Alt+c to reset all fields in that tab
    QObject::connect(ui->Clear_1,SIGNAL(clicked()),this->ui->lineEdit_1,SLOT(clear()));
    QObject::connect(ui->Clear_1,SIGNAL(clicked()),this->ui->lineEdit_2,SLOT(clear()));
    QObject::connect(ui->Clear_1,SIGNAL(clicked()),this->ui->lineEdit_3,SLOT(clear()));
    QObject::connect(ui->Clear_1,SIGNAL(clicked()),this->ui->lineEdit_4,SLOT(clear()));
    QObject::connect(ui->Clear_1,SIGNAL(clicked()),this->ui->lineEdit_5,SLOT(clear()));
    QObject::connect(ui->Clear_1,SIGNAL(clicked()),this->ui->lineEdit_6,SLOT(clear()));

    QObject::connect(ui->Clear_1,SIGNAL(clicked()),this->ui->textEdit_1,SLOT(clear()));

    // tab introspection
    // textEdit_2 = Hobbies, textEdit_3 = love,god,romance, textEdit_4 = Memorable day, textEdit_5 = dark secret
    // ui->Clear_2 is a hidden button responding to Alt+c
    QObject::connect(ui->Clear_2,SIGNAL(clicked()),this->ui->textEdit_2,SLOT(clear()));
    QObject::connect(ui->Clear_2,SIGNAL(clicked()),this->ui->textEdit_3,SLOT(clear()));
    QObject::connect(ui->Clear_2,SIGNAL(clicked()),this->ui->textEdit_4,SLOT(clear()));
    QObject::connect(ui->Clear_2,SIGNAL(clicked()),this->ui->textEdit_5,SLOT(clear()));

    // tab Activities
    // textEdit_6 = Movies, textEdit_7 = Song,god,romance, textEdit_8 = Books, textEdit_9 = delicasies
    // ui->Clear_3 is a hidden button responding to Alt+c
    QObject::connect(ui->Clear_3,SIGNAL(clicked()),this->ui->textEdit_6,SLOT(clear()));
    QObject::connect(ui->Clear_3,SIGNAL(clicked()),this->ui->textEdit_7,SLOT(clear()));
    QObject::connect(ui->Clear_3,SIGNAL(clicked()),this->ui->textEdit_8,SLOT(clear()));
    QObject::connect(ui->Clear_3,SIGNAL(clicked()),this->ui->textEdit_9,SLOT(clear()));

    // tab About me
    // textEdit_10 = abt me, textEdit_11 = memorable moments, textEdit_12 = hated for, textEdit_13 = dark secret
    // ui->Clear_2 is a hidden button responding to Alt+cQObject::connect(ui->Clear_4,SIGNAL(clicked()),this->ui->textEdit_10,SLOT(clear()));
    QObject::connect(ui->Clear_4,SIGNAL(clicked()),this->ui->textEdit_11,SLOT(clear()));
    QObject::connect(ui->Clear_4,SIGNAL(clicked()),this->ui->textEdit_12,SLOT(clear()));
    QObject::connect(ui->Clear_4,SIGNAL(clicked()),this->ui->textEdit_13,SLOT(clear()));

    QObject::connect(ui->Clear_5,SIGNAL(clicked()),ui->lineEdit_7,SLOT(clear()));
    QObject::connect(ui->Clear_5,SIGNAL(clicked()),ui->pushButton_4,SLOT(click()));


    //pushButton_2 is connects to above Clear_i buttons of every tab
    QObject::connect(ui->pushButton_2,SIGNAL(clicked()),this->ui->Clear_1,SLOT(click()));
    QObject::connect(ui->pushButton_2,SIGNAL(clicked()),this->ui->Clear_2,SLOT(click()));
    QObject::connect(ui->pushButton_2,SIGNAL(clicked()),this->ui->Clear_3,SLOT(click()));
    QObject::connect(ui->pushButton_2,SIGNAL(clicked()),this->ui->Clear_4,SLOT(click()));

    //linking "Submit button" to SLOT Accept()
    QObject::connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(Accept()));

    //Calling imageviewer
    QObject::connect(ui->pushButton_4,SIGNAL(clicked()),this,SLOT(imageView()));
    QObject::connect(ui->pushButton,SIGNAL(clicked()),ui->pushButton_4,SLOT(click()));
    QObject::connect(ui->lineEdit_7,SIGNAL(returnPressed()),ui->pushButton_4,SLOT(click()));

    QObject::connect(ui->lineEdit_1,SIGNAL(returnPressed()),this,SLOT(Accept()));  //done for quick testing of o/p, remove it
    QObject::connect(ui->lineEdit_1,SIGNAL(textChanged(QString)),ui->lineEdit_1,SLOT(setWindowTitle(QString)));

}