示例#1
0
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;
}
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);
}
示例#3
0
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);
}
示例#4
0
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();
}
示例#5
0
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");
}
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);
}
示例#7
0
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;");
}
示例#8
0
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;
}
示例#9
0
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);
}
示例#10
0
/**
 * 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 );
  }
}
示例#11
0
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);
}
示例#12
0
//-----------------------------------------------------------------------------
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();
}
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();
	}
}
示例#14
0
/*!
  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;
}
示例#15
0
// 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;
}
示例#16
0
void CNavigationDiagramView::LoadBackgroundImageAndResize(const char *filename){
	QPixmap pixmap;
	QImage image;
	if (image.load(QString(filename))){
		int width = image.width();
		int height = image.height();
		QCanvas *canvas = this->canvas();
		canvas->resize(width, height);

		pixmap.convertFromImage(image);
		canvas->setBackgroundPixmap(pixmap);

		double x, y;

		m_pFromDiagramMarker->move(0.4 * canvas->width(), 0.5 * canvas->height());
		x = m_pFromDiagramMarker->GetCenterX();
		y = m_pFromDiagramMarker->GetCenterY();
		CNavigationProjectController::Instance()->SetNewFromPosition(x, y);

		m_pAtDiagramMarker->move(0.6 * canvas->width(), 0.5 * canvas->height());
		x = m_pAtDiagramMarker->GetCenterX();
		y = m_pAtDiagramMarker->GetCenterY();
		CNavigationProjectController::Instance()->SetNewAtPosition(x, y);
		canvas->update();
	}else{
	}
}
void CViewHistogramDialog::updateView() throw()
{
BENCHSTART;
	alog << "A" << endl;
  histImage.create( usRangeEnd - usRangeStart + 1, 201, 32, 256*256*256 );
  histImage.fill( Qt::white.rgb() );
  histViewPtr->setFixedWidth( 500 );
  QPixmap processedPixmap;
  processedPixmap.convertFromImage( histImage );  	

  QPainter p( &processedPixmap );

	alog << "Histosize is " << histoVec.size() << "   " << usRangeStart << "   " << usRangeEnd << endl;
	alog << "Histosize is " << histoVec[0].size() << "   " << usRangeStart << "   " << usRangeEnd << endl;
  for ( ushort usRange = usRangeStart; usRange <= usRangeEnd; usRange++ )
  {      
      p.drawLine( usRange - usRangeStart, 200, usRange - usRangeStart,
        200 - static_cast<ushort>( histoVec[0][usRange] * ( 200.0 / dMaxValue ) ) );
  }
  p.setPen( Qt::black );
  p.drawLine( 0, 200, usRangeEnd - usRangeStart + 1, 200 );
  p.end();
  histViewPtr->setEraseColor( Qt::gray );
  histViewPtr->setPixmap( processedPixmap );
BENCHSTOP;
}
示例#18
0
    void mousePressEvent(QMouseEvent *e) {
        if(e->button() == LeftButton) {
            if(labeltype == Des)
                return;

            QDragObject *drobj = 0;

            if(pixmap()) { // 如果有圖片
                // 產生QDragObject
                drobj = new QImageDrag(pixmap()->convertToImage(), this);

                QPixmap pm;
                // 產生縮圖
                pm.convertFromImage(
                   pixmap()->convertToImage().smoothScale(25, 25));
                // 拖曳時的顯示圖形與游標位移
                drobj->setPixmap(pm, QPoint(-14, -20));
            }
            else if(text()) { // 如果有文字
                drobj = new QTextDrag(text(), this);
                drobj->setPixmap(QPixmap("text.gif"), QPoint(-25, -15));
            }

            // ?#125;始拖放動作
            if(drobj)
                drobj->dragCopy();
        }
    }   
示例#19
0
void JabberPicture::setPict(QImage &img)
{
    if (img.isNull()){
        lblPict->setText(i18n("Picture is not available"));
        return;
    }
    int w = img.width();
    int h = img.height();
    if (h > w){
        if (h > 300){
            w = w * 300 / h;
            h = 300;
        }
    }else{
        if (w > 300){
            h = h * 300 / w;
            w = 300;
        }
    }
    if ((w != img.width()) || (h != img.height()))
        img = img.smoothScale(w, h);
    QPixmap pict;
    pict.convertFromImage(img);
    lblPict->setPixmap(pict);
    lblPict->setMinimumSize(pict.size());
}
示例#20
0
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 );
}
示例#21
0
QPixmap ThumbnailEditor::thumbnail() {
	QImage im = ui->ImageCanvas->croppedImage().convertToImage();
	im = im.smoothScale( 200, 200 );
	QPixmap pm;
	pm.convertFromImage( im );
	return pm;
}
示例#22
0
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;
}
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);
	}
}
示例#24
0
void FrameObject::loadImage(int frameIdx)
{
    // TODO:
    // this method gets called way too many times even
    // if just a single parameter was changed
    if (frameIdx==INT_INVALID || frameIdx >= numFrames())
    {
        p_displayImage = QPixmap();
        return;
    }

	if (p_source == NULL)
        return;

    // check if we have this frame index in our cache already
	CacheIdx cIdx(p_source->getName(), frameIdx);
    QPixmap* cachedFrame = frameCache.object(cIdx);
    if(cachedFrame == NULL)    // load the corresponding frame from yuv file into the frame buffer
    {
        // add new QPixmap to cache and use its data buffer
        cachedFrame = new QPixmap();

		if (p_source->pixelFormat() != YUVC_24RGBPixelFormat)
        {
            // read YUV444 frame from file - 16 bit LE words
			p_source->getOneFrame(&p_tmpBufferYUV444, frameIdx);

            // if requested, do some YUV math
            if( doApplyYUVMath() )
				applyYUVMath(&p_tmpBufferYUV444, p_width, p_height, p_source->pixelFormat());

            // convert from YUV444 (planar) - 16 bit words to RGB888 (interleaved) color format (in place)
			convertYUV2RGB(&p_tmpBufferYUV444, &p_PixmapConversionBuffer, YUVC_24RGBPixelFormat, p_source->pixelFormat());
        }
        else
        {
            // read RGB24 frame from file
			p_source->getOneFrame(&p_PixmapConversionBuffer, frameIdx);
        }

		if (p_PixmapConversionBuffer.size() == 0) {
			// Conversion failed. This can happen for example when the pixel format could not be determined.
			QString pixelFmtName = p_source->pixelFormatList()[p_source->pixelFormat()].name();
			QString errTxt = "Error converting image from pixel format type " + pixelFmtName + ".";
			setInfo(errTxt, true);
			p_displayImage = QPixmap();
			return;
		}

        // add this frame into our cache, use MBytes as cost
        int sizeInMB = p_PixmapConversionBuffer.size() >> 20;

        // Convert the image in p_PixmapConversionBuffer to a QPixmap
        QImage tmpImage((unsigned char*)p_PixmapConversionBuffer.data(),p_width,p_height,QImage::Format_RGB888);
        //QImage tmpImage((unsigned char*)p_PixmapConversionBuffer.data(),p_width,p_height,QImage::Format_RGB30);
        cachedFrame->convertFromImage(tmpImage);
		
		frameCache.insert(cIdx, cachedFrame, sizeInMB);
    }
示例#25
0
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 );
			}
	}
}
示例#26
0
/*!
  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( const QMimeSource* e, QPixmap& pm )
{
    QImage img;
    // We avoid dither, since the image probably came from this display
    if ( decode( e, img ) )
	return pm.convertFromImage( img, AvoidDither );
    return FALSE;
}
void ScreeniePixmapItem::updatePixmap(const QImage &image)
{
    QPixmap pixmap;
    pixmap.convertFromImage(image);
    setPixmap(pixmap);
    updateReflection();
    updateItemGeometry();
}
示例#28
0
QPixmap MainWindow::Mat2QPixmap(const Mat &mat)
{
    Mat rgb;
    QPixmap p;
    cvtColor(mat, rgb, CV_BGR2RGB);
    p.convertFromImage(QImage((const unsigned char*)(rgb.data), rgb.cols, rgb.rows, QImage::Format_RGB888));
    return p;
}
示例#29
0
void ButtonSettings::updateLabels()
{
    for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) {
        qCopInfo cip = ButtonUtils::inst()->messageToInfo ((*it)->m_pmsg );

        QPixmap pic;
        pic.convertFromImage( cip.m_icon.convertToImage().smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
        (*it)->m_picon->setPixmap ( pic );
        (*it)->m_plabel->setText ( cip.m_name );

        qCopInfo cih = ButtonUtils::inst()->messageToInfo ((*it)->m_hmsg );

        pic.convertFromImage( cih.m_icon.convertToImage().smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
        (*it)->m_hicon->setPixmap ( pic );
        (*it)->m_hlabel->setText ( cih.m_name );
    }
}
示例#30
0
void MainWindow::on_actionBinarization_manual_triggered()
{
    Dialogbinarization dialog;
    if (dialog.exec() == QDialog::Accepted)
    {
        QPixmap pixmap = pixmapItem->pixmap().copy();

        QRgb black = qRgb(0,0,0);
        QRgb white = qRgb(255,255,255);
        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;
                if (dialog.methodChosed() == 1)
                {
                    int treshold = dialog.treshold1();
                    if ( gray < treshold )
                        newColor = black;
                    else
                        newColor = white;
                }
                else if (dialog.methodChosed() == 2)
                {
                    int treshold = dialog.treshold1();
                    if ( gray > treshold )
                        newColor = black;
                    else
                        newColor = white;
                }
                else
                {
                    int treshold1 = dialog.treshold1();
                    int treshold2 = dialog.treshold2();
                    if ( treshold1 < gray && gray <= treshold2 )
                        newColor = black;
                    else
                        newColor = white;
                }
                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);
    }
}