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


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

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


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

示例1: 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,代码来源:

示例2: StretchLogoLabel

ProfileOpenDlg::ProfileOpenDlg(const QString &def, const VarList &_langs, const QString &curLang, QWidget *parent)
:QDialog(parent)
{
	setupUi(this);
	setModal(true);
	setWindowTitle(CAP(caption()));

	langs = _langs;

	// insert the logo
	QPixmap logo = (QPixmap)IconsetFactory::icon("psi/psiLogo").pixmap();
	lb_logo->setPixmap(logo);
	lb_logo->setFixedSize(logo.width(), logo.height());
	lb_logo->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
	//setFixedWidth(logo->width());

	QImage logoImg = logo.convertToImage();

	QPixmap tmp;
	tmp.convertFromImage( logoImg.copy(0, 0, 1, logoImg.height()) );
	StretchLogoLabel *stretch = new StretchLogoLabel(tmp, lb_left);

	tmp.convertFromImage( logoImg.copy(logoImg.width()-1, 0, 1, logoImg.height()) );
	stretch = new StretchLogoLabel(tmp, lb_right);

	// setup signals
	connect(pb_open, SIGNAL(clicked()), SLOT(accept()));
	connect(pb_close, SIGNAL(clicked()), SLOT(reject()));
	connect(pb_profiles, SIGNAL(clicked()), SLOT(manageProfiles()));
	connect(cb_lang, SIGNAL(activated(int)), SLOT(langChange(int)));

	int x = 0;
	langSel = x;
	for(VarList::ConstIterator it = langs.begin(); it != langs.end(); ++it) {
		cb_lang->insertItem((*it).data());
		if((curLang.isEmpty() && x == 0) || (curLang == (*it).key())) {
			cb_lang->setCurrentItem(x);
			langSel = x;
		}
		++x;
	}

	// QWhatsThis helpers
	cb_profile->setWhatsThis(
		tr("Select a profile to open from this list."));
	cb_lang->setWhatsThis(
		tr("Select a language you would like Synapse-IM to use from this "
		"list.  You can download extra language packs from the Synapse-IM homepage."));
	ck_auto->setWhatsThis(
		tr("Automatically open this profile when Synapse-IM is started.  Useful if "
		"you only have one profile."));

	reload(def);
}
开发者ID:BackupTheBerlios,项目名称:synapse-xmpp-svn,代码行数:54,代码来源:profiledlg.cpp

示例3: on_actionGrayscale_triggered

void MainWindow::on_actionGrayscale_triggered()
{
    QPixmap pixmap = pixmapItem->pixmap().copy();

    QImage image = pixmap.toImage();
    for (int y = 0; y < image.height(); ++y)
        for (int x = 0; x < image.width(); ++x)
        {
            QRgb oldColor = image.pixel(x, y);
            int gray = qPow(
                       0.2126 * qPow(qRed(oldColor), 2.2) +
                       0.7152 * qPow(qGreen(oldColor), 2.2) +
                       0.0722 * qPow(qBlue(oldColor), 2.2),
                       1/2.2
                       );
            QRgb newColor = qRgba(gray, gray, gray, qAlpha(oldColor));
            image.setPixel(x, y, newColor);
        }

    pixmap.convertFromImage(image);

    pixmapItem_2->setPixmap(pixmap);
    scene_2->setSceneRect(QRectF(pixmap.rect()));

    calcHist(pixmap, hist_2, maxLevel_2);
    drawHist(pixmapItem_4, hist_2, maxLevel_2);
}
开发者ID:andrew-k-21-12,项目名称:aioi3,代码行数:27,代码来源:mainwindow.cpp

示例4: 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

示例5: onChangeHistogrammWidget

void myFrame::onChangeHistogrammWidget(int x1, int x2)
{
    qDebug() << "ChangeHistogrammWidget 1" << QTime::currentTime().toString("hh:mm:ss.zzz");
    quint8 * line = rxImage.scanLine(0);
    int stride =  rxImage.bytesPerLine();
    qint32 pixel = 0;
    qDebug() << "ChangeHistogrammWidget 2" << QTime::currentTime().toString("hh:mm:ss.zzz");
    for ( int y = 0; y < rxImage.height(); ++y, line += stride)
    {
        quint8 * pix = line;
        for ( int x = 0; x < rxImage.width(); ++x, pix += 1)
        {
            pixel  = 255*(imageData[(y*IMAGE_WIDTH)+x]-x1)/((x2-x1));
            if (pixel > 255)
            {
                pixel = 255;
            }
            if (pixel < 0)
            {
                pixel = 0;
            }
            pix[0] =  pixel;
        }
    }
    qDebug() << "ChangeHistogrammWidget 3" << QTime::currentTime().toString("hh:mm:ss.zzz");

    QPixmap pixmap;
    pixmap.convertFromImage(rxImage);
    imageLabel->setPixmap(pixmap);
    qDebug() << "ChangeHistogrammWidget 4" << QTime::currentTime().toString("hh:mm:ss.zzz");
}
开发者ID:TomoControl,项目名称:TomoControl,代码行数:31,代码来源:myimageviewer.cpp

