本文整理汇总了C++中QPixmap::toImage方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::toImage方法的具体用法?C++ QPixmap::toImage怎么用?C++ QPixmap::toImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPixmap
的用法示例。
在下文中一共展示了QPixmap::toImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateData
void IdentityWidget::updateData(const RsPeerDetails &pgp_details)
{
//if (_details != pgp_details) {
_details = pgp_details;
_havePGPDetail = true;
_nickname = QString::fromUtf8(_details.name.c_str());
if (!_haveGXSId) m_myName = _nickname;
ui->labelName->setText(m_myName);
if (_haveGXSId) {
ui->labelName->setToolTip(tr("GXS name:").append(" "+m_myName).append("\n")
.append(tr("PGP name:").append(" "+_nickname)));
} else {//if (m_myName != _nickname)
ui->labelName->setToolTip(tr("PGP name:").append(" "+_nickname));
}//else (m_myName != _nickname)
QFont font = ui->labelName->font();
font.setItalic(true);
ui->labelName->setFont(font);
_keyId = QString::fromStdString(_details.gpg_id.toStdString());
ui->labelKeyId->setText(_keyId);
ui->labelKeyId->setToolTip(tr("PGP id:").append(" "+_keyId));
QPixmap avatar;
AvatarDefs::getAvatarFromGpgId(_details.gpg_id.toStdString(), avatar);
if (_avatar != avatar.toImage()) {
_avatar = avatar.toImage();
_scene->clear();
_scene->addPixmap(avatar.scaled(ui->graphicsView->width(),ui->graphicsView->height()));
emit imageUpdated();
}//if (_avatar != avatar.toImage())
//}//if (_details != gpg_details)
}
示例2: makePixmapForDrag
QPixmap TabBar::makePixmapForDrag(int index) {
std::vector< std::pair<QString,QIcon > > tabs;
for (int i = 0; i < count(); ++i) {
tabs.push_back(std::make_pair(tabText(i),tabIcon(i)));
}
//remove all tabs
while (count() > 0) {
removeTab(0);
}
///insert just the tab we want to screen shot
addTab(tabs[index].second, tabs[index].first);
QPixmap currentTabPixmap = Gui::screenShot(_tabWidget->tabAt(index));
#if QT_VERSION < 0x050000
QPixmap tabBarPixmap = QPixmap::grabWidget(this);
#else
QPixmap tabBarPixmap = grab();
#endif
///re-insert all the tabs into the tab bar
removeTab(0);
for (U32 i = 0; i < tabs.size(); ++i) {
addTab(tabs[i].second, tabs[i].first);
}
QImage tabBarImg = tabBarPixmap.toImage();
QImage currentTabImg = currentTabPixmap.toImage();
//now we just put together the 2 pixmaps and set it with mid transparancy
QImage ret(currentTabImg.width(),currentTabImg.height() + tabBarImg.height(),QImage::Format_ARGB32_Premultiplied);
for (int y = 0; y < tabBarImg.height(); ++y) {
QRgb* src_pixels = reinterpret_cast<QRgb*>(tabBarImg.scanLine(y));
for (int x = 0; x < ret.width(); ++x) {
if (x < tabBarImg.width()) {
QRgb pix = src_pixels[x];
ret.setPixel(x, y, qRgba(qRed(pix), qGreen(pix), qBlue(pix), 255));
} else {
ret.setPixel(x, y, qRgba(0, 0, 0, 128));
}
}
}
for (int y = 0; y < currentTabImg.height(); ++y) {
QRgb* src_pixels = reinterpret_cast<QRgb*>(currentTabImg.scanLine(y));
for (int x = 0; x < ret.width(); ++x) {
QRgb pix = src_pixels[x];
ret.setPixel(x, y + tabBarImg.height(), qRgba(qRed(pix), qGreen(pix), qBlue(pix), 255));
}
}
return QPixmap::fromImage(ret);
}
示例3: setPixmap
void QGeoMapPixmapObject::setPixmap(const QPixmap &pixmap)
{
QPixmap curPixmap = d_ptr->pixmap;
if (curPixmap.isNull() && pixmap.isNull())
return;
if ((curPixmap.isNull() && !pixmap.isNull())
|| (!curPixmap.isNull() && pixmap.isNull())
|| (curPixmap.toImage() != pixmap.toImage())) {
d_ptr->pixmap = pixmap;
emit pixmapChanged(pixmap);
}
}
示例4: toQImage
QImage ImageBufferDataPrivateUnaccelerated::toQImage() const
{
QPaintEngine* paintEngine = m_pixmap.paintEngine();
if (!paintEngine || paintEngine->type() != QPaintEngine::Raster)
return m_pixmap.toImage();
// QRasterPixmapData::toImage() will deep-copy the backing QImage if there's an active QPainter on it.
// For performance reasons, we don't want that here, so we temporarily redirect the paint engine.
QPaintDevice* currentPaintDevice = paintEngine->paintDevice();
paintEngine->setPaintDevice(0);
QImage image = m_pixmap.toImage();
paintEngine->setPaintDevice(currentPaintDevice);
return image;
}
示例5: slotIconChanged
void WebPage::slotIconChanged(void)
{
QIcon icon = m_browser->GetIcon();
if (icon.isNull())
{
//FIXME use a default icon here?
m_listItem->setImage(NULL);
}
else
{
if (m_listItem)
{
QPixmap pixmap = icon.pixmap(32, 32);
QImage image = pixmap.toImage();
image = image.scaled(
QSize(32,32), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
MythImage *mimage = GetMythPainter()->GetFormatImage();
mimage->Assign(image);
m_listItem->setImage(mimage);
}
}
m_parent->m_pageList->Refresh();
}
示例6: qGreen
QPixmap
IconLoader::invert(QPixmap pmap)
{
QImage img = pmap.toImage().convertToFormat(QImage::Format_ARGB32);
for (int y = 0; y < img.height(); ++y) {
for (int x = 0; x < img.width(); ++x) {
QRgb rgba = img.pixel(x, y);
QColor colour = QColor
(qRed(rgba), qGreen(rgba), qBlue(rgba), qAlpha(rgba));
int alpha = colour.alpha();
if (colour.saturation() < 5 && colour.alpha() > 10) {
colour.setHsv(colour.hue(),
colour.saturation(),
255 - colour.value());
colour.setAlpha(alpha);
img.setPixel(x, y, colour.rgba());
}
}
}
pmap = QPixmap::fromImage(img);
return pmap;
}
示例7: Refresh
void EC_ChatBubble::Refresh()
{
if (renderer_.expired() ||!billboardSet_ || !billboard_)
return;
// If no messages in the log, hide the chat bubble.
if (messages_.size() == 0)
{
billboardSet_->setVisible(false);
return;
}
else
billboardSet_->setVisible(true);
// Get pixmap with chat bubble and text rendered to it.
QPixmap pixmap = GetChatBubblePixmap();
if (pixmap.isNull())
return;
// Create texture
QImage img = pixmap.toImage();
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream((void*)img.bits(), img.byteCount()));
std::string tex_name("ChatBubbleTexture" + renderer_.lock()->GetUniqueObjectName());
Ogre::TextureManager &manager = Ogre::TextureManager::getSingleton();
Ogre::Texture *tex = dynamic_cast<Ogre::Texture *>(manager.create(tex_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME).get());
assert(tex);
tex->loadRawData(stream, img.width(), img.height(), Ogre::PF_A8R8G8B8);
// Set new material with the new texture name in it.
std::string newMatName = std::string("material") + renderer_.lock()->GetUniqueObjectName();
Ogre::MaterialPtr material = OgreRenderer::CloneMaterial("UnlitTexturedSoftAlpha", newMatName);
OgreRenderer::SetTextureUnitOnMaterial(material, tex_name);
billboardSet_->setMaterialName(newMatName);
}
示例8: alphaBlend
QPixmap StyleHelper::alphaBlend(const QPixmap& src)
{
QImage imageSrc = src.toImage();
QImage imageCopy = imageSrc.convertToFormat(QImage::Format_ARGB32);
QRect rectSrc = imageCopy.rect();
int w = rectSrc.width();
int h = rectSrc.height();
uchar* pixels = imageCopy.bits();
uint mask = 0;
QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied;
// Make a QImage out of the QPixmap and add alpha
QImage image(w, h, imageFormat);
if (!image.isNull())
{
int bytes_per_line = w * sizeof(QRgb);
for (int y = 0; y < h; ++y)
{
QRgb* dest = (QRgb*) image.scanLine(y);
const QRgb* src = (const QRgb *) (pixels + y * bytes_per_line);
for (int x = 0; x < w; ++x)
{
const uint pixel = src[x];
if ((pixel & 0xff000000) == 0 && (pixel & 0x00ffffff) != 0)
dest[x] = pixel | 0xff000000;
else
dest[x] = pixel | mask;
}
}
}
return QPixmap::fromImage(image, Qt::AutoColor);
}
示例9: makeShadow
QImage makeShadow( const QPixmap& textPixmap, const QColor &bgColor )
{
const int w = textPixmap.width();
const int h = textPixmap.height();
const int bgr = bgColor.red();
const int bgg = bgColor.green();
const int bgb = bgColor.blue();
int alphaShadow;
// This is the source pixmap
QImage img = textPixmap.toImage();
QImage result( w, h, QImage::Format_ARGB32 );
result.fill( 0 ); // fill with black
static const int M = 5;
for( int i = M; i < w - M; i++) {
for( int j = M; j < h - M; j++ )
{
alphaShadow = (int) decay( img, i, j );
result.setPixel( i,j, qRgba( bgr, bgg , bgb, qMin( MAX_OPACITY, alphaShadow ) ) );
}
}
return result;
}
示例10: drawGrid
QImage BitmapHelper::drawGrid(const QImage *source, int scale)
{
QImage result = QImage(*source);
if (scale > 5) {
QPixmap pixmap = QPixmap::fromImage(result);
QPainter painter(&pixmap);
painter.setPen(QColor("silver"));
for (int x = 0; x < pixmap.width(); x += scale) {
painter.drawLine(x, 0, x, pixmap.height());
}
painter.drawLine(pixmap.width() - 1, 0, pixmap.width() - 1, pixmap.height());
for (int y = 0; y < pixmap.height(); y += scale) {
painter.drawLine(0, y, pixmap.width(), y);
}
painter.drawLine(0, pixmap.height() - 1, pixmap.width(), pixmap.height() - 1);
result = pixmap.toImage();
}
return result;
}
示例11: drawShadowedPixmap
void EWASiteDrawer::drawShadowedPixmap(QPainter *p, const QPixmap &pix, int dx, int dy, bool onlyshdw )
{
QImage msk = pix.toImage();
QImage shadow(msk.width()+2*fsize, msk.height()+2*fsize, QImage::Format_ARGB32);
double divisor=0.0;
for(int i=0;i<2*fsize+1;i++)
for(int j=0;j<2*fsize+1;j++)
divisor+=filter[i][j];
for(int y=0;y<shadow.height(); y++)
for(int x=0;x<shadow.width(); x++){
int l=0;
for(int sy=-fsize;sy<=fsize;sy++)
for(int sx=-fsize;sx<=fsize;sx++){
int tx = x+sx-fsize;
int ty = y+sy-fsize;
if(tx<0 || ty<0 || tx>=msk.width() || ty>=msk.height())
l+=(int)(filter[sx+fsize][sy+fsize]*255);
else
l+=(int)(filter[sx+fsize][sy+fsize]*(255-qAlpha(msk.pixel(tx, ty))));
}
l=(int)(l/divisor);
l = 255 - l;
l=qBound(0, l, 225);
shadow.setPixel(x, y,qRgba(0, 0, 0, l));
}
p->drawImage(dx, dy, shadow);
if(!onlyshdw) p->drawPixmap(dx, dy, pix);
}
示例12: recolorPixmap
QPixmap SxButton::recolorPixmap(const QPixmap& pixmap, int _r, int _g, int _b)
{
QImage image = pixmap.toImage();
QImage alpha = image.alphaChannel();
for (int y = 0; y < image.height(); y++)
{
for (int x = 0; x < image.width(); x++)
{
QRgb color = image.pixel(x,y);
int r = qRed(color);
int g = qGreen(color);
int b = qBlue(color);
r+= _r;
g+= _g;
b+= _b;
if (r<0) r=0; else if (r>=256) r=255;
if (g<0) g=0; else if (g>=256) g=255;
if (b<0) b=0; else if (b>=256) b=255;
color = QColor(r,g,b).rgb();
image.setPixel(x,y,color);
}
}
image.setAlphaChannel(alpha);
return QPixmap::fromImage(image);
}
示例13: QString
void
AudioEngine::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
if ( requestData.caller != s_aeInfoIdentifier ||
requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
{
return;
}
QVariantMap playInfo;
playInfo["message"] = QString( "Tomahawk is playing \"%1\" by %2 on album %3." )
.arg( m_currentTrack->track() )
.arg( m_currentTrack->artist()->name() )
.arg( m_currentTrack->album()->name() );
if ( !output.isNull() && output.isValid() )
{
QVariantMap returnedData = output.value< QVariantMap >();
const QByteArray ba = returnedData["imgbytes"].toByteArray();
if ( ba.length() )
{
QPixmap pm;
pm.loadFromData( ba );
playInfo["image"] = QVariant( pm.toImage() );
}
}
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
QVariant::fromValue< QVariantMap >( playInfo ) );
}
示例14: QImage
//-------------------------------------------------
QImage * ImageWriter::createImage (
time_t date, ImageWriterDialog &dial, int Winit, int Hinit)
{
QImage *image = NULL;
int W = dial.getW ();
int H = dial.getH ();
if (dial.getResizeAfter() && (W!=Winit || H!=Hinit) )
{
QPixmap *pixmap = terre->createPixmap (date, Winit, Hinit);
if (pixmap) {
QPixmap pixmap2 = pixmap->scaled (W, H,
Qt::KeepAspectRatioByExpanding,
Qt::SmoothTransformation);
image = new QImage (pixmap2.toImage ());
delete pixmap;
}
}
else {
QPixmap *pixmap = terre->createPixmap (date, W, H);
if (pixmap) {
image = new QImage (pixmap->toImage ());
delete pixmap;
}
}
return image;
}
示例15: fromRgbF
QColor
KColorDialog::grabColor(const QPoint &p)
{
#ifdef Q_WS_X11
// we use the X11 API directly in this case as we are not getting back a valid
// return from QPixmap::grabWindow in the case where the application is using
// an argb visual
Window root = RootWindow(QX11Info::display(), QX11Info::appScreen());
// XImage *ximg = XGetImage(QX11Info::display(), root, p.x(), p.y(), 1, 1, -1, ZPixmap);
// unsigned long xpixel = XGetPixel(ximg, 0, 0);
// XDestroyImage(ximg);
XColor xcol;
// xcol.pixel = xpixel;
xcol.flags = DoRed | DoGreen | DoBlue;
// XQueryColor(QX11Info::display(),
// DefaultColormap(QX11Info::display(), QX11Info::appScreen()),
// &xcol);
return QColor::fromRgbF(xcol.red / 65535.0, xcol.green / 65535.0, xcol.blue / 65535.0);
#else
QWidget *desktop = QApplication::desktop();
QPixmap pm = QPixmap::grabWindow(desktop->winId(), p.x(), p.y(), 1, 1);
QImage i = pm.toImage();
return i.pixel(0, 0);
#endif
}