void MainWindow::on_action_Open_thermogram_activated()
{
    QString path = QFileDialog::getOpenFileName(ui->centralWidget,tr("Select thermogram..."),"",tr("Temperature Matrix (*.txt);;Radiometric jpg (*.jpg)"));
     if( !path.isEmpty() ){
         QImage img;
         img.load(path);
         QPixmap pix = QPixmap::fromImage(img);
         QSize size = ui->screen->size();
         ui->screen->setPixmap(pix.scaled(size,Qt::KeepAspectRatio));
     }
}
QImage CAD_electrical_busbarwithtapoffpoints2row::wizardImage()
{
    QImage image;
    QFileInfo fileinfo(__FILE__);
    QString imageFileName = fileinfo.baseName();
    imageFileName.prepend(":/itemGraphic/");
    imageFileName.append(".png");
    image.load(imageFileName, "PNG");

    return image;
}
void LoadImage::on_pushButton_loadimg_clicked()
{
    QString fileName = QFileDialog::getOpenFileName( 0, QString(), IMAGE_DIR,
                                                     tr("Images (*.png *.jpg)") );
    QImage image;
    if ( !image.load(fileName) ) {
        ui->image_label->setText( tr("Selected file is not an image, please select another.") );
        return;
    }
    ui->image_label->setPixmap( QPixmap::fromImage(image) );
}
Beispiel #4
0
void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextFragment &fragment) const
{
    writer.writeStartElement(drawNS, QString::fromLatin1("frame"));
    if (m_strategy == 0) {
        // don't do anything.
    }
    else if (fragment.charFormat().isImageFormat()) {
        QTextImageFormat imageFormat = fragment.charFormat().toImageFormat();
        writer.writeAttribute(drawNS, QString::fromLatin1("name"), imageFormat.name());

        // vvv  Copy pasted mostly from Qt =================
        QImage image;
        QString name = imageFormat.name();
        if (name.startsWith(QLatin1String(":/"))) // auto-detect resources
            name.prepend(QLatin1String("qrc"));
        QUrl url = QUrl::fromEncoded(name.toUtf8());
        const QVariant data = m_document->resource(QTextDocument::ImageResource, url);
        if (data.type() == QVariant::Image) {
            image = qvariant_cast<QImage>(data);
        } else if (data.type() == QVariant::ByteArray) {
            image.loadFromData(data.toByteArray());
        }

        if (image.isNull()) {
            QString context;
           
            if (image.isNull()) { // try direct loading
                name = imageFormat.name(); // remove qrc:/ prefix again
                image.load(name);
            }
        }

        // ^^^ Copy pasted mostly from Qt =================
        if (! image.isNull()) {
            QBuffer imageBytes;
            QImageWriter imageWriter(&imageBytes, "png");
            imageWriter.write(image);
            QString filename = m_strategy->createUniqueImageName();
            m_strategy->addFile(filename, QString::fromLatin1("image/png"), imageBytes.data());

            // get the width/height from the format.
            qreal width = (imageFormat.hasProperty(QTextFormat::ImageWidth)) ? imageFormat.width() : image.width();
            writer.writeAttribute(svgNS, QString::fromLatin1("width"), pixelToPoint(width));
            qreal height = (imageFormat.hasProperty(QTextFormat::ImageHeight)) ? imageFormat.height() : image.height();
            writer.writeAttribute(svgNS, QString::fromLatin1("height"), pixelToPoint(height));

            writer.writeStartElement(drawNS, QString::fromLatin1("image"));
            writer.writeAttribute(xlinkNS, QString::fromLatin1("href"), filename);
            writer.writeEndElement(); // image
        }
    }

    writer.writeEndElement(); // frame
}
bool MeshViewerWidgetT<M>::open_texture( const char *_filename )
{
   QImage texsrc;
   QString fname = _filename;

   if (texsrc.load( fname ))
   {      
     return set_texture( texsrc );
   }
   return false;
}
Beispiel #6
0
//loads image from fileName (holding full path) if fileName != ""
void MainWindow::readImage(QString fileName, QImage &image)
{
    QFile file(fileName);
    if(!file.open(QFile::ReadOnly))
    {
        QMessageBox::information(this, tr("Unable to open file"), file.errorString());
        return;
    }
    image.load(fileName);
    file.close();
}
QImage CAD_Sanitary_ElectricWaterHeater::wizardImage()
{
    QImage image;
    QFileInfo fileinfo(__FILE__);
    QString imageFileName = fileinfo.baseName();
    imageFileName.prepend(":/itemGraphic/");
    imageFileName.append(".png");
    image.load(imageFileName, "PNG");
                       
    return image;
}
Beispiel #8
0
QRcodeImage::QRcodeImage(QString FilePathName)
{
	DECIMAL_POINT=21;

	//ÔØÈëͼƬ
	QImage image;
	image.load(FilePathName);
	m_EncodeImage = image.convertToFormat(QImage::Format_RGB32);
	m_Width = m_EncodeImage.width();
	m_Height = m_EncodeImage.height();
}
QImage CAD_sprinkler_compressedAirWaterContainer::wizardImage()
{
    QImage image;
    QFileInfo fileinfo(__FILE__);
    QString imageFileName = fileinfo.baseName();
    imageFileName.prepend(":/itemGraphic/");
    imageFileName.append(".png");
    image.load(imageFileName, "PNG");

    return image;
}
QImage CAD_Cleanroom_CeilingSuspension::wizardImage()
{
    QImage image;
    QFileInfo fileinfo(__FILE__);
    QString imageFileName = fileinfo.baseName();
    imageFileName.prepend(":/itemGraphic/");
    imageFileName.append(".png");      
    image.load(imageFileName, "PNG");
                       
    return image;
}
Beispiel #11
0
bool Reader::Read_ICL_NUIM_depth(QImage & depth, const int number, const QString & directory,
                                 const QString &fname, const QString &format, const int digits)
{
    QString impos;
    ImageName(impos, number, digits, directory, fname, format);
    QString dp = impos;
    int dot = dp.lastIndexOf('.');
    if (dot != -1) dp.truncate(dot);
    dp += ".depth";
    return depth.load(dp);
}
Beispiel #12
0
MyItem::MyItem()
{

	QImage *image = new QImage();
	if (image->load(g_filedst))
	{
		height = image->height();
		width = image->width();
	}
		
}
Beispiel #13
0
int Logic::getImageWidth(const QString &pathToImage) const
{
    QFile file(pathToImage);
    if (file.exists()) {
        QImage img;
        img.load(pathToImage);
        file.close();
        return img.width();
    }
    return 0;
}
QImage CAD_Cleanroom_ControlEmergencySwitch::wizardImage()
{
    QImage image;
    QFileInfo fileinfo(__FILE__);
    QString imageFileName = fileinfo.baseName();
    imageFileName.prepend(":/itemGraphic/");
    imageFileName.append(".png");   
    image.load(imageFileName, "PNG");
                       
    return image;
}
QImage ImageManager::getLastTexture() {
    QImage texture;
    if (texture_locations.size() == 0) {
        texture = QImage(800, 600, QImage::Format_RGB32);
        return texture;
    }
    if (texture.load(texture_locations.last()))return texture;
    texture = QImage(800, 600, QImage::Format_RGB32);
    cerr << "Unable to load texture" << texture_locations.last().toStdString().c_str() << endl;
    return texture;
}
QImage CAD_Electrical_CabinetWithoutDoor::wizardImage()
{
    QImage image;
    QFileInfo fileinfo(__FILE__);
    QString imageFileName = fileinfo.baseName();
    imageFileName.prepend(":/itemGraphic/");
    imageFileName.append(".png");   
    image.load(imageFileName, "PNG");
                       
    return image;
}
QImage ImageManager::getLastImage() {
    QImage image;
    if (image_locations.size() == 0) {
        image = QImage(800, 600, QImage::Format_RGB32);
        return image;
    }
    if (image.load(image_locations.last()))return image;
    image = QImage(800, 600, QImage::Format_RGB32);
    cerr << "Unable to load image" << image_locations.last().toStdString().c_str() << endl;
    return image;
}
/**
 * \fn BB_DocComponent::keyBoardEdit( QWidget* parent )
 */