示例6: slotShowPreview

void QPreviewFileDialog::slotShowPreview(bool b)
{
  if(!mPreviewMode) return;
  QString qs;
  double xfac;
  double yfac;
  QImage qi;
  QPixmap* pix;
//  showExtension(b);
  if(b)
  {
    xfac = double(mpImage->width())/double(mpPixWidget->width());
    yfac = double(mpImage->height())/double(mpPixWidget->height());
    if(xfac > yfac)
      qi = mpImage->smoothScale(mpImage->width()/xfac,mpImage->height()/xfac);
    else
      qi = mpImage->smoothScale(mpImage->width()/yfac,mpImage->height()/yfac);
    pix = new QPixmap;
    pix->convertFromImage(qi);
    mpPixWidget->setPixmap(*pix);
  }
  else
  {
    if(mpPixWidget->pixmap())
      mpPixWidget->pixmap()->resize(0,0);
    mpPixWidget->repaint();
  }
  xmlConfig->setBoolValue("PREVIEW_EXTENSION",b);
}
开发者ID:arunjalota,项目名称:paperman,代码行数:29,代码来源:qpreviewfiledialog.cpp

示例7: itemId

ClothingThumbnail::ClothingThumbnail(ClothingItem someClothing, bool acceptTouchEvents, bool thumbnail)
: itemId(someClothing.getItemID())
{
    QPixmap* clothingImage = new QPixmap();
    if(thumbnail){
        clothingImage->convertFromImage(someClothing.getThumbnail());
    } else {
        clothingImage->convertFromImage(someClothing.getImage());        
    }
    this->setPixmap(*clothingImage);
    if(acceptTouchEvents){
        setAttribute(Qt::WA_AcceptTouchEvents);
    }
    connect(&touchTimer, SIGNAL(timeout()), this, SLOT(selectionTimerTimeout()));
    setStyleSheet("border: 4px solid orange; border-radius: 8px; background-color: orange;");
}
开发者ID:beaesguerra,项目名称:dressr,代码行数:16,代码来源:ClothingThumbnail.cpp

示例8: 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,代码来源:

示例9: showPreview

