本文整理汇总了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;
}
}
示例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);
}
示例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);
}
示例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)));
}
示例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());
}
示例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);
}
示例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);
}
示例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();
}
示例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());
}
示例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);
}
示例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;
}
示例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();
}
示例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);
//.........这里部分代码省略.........
示例14: pixmap
QPixmap Image::pixmap()
{
QPixmap pixmap;
return pixmap.fromImage(m_image) ;
}
示例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())) ;
}