当前位置: 首页>>代码示例>>C++>>正文


C++ QPixmap::fromImage方法代码示例

本文整理汇总了C++中QPixmap::fromImage方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::fromImage方法的具体用法?C++ QPixmap::fromImage怎么用?C++ QPixmap::fromImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPixmap的用法示例。


在下文中一共展示了QPixmap::fromImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

void E1DialerButton::generateBgPixmap( const E1DialerButton::State& st )
{
    QPixmap pm;
    if( !m_bgImage.isNull() && m_colorForState[st].isValid() ) {
        QImage tmpImg = m_bgImage.copy();
        ThemePixmapItem::colorizeImage(tmpImg, m_colorForState[st], 255, true);
        pm = pm.fromImage(tmpImg);
        m_bgForState[st] = pm;
    } else if( !m_bgImage.isNull() ) {
        pm = pm.fromImage( m_bgImage );
        m_bgForState[st] = pm;
    }
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:13,代码来源:e1_dialer.cpp

示例2: assert

void ribi::QtBoenkenMainDialog::Paint(
  QPixmap& pixmap,
  const unsigned char r,
  const unsigned char g,
  const unsigned char b,
  const unsigned char a)
{
  const int width = pixmap.width();
  const int height = pixmap.height();

  QImage image = pixmap.toImage();

  assert(image.bytesPerLine() / width == 4
    && "Assume there are 4 bytes per pixel");

  for (int y=0; y!=height; ++y)
  {
    unsigned char * const line
      = static_cast<unsigned char *>(image.scanLine(y));
    for (int x=0; x!=width; ++x)
    {
      line[x*4+3] = a; //Alpha value
      line[x*4+2] = r; //Red
      line[x*4+1] = g; //Green
      line[x*4+0] = b; //Blue
    }
  }
  pixmap = pixmap.fromImage(image);
}
开发者ID:RLED,项目名称:ProjectRichelBilderbeek,代码行数:29,代码来源:qtboenkenmaindialog.cpp

示例3: mostrar_captura_s

//Mostrara imagen recojida del socket
void ViewerWindow::mostrar_captura_s(const QImage &image)
{
    QPixmap pixmap;
    pixmap=pixmap.fromImage(image);
    ui->label->setPixmap(pixmap);

}
开发者ID:alu4216,项目名称:Proyecto-cliente-servidor,代码行数:8,代码来源:viewerwindow.cpp

示例4: setThumbnail

void ScrollBox::setThumbnail(QPixmap img)
{
    QPixmap bkPixmap  = img.fromImage(img.toImage().scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
    QPalette palette;
    palette.setBrush(backgroundRole(), bkPixmap);
    setPalette(palette);

    // Qt3
    //setPaletteBackgroundPixmap(img.fromImage(img.toImage().scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)));
}
开发者ID:UIKit0,项目名称:rosegarden,代码行数:10,代码来源:ScrollBox.cpp

示例5: setPict

void ICQPicture::setPict(QImage &img)
{
    if (img.isNull()){
        lblPict->setText(i18n("Picture is not available"));
        return;
    }
    QPixmap pict;
    pict.fromImage(img);
    lblPict->setPixmap(pict);
    lblPict->setMinimumSize(pict.size());
}
开发者ID:BackupTheBerlios,项目名称:sim-im-svn,代码行数:11,代码来源:icqpicture.cpp

示例6: convertPixmapToGrayscale

// experimental
QPixmap PrintLayout::convertPixmapToGrayscale(QPixmap pixmap) const
{
	QImage image = pixmap.toImage();
	int gray, width = pixmap.width(), height = pixmap.height();
	for (int i = 0; i < width; i++) {
		for (int j = 0; j < height; j++) {
			gray = qGray(image.pixel(i, j));
			image.setPixel(i, j, qRgb(gray, gray, gray));
		}
	}
    return pixmap.fromImage(image);
}
开发者ID:JT5D,项目名称:subsurface,代码行数:13,代码来源:printlayout.cpp

示例7: image_s

//Procesar los frame recibidos por la cam para mostrarlos y modificarlo(pintar sobre ellos)
void ViewerWindow::image_s(const QImage &image)
{
    //Procesar la image para poder pintar sobre ella la hora
    QTime time = QTime::currentTime();
    QString timeString = time.toString();
    QPixmap pixmap;
    pixmap=pixmap.fromImage(image);
    QPainter paint(&pixmap);
    paint.setPen(Qt::green);
    paint.drawText(0,0,pixmap.width(),pixmap.height(),Qt::AlignRight |Qt::AlignBottom ,timeString,0);
    ui->label->setPixmap(pixmap);

}
开发者ID:alu4216,项目名称:Proyecto-cliente-servidor,代码行数:14,代码来源:viewerwindow.cpp

示例8: setPixmap

	void setPixmap(const QPixmap &_pm)
	{
		QPixmap pm;
		QImage i = _pm.toImage();
		i = i.scaled(i.width() * 2, i.height() * 2);
		pm.fromImage(i);

		TrayIconPrivate::setPixmap(pm);

		// thanks to Robert Spier for this:
		// for some reason the repaint() isn't being honored, or isn't for
		// the icon.  So force one on the widget behind the icon
		repaint();
	}
开发者ID:hatstand,项目名称:davepp,代码行数:14,代码来源:trayicon_x11.cpp

示例9: imageSelectionChanged

void PackThemeImageWidget::imageSelectionChanged(const QString & szImagePath)
{
	QImage pix(szImagePath);
	if(!pix.isNull())
	{
		QPixmap out;
		if(pix.width() > 300 || pix.height() > 225)
		{
			pix=pix.scaled(300,225,Qt::KeepAspectRatio,Qt::SmoothTransformation);
			out=out.fromImage(pix);
		} else {
			out=out.fromImage(pix);
		}
		m_pImageLabel->setPixmap(out);
		return;
	}

	QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected image","theme"),
		QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);

	m_pImageSelector->setSelection("");
	m_pImageLabel->setPixmap(QPixmap());
}
开发者ID:namikaze90,项目名称:KVIrc,代码行数:23,代码来源:PackThemeDialog.cpp

示例10: changeColor

QPixmap MusicItem::changeColor(const QPixmap &pixmap, QColor c)
{
    QImage image = pixmap.toImage();
    QRgb old;
    int width = pixmap.width();
    int height = pixmap.height();
    for (int i = 0; i < width; ++i)
    {
        for (int j = 0; j < height; ++j)
        {
            old = image.pixel(i, j);
            if (qAlpha(old) == 255)
                image.setPixel(i, j, c.rgb());
        }
    }

    return pixmap.fromImage(image);
}
开发者ID:jotek,项目名称:noteclick,代码行数:18,代码来源:MusicItem.cpp

示例11: background

QPixmap TransparentTop::background(const QColor &c)
{
#if COMPAT_QT_VERSION < 0x030000
    QWidget *w = (QWidget*)parent();
    const QPixmap *bg = w->backgroundPixmap();
    if (bg == NULL)
        return QPixmap();
    QImage img = bg->toImage();
#else
    if (bg.isNull())
        return QPixmap();
    QImage img = bg.toImage();
#endif
    img = KImageEffect::fade(img, m_transparent, c);
    QPixmap res;
    res.fromImage(img);
    return res;
}
开发者ID:BackupTheBerlios,项目名称:sim-im-svn,代码行数:18,代码来源:transtop.cpp

示例12: QGraphicsScene

void QImage2MatDialog::qimageShow(QImage& qImage, QGraphicsView*& graphView)
{
	int imageWidth  = qImage.width();
	int imageHeight = qImage.height();
	int viewWidth   = ui->graphicsView_qimg->width();
	int viewHight   = ui->graphicsView_qimg->height();

	QPixmap pixMap;
	pixMap = pixMap.fromImage(qImage.scaled(viewWidth, 
		viewHight, 
		Qt::KeepAspectRatioByExpanding));

#if 0
	qDebug() << viewWidth << " " << viewHight;
#endif

	QGraphicsScene *graphicsViewScene = new QGraphicsScene();
	graphicsViewScene->setSceneRect(0, 0, viewWidth, viewHight);
	graphicsViewScene->clear();
	graphicsViewScene->addPixmap(pixMap);

	graphView->setScene(graphicsViewScene);
	graphView->show();
}
开发者ID:yhlleo,项目名称:QImage2Mat,代码行数:24,代码来源:qimage2matdialog.cpp

示例13: packageThemes

	bool packageThemes(
			const QString &szPackagePath,
			const QString &szPackageName,
			const QString &szPackageVersion,
			const QString &szPackageDescription,
			const QString &szPackageAuthor,
			const QString &szPackageImagePath,
			KviPointerList<KviThemeInfo> &lThemeInfoList,
			QString &szError
		)
	{
		if(szPackagePath.isEmpty())
		{
			szError = __tr2qs_ctx("Invalid empty package path","theme");
			return false;
		}

		if(szPackageName.isEmpty())
		{
			szError = __tr2qs_ctx("Invalid empty package name","theme");
			return false;
		}

		QPixmap out;

		if(!szPackageImagePath.isEmpty())
		{
			QImage pix(szPackageImagePath);
			if(pix.isNull())
			{
				szError = __tr2qs_ctx("Failed to load the selected image: please fix it","theme");
				return false;
			}

			if((pix.width() > 300) || (pix.height() > 225))
				out = out.fromImage(pix.scaled(300,225,Qt::KeepAspectRatio));
			else
				out=out.fromImage(pix);
		}

		KviPackageWriter f;

		f.addInfoField("PackageType","ThemePack");
		f.addInfoField("ThemePackVersion",KVI_CURRENT_THEME_ENGINE_VERSION);
		f.addInfoField("Name",szPackageName);
		f.addInfoField("Version",szPackageVersion.isEmpty() ? "1.0.0" : szPackageVersion);
		f.addInfoField("Author",szPackageAuthor);
		f.addInfoField("Description",szPackageDescription);
		// this is the equivalent to an empty date.toString() call, but it's needed
		// to ensure qt4 will use the default() locale and not the system() one
		f.addInfoField("Date",QDateTime::currentDateTime().toString(Qt::ISODate));
		f.addInfoField("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE);

		if(!out.isNull())
		{
			QByteArray * pba = new QByteArray();
			QBuffer buffer(pba,0);
			buffer.open(QIODevice::WriteOnly);
			out.save(&buffer,"PNG");
			buffer.close();
			f.addInfoField("Image",pba); // cool :) [no disk access needed]
		}

		QString szTmp;

		szTmp.setNum(lThemeInfoList.count());
		f.addInfoField("ThemeCount",szTmp);

		int iIdx = 0;
		for(KviThemeInfo * pInfo = lThemeInfoList.first();pInfo;pInfo = lThemeInfoList.next())
		{
			if(pInfo->name().isEmpty())
			{
				szError = __tr2qs_ctx("Invalid theme name","theme");
				return false;
			}
			if(pInfo->version().isEmpty())
			{
				szError = __tr2qs_ctx("Invalid theme version","theme");
				return false;
			}

			QString szSubdir = pInfo->name() + QString("-") + pInfo->version();
			szSubdir.replace(QRegExp("[^a-zA-Z0-9_\\-.][^a-zA-Z0-9_\\-.]*"),"_");

			szTmp = QString("Theme%1Name").arg(iIdx);
			f.addInfoField(szTmp,pInfo->name());
			szTmp = QString("Theme%1Version").arg(iIdx);
			f.addInfoField(szTmp,pInfo->version());
			szTmp = QString("Theme%1Description").arg(iIdx);
			f.addInfoField(szTmp,pInfo->description());
			szTmp = QString("Theme%1Date").arg(iIdx);
			f.addInfoField(szTmp,pInfo->date());
			szTmp = QString("Theme%1Subdirectory").arg(iIdx);
			f.addInfoField(szTmp,szSubdir);
			szTmp = QString("Theme%1Author").arg(iIdx);
			f.addInfoField(szTmp,pInfo->author());
			szTmp = QString("Theme%1Application").arg(iIdx);
			f.addInfoField(szTmp,pInfo->application());
			szTmp = QString("Theme%1ThemeEngineVersion").arg(iIdx);
//.........这里部分代码省略.........
开发者ID:kartagis,项目名称:KVIrc,代码行数:101,代码来源:ThemeFunctions.cpp

示例14: pixmap

QPixmap Image::pixmap()
{
	QPixmap pixmap;
	return pixmap.fromImage(m_image) ;
}
开发者ID:Jinxiaohai,项目名称:QT,代码行数:5,代码来源:image.cpp

示例15: QMainWindow

MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this) ;

    device = new epocDevice() ;
    th = new epocThread(device) ;
    timerDraw = new QTimer() ;
    timerDraw->setInterval(100) ;

    ui->graphSignal->setScene(&sceneSignal) ;

    QPixmap pix ;
    pix.fromImage(QImage("../epocWatch/images/head.jpg")) ;
    QGraphicsScene scenePosition ;
    ui->graphPosition->setScene(&scenePosition) ;
    scenePosition.addPixmap(pix) ;

    vecDataAF3.fill(0, 1024) ;
    vecDataAF4.fill(0, 1024) ;
    vecDataF3.fill(0, 1024) ;
    vecDataF4.fill(0, 1024) ;
    vecDataF7.fill(0, 1024) ;
    vecDataF8.fill(0, 1024) ;
    vecDataFC5.fill(0, 1024) ;
    vecDataFC6.fill(0, 1024) ;
    vecDataT7.fill(0, 1024) ;
    vecDataT8.fill(0, 1024) ;
    vecDataP7.fill(0, 1024) ;
    vecDataP8.fill(0, 1024) ;
    vecDataO1.fill(0, 1024) ;
    vecDataO2.fill(0, 1024) ;

    vecFoufou.fill(0, 1024) ;

    isCheckedAF34 = false ;
    isCheckedF34 = false ;
    isCheckedF78 = false ;
    isCheckedFC56 = false ;
    isCheckedO12 = false ;
    isCheckedP78 = false ;
    isCheckedT78 = false ;

    ui->progressDelta->setStyleSheet(ui->progressDelta->property("defaultStyleSheet").toString() +
                                       " QProgressBar::chunk { background: yellow; }") ;
    ui->progressTheta->setStyleSheet(ui->progressTheta->property("defaultStyleSheet").toString() +
                                       " QProgressBar::chunk { background: orange; }") ;
    ui->progressAlpha->setStyleSheet(ui->progressAlpha->property("defaultStyleSheet").toString() +
                                       " QProgressBar::chunk { background: blue; }") ;
    ui->progressBeta->setStyleSheet(ui->progressBeta->property("defaultStyleSheet").toString() +
                                       " QProgressBar::chunk { background: green; }") ;
    ui->progressGamma->setStyleSheet(ui->progressGamma->property("defaultStyleSheet").toString() +
                                       " QProgressBar::chunk { background: red; }") ;


    connect(ui->cbAF34, SIGNAL(clicked()), this, SLOT(slotChecked())) ;
    connect(ui->cbF34, SIGNAL(clicked()), this, SLOT(slotChecked())) ;
    connect(ui->cbF78, SIGNAL(clicked()), this, SLOT(slotChecked())) ;
    connect(ui->cbFC56, SIGNAL(clicked()), this, SLOT(slotChecked())) ;
    connect(ui->cbO12, SIGNAL(clicked()), this, SLOT(slotChecked())) ;
    connect(ui->cbP78, SIGNAL(clicked()), this, SLOT(slotChecked())) ;
    connect(ui->cbT78, SIGNAL(clicked()), this, SLOT(slotChecked())) ;
    connect(ui->cbAll, SIGNAL(clicked()), this, SLOT(slotCheckedAll())) ;

    connect(timerDraw, SIGNAL(timeout()), this, SLOT(slotDraw())) ;

    connect(ui->pbConnect, SIGNAL(clicked()), this, SLOT(slotConnect())) ;
    connect(ui->pbStart, SIGNAL(clicked()), this, SLOT(slotStart())) ;
    connect(ui->pbQuit, SIGNAL(clicked()), this, SLOT(close())) ;
}
开发者ID:eLucid06,项目名称:epocWatch,代码行数:69,代码来源:mainwindow.cpp


注:本文中的QPixmap::fromImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。