int BB_Level::keyBoardEdit( QWidget* parent )
{
	QImage image;
	
	int result;
	bool exit = false;

	BB_DlgLevelEdit dlg(parent);
	
	dlg.setName(getName());
	dlg.setDescription(getDescription());
	
	QString planFile(m_FilePath.path() + QDir::separator() + m_MapFileName);
	dlg.setPlanFile( planFile );
	
	do
	{
	
		result = dlg.exec();
		/* Falls Abbrechen gedrückt wurde: raus. */
		if(result == QDialog::Rejected)
		{
			return false;
		}
		
		if(dlg.getName().isEmpty())
		{
			QMessageBox::critical(NULL,"Fehler",QString::fromUtf8("Sie müssen einen Namen für das Gelände angeben."));
		}
		else if(!image.load(dlg.getPlanFile()))
		{
			QMessageBox::critical(NULL,"Fehler",QString::fromUtf8("Sie müssen eine gültige Bilddatei als Plan angeben."));
		}
		else
		{
			/* Falls alles gut ist */
			exit = 1;
		}
			
	} while(result != QDialog::Rejected && !exit);
	
	setName(dlg.getName());
	setDescription(dlg.getDescription());
	
	m_MapFileName.sprintf("%08d.png",getObjectNr());
	
	image.save(m_FilePath.path() + QDir::separator() + m_MapFileName,"PNG");
	
	setMap(QPixmap::fromImage(image));
	
	parent->update();
	getListWidgetItem()->setText(getName());
	return result;
}
QImage CAD_air_ductTransitionRectRound::wizardImage()
{
    QImage image;
    QFileInfo fileinfo(__FILE__);
    QString imageFileName = fileinfo.baseName();
    imageFileName.prepend(":/itemGraphic/");
    imageFileName.append(".png");
    image.load(imageFileName, "PNG");

    return image;
}
Beispiel #20
0
void PaintCanvas::drawBackgroundImage()
{
	initBGImage();


 	QImage img;
 	img.load("G:/Projects/STOP MOTION/Produce-stop-motion/key-pairs/bg");

	// 1E-3 needed. Just try with width=128 and see !
	int newWidth  = 1<<(int)(1+log(img.width() -1+1E-3) / log(2.0));
	int newHeight = 1<<(int)(1+log(img.height()-1+1E-3) / log(2.0));

	u_max = img.width()  / (float)newWidth;
	v_max = img.height() / (float)newHeight;

	if ((img.width()!=newWidth) || (img.height()!=newHeight))
	{
		//qWarning("Image size set to %dx%d pixels", newWidth, newHeight);
		img = img.copy(0, 0, newWidth, newHeight);
	}

	ratio = newWidth / float(newHeight);

	QImage glImg = QGLWidget::convertToGLFormat(img);  // flipped 32bit RGBA

	// Bind the img texture...
	glTexImage2D(GL_TEXTURE_2D, 0, 4, glImg.width(), glImg.height(), 0,
		GL_RGBA, GL_UNSIGNED_BYTE, glImg.bits());


	glDisable(GL_LIGHTING);
	glEnable(GL_TEXTURE_2D);
	glColor3f(1,1,1);

	startScreenCoordinatesSystem(true);

	// Draws the background quad
	glNormal3f(0.0, 0.0, 1.0);
	glBegin(GL_QUADS);
	glTexCoord2f(0.0,   1.0-v_max);	glVertex2i(0,0);
	glTexCoord2f(0.0,   1.0);		glVertex2i(0,height());
	glTexCoord2f(u_max, 1.0);		glVertex2i(width(),height());
	glTexCoord2f(u_max, 1.0-v_max);	glVertex2i(width(),0);
	glEnd();

	stopScreenCoordinatesSystem();

	// Depth clear is not absolutely needed. An other option would have been to draw the
	// QUAD with a 0.999 z value (z ranges in [0, 1[ with startScreenCoordinatesSystem()).
	glClear(GL_DEPTH_BUFFER_BIT);
	glDisable(GL_TEXTURE_2D);
	glEnable(GL_LIGHTING);

}
QImage CAD_Electrical_LuminaireRailMounted::wizardImage()
{
    QImage image;
    QFileInfo fileinfo(__FILE__);
    QString imageFileName = fileinfo.baseName();
    imageFileName.prepend(":/itemGraphic/");
    imageFileName.append(".png");       
    image.load(imageFileName, "PNG");
                       
    return image;
}
Beispiel #22
0
QImage CAD_basic_line::wizardImage()
{
    QImage image;
    QFileInfo fileinfo(__FILE__);
    QString imageFileName = fileinfo.baseName();
    imageFileName.prepend(":/itemGraphic/");
    imageFileName.append(".png");
    image.load(imageFileName, "PNG");

    return image;
}
bool Editor::importBitmapImage( QString filePath )
{
    backup( tr( "ImportImg" ) );
    qDebug(filePath.toLatin1().data());
    QImageReader reader( filePath );

    Q_ASSERT( layers()->currentLayer()->type() == Layer::BITMAP );
    auto layer = static_cast<LayerBitmap*>( layers()->currentLayer() );

    QImage img;//( reader.size(), QImage::Format_ARGB32_Premultiplied );
    img.load(filePath);
    while ( reader.read( &img ) )
    {/*
        if ( img.isNull() || reader.nextImageDelay() <= 0 )
        {
            qDebug("why not image");
            break;
        }*/

        if ( !layer->keyExists( currentFrame() ) )
        {
            qDebug("why not imagesadfsdaf ssd");
            addNewKey();
        }


        BitmapImage* bitmapImage = layer->getBitmapImageAtFrame( currentFrame() );

        QRect boundaries = img.rect();

        boundaries.moveTopLeft( mScribbleArea->getCentralPoint().toPoint() - QPoint( boundaries.width() / 2, boundaries.height() / 2 ) );
        BitmapImage* importedBitmapImage = new BitmapImage( boundaries, img );
        bitmapImage->paste( importedBitmapImage );

      if(layers()->currentLayerIndex()>2)
      {
        //下面用来框出倒入的图片
        mScribbleArea->mySelection.moveTopLeft(mScribbleArea->getCentralPoint().toPoint() - QPoint( boundaries.width()/1.5, boundaries.height()/1.5) );//这个是为了将值赋给QRectF
        mScribbleArea->mySelection.moveBottomRight(mScribbleArea->getCentralPoint().toPoint() + QPoint( boundaries.width()/1.5, boundaries.height()/1.5));
        mScribbleArea->mySelection.setTopLeft(mScribbleArea->getCentralPoint().toPoint() - QPoint( boundaries.width()/1.5, boundaries.height()/1.5));
        mScribbleArea->mySelection.setBottomRight(mScribbleArea->getCentralPoint().toPoint() + QPoint( boundaries.width()/1.5, boundaries.height()/1.5));
        //mScribbleArea->mySelection.moveBottomRight(QPoint( boundaries.width()/2, boundaries.height()/2));
        mScribbleArea->setSelection( mScribbleArea->mySelection, true );
        mScribbleArea->myTransformedSelection = mScribbleArea->mySelection.adjusted( 0, 0, 0, 0 );
        mScribbleArea->myTempTransformedSelection = mScribbleArea->mySelection.adjusted( 0, 0, 0, 0 );
        mScribbleArea->update();
        mScribbleArea->mIncludeImg[mLayerManager->currentLayerIndex()]=mScribbleArea->mySelection;
        tools()->setCurrentTool(MOVE);
       }
       // scrubTo( currentFrame() + 1 );
    }

    return true;
}
QImage CAD_Cleanroom_WallSmokeExtractFlap::wizardImage()
{
    QImage image;
    QFileInfo fileinfo(__FILE__);
    QString imageFileName = fileinfo.baseName();
    imageFileName.prepend(":/itemGraphic/");
    imageFileName.append(".png");   
    image.load(imageFileName, "PNG");
                       
    return image;
}
Beispiel #25
0
bool inputManager::getCurrentImage(QImage& image)
{
    bool retValue = false;
    if (image_list_.size() > 0 && cur_image_ < image_list_.size())
    {
        std::cout<<"image:"<<QString(input_path_ + image_list_[cur_image_]).toAscii().data()<<std::endl;
        image.load(input_path_ + image_list_[cur_image_]);
        scale(image);
        retValue =  true;
    }
    return retValue;
}
Beispiel #26
0
/**
 * Load a sketch image from a file, and display options order by their probabilities.
 * This is for test usage.
 */
