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


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

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


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

示例1: updateToolTip

void SystemTray::updateToolTip()
{
//	return; /////////////////////////////////////////////////////

	Basket *basket = Global::bnpView->currentBasket();
	if (!basket)
		return;

	if (basket->icon().isEmpty() || basket->icon() == "basket" || ! Settings::showIconInSystray())
		setPixmap(basket->isLocked() ? m_lockedIconPixmap : m_iconPixmap);
	else {
		// Code that comes from JuK:
		QPixmap bgPix = loadIcon("basket");
		QPixmap fgPix = SmallIcon(basket->icon());

		QImage bgImage = bgPix.convertToImage(); // Probably 22x22
		QImage fgImage = fgPix.convertToImage(); // Should be 16x16
		QImage lockOverlayImage = loadIcon("lockoverlay").convertToImage();

		KIconEffect::semiTransparent(bgImage);
		copyImage(bgImage, fgImage, (bgImage.width() - fgImage.width()) / 2,
                  (bgImage.height() - fgImage.height()) / 2);
		if (basket->isLocked())
			KIconEffect::overlay(bgImage, lockOverlayImage);

		bgPix.convertFromImage(bgImage);
		setPixmap(bgPix);
	}

	//QTimer::singleShot( Container::c_delayTooltipTime, this, SLOT(updateToolTipDelayed()) );
	// No need to delay: it's be called when notes are changed:
	updateToolTipDelayed();
}
开发者ID:tytycoon,项目名称:basket,代码行数:33,代码来源:systemtray.cpp

示例2: menuIconSet

QIconSet menuIconSet(const QString& icon)
{
    QIconSet iconset;
    int iconSize = KickerSettings::menuEntryHeight();

    if (iconSize < 0)
    {
        return iconset;
    }

    if (icon != "unknown")
    {
        if (iconSize > 0)
        {
            iconset = KGlobal::iconLoader()->loadIconSet(icon,
                                                     KIcon::NoGroup,
                                                     iconSize, true);
        }
        else if (iconSize == 0)
        {
            QPixmap normal = KGlobal::iconLoader()->loadIcon(icon,
                                                         KIcon::Small,
                                                         0,
                                                         KIcon::DefaultState,
                                                         0,
                                                         true);

            QPixmap active = KGlobal::iconLoader()->loadIcon(icon,
                                                         KIcon::Small,
                                                         0,
                                                         KIcon::ActiveState,
                                                         0,
                                                         true);

            // make sure they are not larger than 20x20
            if (normal.width() > 20 || normal.height() > 20)
            {
                normal.convertFromImage(normal.convertToImage().smoothScale(20,20));
            }

            if (active.width() > 20 || active.height() > 20)
            {
                active.convertFromImage(active.convertToImage().smoothScale(20,20));
            }

            iconset.setPixmap(normal, QIconSet::Small, QIconSet::Normal);
            iconset.setPixmap(active, QIconSet::Small, QIconSet::Active);
        }
    }

    if (iconset.isNull())
    {
        QPixmap pix(iconSize, iconSize);
        QBitmap map(iconSize, iconSize, true);
        pix.setMask(map);
        iconset = QIconSet(pix, pix);
    }

    return iconset;
}
开发者ID:,项目名称:,代码行数:60,代码来源:

示例3: QPixmap