void PictPreview::showPreview(const char *file)
{
    if (file == NULL){
        label->setPixmap(QPixmap());
        return;
    }
    QImage img(QString::fromLocal8Bit(file));
    if ((img.width() > label->width()) || (img.height() > label->height())){
        bool bOk = false;
        if (img.width() > label->width()){
            int h = img.height() * label->width() / img.width();
            if (h <= label->height()){
                img = img.smoothScale(label->width(), h);
                bOk = true;
            }
        }
        if (!bOk){
            int w = img.width() * label->height() / img.height();
            img = img.smoothScale(w, label->height());
        }
    }
    QPixmap pict;
    pict.convertFromImage(img);
    label->setPixmap(pict);
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例10: updateCount

/**
 * Update the count of unread messages.  If there are unread messages,
 * overlay the count on top of a transparent version of the KMail icon.
 * If there is no unread mail, restore the normal KMail icon.
 */
void KMSystemTray::updateCount()
{
  if(mCount != 0)
  {
    int oldPixmapWidth = pixmap()->size().width();
    int oldPixmapHeight = pixmap()->size().height();

    QString countString = QString::number( mCount );
    QFont countFont = KGlobalSettings::generalFont();
    countFont.setBold(true);

    // decrease the size of the font for the number of unread messages if the
    // number doesn't fit into the available space
    float countFontSize = countFont.pointSizeFloat();
    QFontMetrics qfm( countFont );
    int width = qfm.width( countString );
    if( width > oldPixmapWidth )
    {
      countFontSize *= float( oldPixmapWidth ) / float( width );
      countFont.setPointSizeFloat( countFontSize );
    }

    // Create an image which represents the number of unread messages
    // and which has a transparent background.
    // Unfortunately this required the following twisted code because for some
    // reason text that is drawn on a transparent pixmap is invisible
    // (apparently the alpha channel isn't changed when the text is drawn).
    // Therefore I have to draw the text on a solid background and then remove
    // the background by making it transparent with QPixmap::setMask. This
    // involves the slow createHeuristicMask() function (from the API docs:
    // "This function is slow because it involves transformation to a QImage,
    // non-trivial computations and a transformation back to a QBitmap."). Then
    // I have to convert the resulting QPixmap to a QImage in order to overlay
    // the light KMail icon with the number (because KIconEffect::overlay only
    // works with QImage). Finally the resulting QImage has to be converted
    // back to a QPixmap.
    // That's a lot of work for overlaying the KMail icon with the number of
    // unread messages, but every other approach I tried failed miserably.
    //                                                           IK, 2003-09-22
    QPixmap numberPixmap( oldPixmapWidth, oldPixmapHeight );
    numberPixmap.fill( Qt::white );
    QPainter p( &numberPixmap );
    p.setFont( countFont );
    p.setPen( Qt::blue );
    p.drawText( numberPixmap.rect(), Qt::AlignCenter, countString );
    numberPixmap.setMask( numberPixmap.createHeuristicMask() );
    QImage numberImage = numberPixmap.convertToImage();

    // Overlay the light KMail icon with the number image
    QImage iconWithNumberImage = mLightIconImage.copy();
    KIconEffect::overlay( iconWithNumberImage, numberImage );

    QPixmap iconWithNumber;
    iconWithNumber.convertFromImage( iconWithNumberImage );
    setPixmap( iconWithNumber );
  } else
  {
    setPixmap( mDefaultIcon );
  }
}
开发者ID:,项目名称:,代码行数:65,代码来源:

示例11: setZoom

void DrawZone::setZoom(double z)
{
	_zoom=z;
	imageRect.setHeight(myround(image.height()*_zoom));
	imageRect.setWidth(myround(image.width()*_zoom));
	zoomedImage=QPixmap(imageRect.width(),imageRect.height());
	QPainter p(&zoomedImage);
	p.scale(z,z);
	QPixmap pix;
	pix.convertFromImage(image);
	// if the picture has transparent areas,
	// fill them with Gimp like background
	if (pix.mask()) {
  	QPixmap backPix(32,32);
  	QPainter p2(&backPix);
  	p2.fillRect(0,0,32,32,QColor(156,149,156));
  	p2.fillRect(0,16,16,16,QColor(98,105,98));
  	p2.fillRect(16,0,16,16,QColor(98,105,98));
  	p2.flush();
  	p.setPen(QPen());
  	p.fillRect(imageRect.left(),imageRect.top(),imageRect.width(),imageRect.height(),QBrush(QColor("black"),backPix));
	}
	p.drawPixmap(imageRect.left(),imageRect.top(),pix);
	p.flush();
	resizeContents(visibleWidth()>imageRect.width() ? visibleWidth() : imageRect.width(),
								 visibleHeight()>imageRect.height() ? visibleHeight() : imageRect.height());
	repaintContents(0,0,contentsWidth(),contentsHeight(),true);
}
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:28,代码来源:drawzone.cpp

示例12: updateUi

//-----------------------------------------------------------------------------
void MainDialog::updateUi()
{
	//liste des particules
	QString s;
	if( (int)mParticules.size() != mpParticules->count() )
  {
  	mpParticules->clear();
    for( int i = 0; i < (int)mParticules.size(); ++i )
    {
      s = "source " + QString::number( i );
      mpParticules->insertItem( i, s );
    }
  }
	
  //parametre
  Particules& source = getSelectedSource();
  QImage imageColor( 32, 32, QImage::Format_RGB32 );
  imageColor.fill( source.getColor().rgb() );
  QPixmap pix;
  pix.convertFromImage( imageColor );
  mpColorButton->setIcon( pix );
  mpNumberOfParticules->setText( QString::number( source.getNumberOfParticules() ) );
  mpType->setCurrentIndex( source.getType() );
  mpLifeLowerBound->setText( QString::number( source.getLifeRange().first ) );
  mpLifeUpperBound->setText( QString::number( source.getLifeRange().second ) );
  mpVelocityLowerBound->setText( QString::number( source.getVelocityRange().first ) );
  mpVelocityUpperBound->setText( QString::number( source.getVelocityRange().second ) );
  mpRadiusSlider->setValue( source.getRadius() );
  mpRateSlider->setValue( source.getRate() );
  mpSizeSlider->setValue( source.getSize() );
  
	mpViewer->update();
}
开发者ID:realisim,项目名称:realisim,代码行数:34,代码来源:MainDialog.cpp

示例13: 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

示例14: decode

/*!
  Attempts to decode the dropped information in \a e
  into \a pm, returning TRUE if successful.

  This is a convenience function that converts
  to \a pm via a QImage.

  \sa canDecode()
*/
bool QImageDrag::decode( QDropEvent* e, QPixmap& pm )
{
    QImage img;
    if ( decode( e, img ) )
	return pm.convertFromImage( img ); 
    return FALSE;
}
开发者ID:kthxbyte,项目名称:Qt1.45-Linaro,代码行数:16,代码来源:qdragobject.cpp

示例15: 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


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