void GLWidget3D::loadImage(const QString& filename) {
	QImage newImage;
	newImage.load(filename);
	newImage = newImage.scaled(width(), height());

	QPainter painter(&sketch);
	painter.drawImage(0, 0, newImage);

	predict();
	// predict function calls update(), so we do not need to call it twice.
	//update();
}
Beispiel #27
0
QString QgsRenderChecker::imageToHash( QString theImageFile )
{
  QImage myImage;
  myImage.load( theImageFile );
  QByteArray myByteArray;
  QBuffer myBuffer( &myByteArray );
  myImage.save( &myBuffer, "PNG" );
  QString myImageString = QString::fromUtf8( myByteArray.toBase64().data() );
  QCryptographicHash myHash( QCryptographicHash::Md5 );
  myHash.addData( myImageString.toUtf8() );
  return myHash.result().toHex().constData();
}
int QWpsDrawer::read_bmp_file(const char* filename,int *width, int *height) {
    QImage img;

    QFile file(filename);
    QFileInfo info(file);
    file.copy(mTmpWpsString+"/"+info.fileName());

    img.load(filename);
    *width = img.width();
    *height = img.height();
    return 1;
}
Beispiel #29
0
bool imageViewer::openImage(QByteArray *ba)
{
  QImage tempImage;
  QBuffer buffer(ba);
  buffer.open(QIODevice::ReadOnly);
  if(tempImage.load(&buffer,NULL))
  {
    return  openImage(tempImage.convertToFormat(QImage::Format_ARGB32_Premultiplied));
  }
  validImage=false;
  return false;
}
Beispiel #30
0
//----------------------------------------------------------------------------------------------------------------------
bool Texture::loadImage( const std::string &_fName  )
{
 // std::cout<<"NGL loading texture\n";
  QImage *image = new QImage();
  bool loaded=image->load(_fName.c_str());
  if(loaded ==false)
  {
    std::cerr<<"error loading image "<<_fName.c_str()<<"\n";
  }
  if(loaded == true)
  {
    m_width=image->width();
    m_height=image->height();
    m_hasAlpha=image->hasAlphaChannel();
    if(m_hasAlpha == true)
    {
      m_bpp=4;
      m_format = GL_RGBA;
    }
    else
    {
      m_bpp=3;
      m_format = GL_RGB;
    }

    m_data.reset(new unsigned char[ m_width*m_height*m_bpp]);
    unsigned int index=0;
    QRgb colour;
    for(unsigned int y=m_height-1; y>0; y--)
    {
      for(unsigned int x=0; x<m_width; ++x)
      {
        colour=image->pixel(x,y);

        m_data[index++]=qRed(colour);
        m_data[index++]=qGreen(colour);
        m_data[index++]=qBlue(colour);
        if(m_hasAlpha)
        {
          m_data[index++]=qAlpha(colour);
        }
      }
    }

   // std::cout<<"Image size ="<<m_width<<"x"<<m_height<<std::endl;
   // std::cout<<"has alpha = "<<m_hasAlpha<<std::endl;
   // std::cout<<"bpp = "<<m_bpp<<std::endl;
    return true;

  }

  else return false;
}