// return pixmap for a given zoom != 100
QPixmap * get_pixmap(const char * path, double zoom)
{
  QPixmap * px = get_pixmap(path);
  
  if (px == 0)
    return 0;
    
  if (((int) (zoom * 100)) == 100)
    return px;
  
  QPtrDict<QPixmap> * d = DiagramScaledPixmap[path]; // != 0
  int scaled_w = (int) (px->width() * zoom);
  void * k = (void *) scaled_w;
  QPixmap * scaled_px = d->find(k);
  
  if (scaled_px == 0) {
    QImage img = 
      px->convertToImage().smoothScale(scaled_w, (int) (px->height() * zoom));

    scaled_px = new QPixmap();
    scaled_px->convertFromImage(img);
    d->insert(k, scaled_px);
  }
  
  return scaled_px;
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例4: createPixmapNode

void createPixmapNode( QDomDocument& doc, QDomNode& parent,
                       const QString& elementName, const QPixmap& pixmap )
{
    QDomElement pixmapElement = doc.createElement( elementName );
    parent.appendChild( pixmapElement );

    // Convert the pixmap to an image, save that image to an in-memory
    // XPM representation and compress this representation. This
    // conforms to the file format Qt Designer uses.
    QByteArray ba;
    QBuffer buffer( ba );
    buffer.open( IO_WriteOnly );
    QImageIO imgio( &buffer, "XPM" );
    QImage image = pixmap.convertToImage();
    imgio.setImage( image );
    imgio.write();
    buffer.close();
    ulong len = ba.size() * 2;
    QByteArray bazip( len );
    ::compress(  (uchar*) bazip.data(), &len, (uchar*) ba.data(), ba.size() );
    QString dataString;
    static const char hexchars[] = "0123456789abcdef";
    for ( int i = 0; i < (int)len; ++i ) {
        uchar c = (uchar) bazip[i];
        dataString += hexchars[c >> 4];
        dataString += hexchars[c & 0x0f];
    }

    createStringNode( doc, pixmapElement, "Format", "XPM.GZ" );
    createIntNode( doc, pixmapElement, "Length", ba.size() );
    createStringNode( doc, pixmapElement, "Data", dataString );
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例5: ZSettingItem

void mgrui::append2_skin_ui(ZListBox *target, QList<struct skinObj> objList)
{
	struct skinObj *obj = objList.first();
	ZSettingItem *pItem = NULL;
	QPixmap pm;
	while(obj != NULL)
	{	
		pItem = new ZSettingItem(target);//, QString("%I%M") );
		pItem->appendSubItem(1, obj->skinName, SETTINGITEM_REGION_A );
		if(obj->isInPH == true)
			pItem->appendSubItem(1, obj->skinAuthor+ctr(",Phone,")+obj->skinDir,false, SETTINGITEM_REGION_B );
		else
			pItem->appendSubItem(1, obj->skinAuthor+ctr(",MMCA2,")+obj->skinDir, false, SETTINGITEM_REGION_B );
	
		if( QFile::exists( obj->skinWall ) )
			pm = QPixmap( obj->skinWall );
		else
			pm = QPixmap( QString("%1/img/skin.png").arg(appdir) );
			
		QImage img = pm.convertToImage();
		img = img.smoothScale(48, 48);
		pm.convertFromImage(img);
		pItem->setPixmap(0, pm);	
		
		target->insertItem(pItem);
		
		obj = objList.next();
	}
}
开发者ID:OpenMagx,项目名称:moto_magx_app_open_source,代码行数:29,代码来源:rokrmgr.cpp

示例6: buildMgrList

void mgrui::buildMgrList()
{
	mgrListBox->clear();
	
	ZConfig cfg(appdir+"/settings.ini");
	
	int i, tNum;
    tNum = cfg.readNumEntry("LIST", "Items", 1);
	QPixmap pm;
	
	ZSettingItem *pItem = NULL;
	
	for(i=1;i<=tNum;i++)
	{
		printf("==== build item %d =====\n", i);
		pItem = new ZSettingItem(mgrListBox, QString("%I%M") );
		pItem->appendSubItem(1, sctr( cfg.readEntry( "LIST", "Option"+QString::number(i), "") ), false, SETTINGITEM_REGION_A );
		pItem->appendSubItem(1, sctr( cfg.readEntry( "LIST", "Option"+QString::number(i)+"b", "") ), false, SETTINGITEM_REGION_B );
		//pItem->setPixmap(0, pm);		
		//icon = appdir+cfg.readEntry( "LIST", "Icon"+QString::number(i)+"b", "");
		pm = QPixmap(appdir+cfg.readEntry( "LIST", "Icon"+QString::number(i), "") );
		QImage img = pm.convertToImage();
		img = img.smoothScale(48, 48);
		pm.convertFromImage(img);
		pItem->setPixmap(0, pm);	
		
		mgrListBox->insertItem(pItem);
	}
}
开发者ID:OpenMagx,项目名称:moto_magx_app_open_source,代码行数:29,代码来源:rokrmgr.cpp

示例7: icon

QPixmap KasTaskItem::icon()
{
    int sizes[] = { KIcon::SizeEnormous,
		    KIcon::SizeHuge,
		    KIcon::SizeLarge,
		    KIcon::SizeMedium,
		    KIcon::SizeSmall };

    if ( kasbar()->embedThumbnails() && task_->hasThumbnail() ) {
	usedIconLoader = true;

	QPixmap thumb = task_->thumbnail();
	QSize sz = thumb.size();
	sz.scale( sizes[kasbar()->itemSize()], sizes[kasbar()->itemSize()], QSize::ScaleMin );

	QImage img = thumb.convertToImage();
	img = img.smoothScale( sz );

	bool ok = thumb.convertFromImage( img );
	if ( ok )
	    return thumb;
    }

    usedIconLoader = false;
    QPixmap p = task_->bestIcon( sizes[kasbar()->itemSize()], usedIconLoader );
    if ( !p.isNull() )
	return p;

    return task_->icon( sizes[kasbar()->itemSize()], sizes[kasbar()->itemSize()], true );
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例8: loadNewIcon

int LapsusIcons::loadNewIcon(const QString &first, const QString &second, int size)
{
	if (first.length() < 1) return -1;

	QPixmap imgFirst = UserIcon(first);

	if (imgFirst.isNull()) return -1;

	if (second.length() > 0)
	{
		QPixmap imgSecond = UserIcon(second);

		if (!imgSecond.isNull())
		{
			QPainter p;

			p.begin( &imgFirst);
			p.drawPixmap (0, 0, imgSecond);
		}
	}

	int idx = _cachedIcons.count();

	_cachedIcons.push_back(
		QPixmap(imgFirst.convertToImage().smoothScale(size, size)));

	return idx;
}
开发者ID:BackupTheBerlios,项目名称:lapsus-svn,代码行数:28,代码来源:lapsus_icons.cpp

示例9: makeInvisible

static QPixmap makeInvisible(unsigned flags, const QPixmap &p)
{
	unsigned swapColor = flags & ICON_COLOR_MASK;
	char shift = (flags >> 8) & 0xFF;
    QImage image = p.convertToImage();
	if (image.depth() != 32)
		image = image.convertDepth(32);
    unsigned int *data = (unsigned int*)image.bits();
	for (int y = 0; y < image.width(); y++){
		int x = image.width() / 2 - (y - image.height() / 2) * 2 / 3 + shift;
		if (x < 0)
			x = 0;
		if (x > image.width())
			x = image.width();
		unsigned int *line = data + y * (image.width()) + x;
		for (; x < image.width(); x++, line++){
	        QColor c(qRed(*line), qGreen(*line), qBlue(*line));
			int a = qAlpha(*line);
			int h, s, v;
			c.hsv(&h, &s, &v);
			if (swapColor){
				h = (swapColor * 2 - h) & 0xFF;
				c.setHsv(h, s / 2, v * 3 / 4);
			}else{
				c.setHsv(h, s / 2, v * 3 / 4);
			}
	        *line = qRgba(c.red(), c.green(), c.blue(), a);
		}
	}
    QPixmap pict;
    pict.convertFromImage(image);
    return pict;
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例10: drawIcon

void KGridWidget::drawIcon(const QPixmap &icon, bool hitBlend, bool waterBlend, bool rotate)
{
	QPainter painter;
	painter.begin(m_doubleBuffer);
	if(!hitBlend && waterBlend)
	{
		QImage first = icon.convertToImage();
		QImage second = seaPng.convertToImage();
		painter.drawPixmap(m_x, m_y, seaPng);
		if(rotate)
			painter.drawImage(m_x, m_y, KImageEffect::blend(first, second, KImageEffect::VerticalGradient, 30, 30));
		else
			painter.drawImage(m_x, m_y, KImageEffect::blend(first, second, KImageEffect::HorizontalGradient, 30, 30));

	}
	else if(hitBlend && !waterBlend)
	{
		painter.drawPixmap(m_x, m_y, icon);
		painter.drawPixmap(m_x, m_y, hitPng);
	}
	else
		painter.drawPixmap(m_x, m_y, icon);

	if(!m_drawGrid)
		painter.end();
	else
	{
		painter.setBrush(Qt::NoBrush);
		painter.setPen(Qt::black);
		painter.drawRect(m_x, m_y, m_size, m_size);
		painter.end();
	}
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例11: makeOffline

static QPixmap makeOffline(unsigned flags, const QPixmap &p)
{
	unsigned swapColor = flags & ICON_COLOR_MASK;
    QImage image = p.convertToImage();
    unsigned int *data = (image.depth() > 8) ? (unsigned int *)image.bits() :
                         (unsigned int *)image.colorTable();
    int pixels = (image.depth() > 8) ? image.width()*image.height() :
                 image.numColors();
    for (int i = 0; i < pixels; i++){
        QColor c(qRed(data[i]), qGreen(data[i]), qBlue(data[i]));
        int a = qAlpha(data[i]);
		int h, s, v;
		c.hsv(&h, &s, &v);
		if (swapColor){
			h = (swapColor * 2 - h) & 0xFF;
			c.setHsv(h, s, v);
		}else{
			c.setHsv(h, 0, v * 3 / 4);
		}
        data[i] = qRgba(c.red(), c.green(), c.blue(), a);
    }
    QPixmap pict;
    pict.convertFromImage(image);
    return pict;
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例12: drawButtonLabel

void SimpleButton::drawButtonLabel( QPainter *p )
{
    if (!pixmap())
    {
        return;
    }

    QPixmap pix = m_highlight? m_activeIcon : m_normalIcon;

    if (isOn() || isDown())
    {
        pix = pix.convertToImage().smoothScale(pix.width() - 2,
                                               pix.height() - 2);
    }

    int h = height();
    int w = width();
    int ph = pix.height();
    int pw = pix.width();
    int margin = KDialog::spacingHint();
    QPoint origin(margin / 2, margin / 2);

    if (ph < (h - margin))
    {
        origin.setY((h - ph) / 2);
    }

    if (pw < (w - margin))
    {
        origin.setX((w - pw) / 2);
    }

    p->drawPixmap(origin, pix);
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例13: pixmap

// similar to MimeType::pixmapForURL
QPixmap QuickURL::pixmap(mode_t _mode, KIcon::Group _group, int _force_size, int _state, QString *) const
{ // Load icon
    QPixmap pxmap = KMimeType::pixmapForURL(_kurl, _mode, _group, _force_size, _state);
    // Resize to fit button
    pxmap.convertFromImage(pxmap.convertToImage().smoothScale(_force_size, _force_size, QImage::ScaleMin));
    return pxmap;
}
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:8,代码来源:quickbutton.cpp

示例14: setPixmap

void KPrEffectPreview::setPixmap( const QPixmap& pixmap )
{
    // find the right size
    QRect rect = pixmap.rect();
    int w = rect.width();
    int h = rect.height();
    if ( w > h ) {
        w = 297;
        h = 210;
    }
    else if ( w < h ) {
        w = 210;
        h = 297;
    }
    else if ( w == h ) {
        w = 297;
        h = 297;
    }

    setMinimumSize( w, h );

    // create smaller pixmap for preview
    const QImage img( pixmap.convertToImage().smoothScale( w, h, QImage::ScaleFree ) );
    m_pixmap.convertFromImage( img );

    QLabel::setPixmap( m_pixmap );
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例15: drawButton

void QuartzButton::drawButton(QPainter *p)
{
	// Never paint if the pixmaps have not been created
	if (!quartz_initialized)
		return;

	QColor c;

	if (isLeft() )
		c = KDecoration::options()->color(KDecoration::ColorTitleBar, decoration()->isActive()).light(130);
	else
		c = KDecoration::options()->color(KDecoration::ColorTitleBlend, decoration()->isActive());

	// Fill the button background with an appropriate color
	p->fillRect(0, 0, width(), height(), c );

	// If we have a decoration bitmap, then draw that
	// otherwise we paint a menu button (with mini icon), or a onAllDesktops button.
	if( deco )
	{
		int xOff = (width()-10)/2;
		int yOff = (height()-10)/2;
		p->setPen( Qt::black );
		p->drawPixmap(isDown() ? xOff+2: xOff+1, isDown() ? yOff+2 : yOff+1, *deco);
		p->setPen( KDecoration::options()->color(KDecoration::ColorButtonBg, decoration()->isActive()).light(150) );
		p->drawPixmap(isDown() ? xOff+1: xOff, isDown() ? yOff+1 : yOff, *deco);
	} else
		{
			QPixmap btnpix;
			int Offset = 0;

			if (type() == OnAllDesktopsButton)
			{
				if (isDown())
					Offset = 1;

				// Select the right onAllDesktops button to paint
				if (decoration()->isActive())
					btnpix = isOn() ? *pinDownPix : *pinUpPix;
				else
					btnpix = isOn() ? *ipinDownPix : *ipinUpPix;

			} else
				btnpix = decoration()->icon().pixmap( QIconSet::Small, QIconSet::Normal);

			// Shrink the miniIcon for tiny titlebars.
			if ( height() < 16)
			{
				QPixmap tmpPix;

				// Smooth scale the image
				tmpPix.convertFromImage( btnpix.convertToImage().smoothScale(height(), height()));
				p->drawPixmap( 0, 0, tmpPix );
			} else {
				Offset += (height() - 16)/2;
				p->drawPixmap( Offset, Offset, btnpix );
			}
	}
}
开发者ID:,项目名称:,代码行数:59,代码来源:


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