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


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

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


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

示例1: on_radioGrayScale_clicked

void imageEnhanceDialog::on_radioGrayScale_clicked(bool checked)
{
    QByteArray data;
    QPixmap map;

    if(checked)
    {
        disableSliders();

        data = imageEditor->enhanceImage(imageFileName, 100,0,100);

        map.loadFromData(data, "XPM");
        enhanceDialog->rightImage->clear();
        enhanceDialog->rightImage->setPixmap(map);

        eType = grayScale;
    }
}
开发者ID:spnayak82,项目名称:timeLapseGen,代码行数:18,代码来源:timelapsegenmain.cpp

示例2: done

void MainWindow::done(bool ok)
{
    if(m_orgicons.size()){
        QPixmap flag;
        QByteArray raw = m_http->readAll();
        (m_orgicons.front().item)->setText(flag.loadFromData(raw,"JPG")?"success":"fail");
        ;
        (m_orgicons.front().item)->setIcon(QIcon(flag));


        m_orgicons.erase(m_orgicons.begin());
        if( m_orgicons.size() ){
            QUrl url(m_orgicons.front().url);
            m_http->setHost(url.host());
            m_http->get(url.path());
        }
    }
}
开发者ID:hunt978,项目名称:london2012,代码行数:18,代码来源:mainwindow.cpp

示例3: loadPictureData

void PictureLoader::loadPictureData(QNetworkReply *reply) {
    if (reply->error() != QNetworkReply::NoError) {
        qDebug("Network error; show some feedback");
        // TODO
        return;
    }

    const QByteArray data(reply->readAll());

    if (data.isEmpty()) {
        qDebug("No data!");
        return;
    }

    QPixmap pixmap;
    pixmap.loadFromData(data);
    emit pictureReady(pixmap);
}
开发者ID:esdrasbeleza,项目名称:BlzMovies,代码行数:18,代码来源:pictureloader.cpp

示例4: addStation

void Radio::addStation(const QString &nazwa, const QString &URL, const QString &groupName, const QByteArray &img)
{
	QListWidgetItem *lWI = new QListWidgetItem(nazwa);
	lWI->setData(Qt::UserRole, URL);
	lWI->setData(Qt::ToolTipRole, groupName);
	if (img.isEmpty())
		lWI->setIcon(qmp2Icon);
	else
	{
		QPixmap pix;
		pix.loadFromData(img);
		lWI->setIcon(pix);
	}
	if (groupName == wlasneStacje)
		lW->insertItem(lW->row(nowaStacjaLWI), lWI);
	else
		lW->addItem(lWI);
}
开发者ID:biddyweb,项目名称:QMPlay2,代码行数:18,代码来源:Radio.cpp

示例5: slotScreenshotAvailable

void MainUI::slotScreenshotAvailable(QNetworkReply *reply){
  qDebug() << "Screenshot retrieval finished:" << reply->error();
  if(reply->error() == QNetworkReply::NoError){
    QByteArray picdata = reply->readAll();
    QPixmap pix;
      pix.loadFromData(picdata);
    ui->label_app_screenshot->setText(""); //clear the text
    ui->label_app_screenshot->setPixmap( pix.scaled(ui->label_app_screenshot->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation) );
  }else{
    //Network error
    ui->label_app_screenshot->setText( tr("Could not load screenshot (network error)") );
  }
  //Now enable the prev/next buttons as necessary
  QStringList txt = ui->label_app_cScreen->text().split("/");
  if(txt.length()!=2){ return; } //invalid text for some reason
  if(txt[0]!="1"){ ui->tool_app_nextScreen->setEnabled(true); }
  if(txt[0] != txt[1]){ ui->tool_app_prevScreen->setEnabled(true); }
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例6: getOwnAvatar

void AvatarDefs::getOwnAvatar(QPixmap &avatar, const QString& defaultImage)
{
	unsigned char *data = NULL;
	int size = 0;

	/* get avatar */
	rsMsgs->getOwnAvatarData(data, size);

	if (size == 0) {
		avatar = QPixmap(defaultImage);
		return;
	}

	/* load image */
	avatar.loadFromData(data, size, "PNG") ;

	delete[] data;
}
开发者ID:G10h4ck,项目名称:RetroShare,代码行数:18,代码来源:AvatarDefs.cpp

示例7: QRect

void
KexiBlobTableEdit::setupContents(QPainter *p, bool focused, const QVariant& val,
                                 QString &txt, int &align, int &x, int &y_offset, int &w, int &h)
{
    Q_UNUSED(focused);
    Q_UNUSED(txt);
    Q_UNUSED(align);

//! @todo optimize: load to m_pixmap, downsize
    QPixmap pixmap;
    x = 0;
    w -= 1; //a place for border
    h -= 1; //a place for border
    if (p && val.canConvert(QVariant::ByteArray) && pixmap.loadFromData(val.toByteArray())) {
        KexiUtils::drawPixmap(*p, KexiUtils::WidgetMargins()/*lineWidth*/, QRect(x, y_offset, w, h),
                              pixmap, Qt::AlignCenter, true/*scaledContents*/, true/*keepAspectRatio*/);
    }
}
开发者ID:JeremiasE,项目名称:KFormula,代码行数:18,代码来源:kexiblobtableedit.cpp

示例8: dataChanged

void
SearchModel::bannerReceived(QtTvDB::Show *show, const QByteArray & data)
{
  int id;
  QPixmap pixmap;

  id = show->id();

  if (banners.contains(id))
    return ;

  pixmap.loadFromData(data);
  banners[id] = pixmap;
  //pixmap.scaled(QSize(256, 64), Qt::KeepAspectRatio, Qt::SmoothTransformation);

  QModelIndex idx = index(shows.indexOf(show));
  emit dataChanged(idx, idx);
}
开发者ID:jepaan,项目名称:serieswatcher,代码行数:18,代码来源:searchmodel.cpp

示例9: getTilePatch

/**
* @return image for temporarily replacing a tile that is downloading and currently unavailable
* The 'patch' is a subsection of an available tile from a lower zoom level.
* The algorithm tries to find a suitable tile starting from level zoom -1, until level 0.
* The higher the zoom level difference the more pixelated the patch will be.
*/
QPixmap cacaMap::getTilePatch(int zoom, quint32 x, quint32 y, int offx, int offy, int tsize)
{
	//dont go beyond level 0 and 
	//dont use patches smaller than 16 px. They are unintelligible anyways.
	if (zoom>0 && tsize>=16*2)
	{
		int parentx, parenty, offsetx, offsety;
		QString tileid;
		QPixmap patch;
		QString sz,sx,sy;
		parentx = x/2;
		parenty = y/2;
		sz.setNum(zoom-1);
		sx.setNum(parentx);
		sy.setNum(parenty);
		offsetx = offx/2 + (x%2)*tileSize/2;
		offsety = offy/2 + (y%2)*tileSize/2;
		tileid = sz+"."+sx+"."+sy;
		if (tileCache.contains(tileid))
		{
			//render the tile
			QDir::setCurrent(folder);
			QString path= getTilePath(zoom-1,parentx) ;
			QString fileName = servermgr.fileName(parenty);
			QDir::setCurrent(path);
			QFile f(fileName);
			if (f.open(QIODevice::ReadOnly))
			{
				patch.loadFromData(f.readAll());
				f.close();
				return patch.copy(offsetx,offsety,tsize/2,tsize/2).scaledToHeight(tileSize);
			}
			else
			{
				cout<<"no file found "<<path.toStdString()<<fileName.toStdString()<<endl;
			}
		}
		else
		{
			return getTilePatch(zoom-1,parentx,parenty,offsetx,offsety,tsize/2);
		}
	}
	return loadingAnim.currentPixmap();
}
开发者ID:FlavioFalcao,项目名称:cacaMap,代码行数:50,代码来源:cacamap.cpp

示例10: load

void ViewerWidget::load(const QByteArray &data)
{
    scene->clear();
    QList<QGraphicsItem *> items;
    QPixmap pixmap;
    if (pixmap.loadFromData(data)) {
        items << new QGraphicsPixmapItem(pixmap);
    }
    else if (data.startsWith("%PDF")) {
        fz_stream *stream = fz_open_memory(context, (unsigned char *)data.constData(), data.length());
        fz_document *doc = fz_open_document_with_stream(context, ".pdf", stream);
        fz_close(stream);
        int pagecount = fz_count_pages(doc);
        for (int i = 0; i < pagecount; i++) {
            fz_page *page = fz_load_page(doc, i);
            fz_rect bounds;
            fz_bound_page(doc, page, &bounds);
            fz_display_list *list = fz_new_display_list(context);
            fz_device *dev = fz_new_list_device(context, list);
            fz_run_page(doc, page, dev, &fz_identity, NULL);
            fz_free_device(dev);
            fz_free_page(doc, page);
            PageItem *item = new PageItem(context, list, bounds.x1 - bounds.x0, bounds.y1 - bounds.y0);
            item->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
            items << item;
        }
        fz_close_document(doc);
    } else {
        scene->setSceneRect(0, 0, 0, 0);
        return;
    }
    int top = 0;
    QPen outline(Qt::lightGray, 2, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
    outline.setCosmetic(true);
    foreach (QGraphicsItem *item, items) {
        QGraphicsRectItem *rim = new QGraphicsRectItem(item->boundingRect());
        item->setPos(0, top);
        rim->setPos(0, top);
        rim->setPen(outline);
        rim->setBrush(Qt::NoBrush);
        scene->addItem(rim);
        scene->addItem(item);
        top += item->boundingRect().height() + SPACING;
    }
开发者ID:EmmanuelOga,项目名称:even,代码行数:44,代码来源:viewerwidget.cpp

示例11: displayJPEG

void Widget::displayJPEG()
{
    disconnect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));

    QPixmap img;
    //    qDebug() << "jpegBA size: " << jpegBA.size();
    img.loadFromData(jpegBA);
    if(!img.isNull())
    {
        int w = ui->imgOutput->width();
        int h = ui->imgOutput->height();

        ui->imgOutput->setPixmap(img.scaled(w,h,Qt::KeepAspectRatio));
    }
    //        ui->imgOutput->setPixmap(img);
    imageReady=true;
    //    resizeImage();
    connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
}
开发者ID:shujaatak,项目名称:MintyRemote-MJPEG_Viewer,代码行数:19,代码来源:widget.cpp

示例12: setAvatar

void Core::setAvatar(uint8_t format, const QByteArray& data)
{
    if (tox_set_avatar(tox, format, (uint8_t*)data.constData(), data.size()) != 0)
    {
        qWarning() << "Core: Failed to set self avatar";
        return;
    }

    QPixmap pic;
    pic.loadFromData(data);
    Settings::getInstance().saveAvatar(pic, getSelfId().toString());
    emit selfAvatarChanged(pic);
    
    // Broadcast our new avatar!
    // according to tox.h, we need not broadcast this ourselves, but initial testing indicated elsewise
    const uint32_t friendCount = tox_count_friendlist(tox);;
    for (unsigned i=0; i<friendCount; i++)
        tox_send_avatar_info(tox, i);
}
开发者ID:tr37ion,项目名称:qTox,代码行数:19,代码来源:core.cpp

示例13: requestFinished

    void MapNetwork::requestFinished(void)
    {
	QNetworkReply *rep = (QNetworkReply *)sender();
	QPixmap pm;
	QString url;

	 // check if id is in map?
	if (!loadingMap.contains(rep))
	   return ;

	url = loadingMap[rep];
	loadingMap.remove(rep);

	if (pm.loadFromData(rep->readAll()))
	    parent->receivedImage(pm, url);

        if (loadingMap.isEmpty())
            parent->loadingQueueEmpty();
    }
开发者ID:iksaif,项目名称:lugdulov,代码行数:19,代码来源:mapnetwork.cpp

示例14: slotDownloadFinished

void MrmlView::slotDownloadFinished( const KURL& url, const QByteArray& data )
{
    QPtrListIterator<MrmlViewItem> it( m_items );
    for( ; it.current(); ++it ) {
        MrmlViewItem *item = it.current();
        if ( item->thumbURL() == url )
        {
            QPixmap p;
            if ( data.isEmpty() || !p.loadFromData( data ) )
                p = m_unavailablePixmap;

            m_pixmapCache.insert( url.url(), p );
            item->setPixmap( p );

            slotLayout();
            return;
        }
    }
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:19,代码来源:mrml_view.cpp

示例15: parse

void TexturesList::parse()
{
	clear();

	LBlockValuesList list = doc->getTexturesList();
	
	foreach(LBlockValues texture, list) {
		QString name = texture["name"];
		QString value = texture["value"];

		QByteArray array = QByteArray::fromBase64(value.toAscii());

		QPixmap pixmap;
		pixmap.loadFromData(array);

		QStandardItem *item = new QStandardItem(QIcon(pixmap), name);
		appendRow(item);
		items<<item;
	}
开发者ID:gja,项目名称:lblock,代码行数:19,代码来源:textureslist.cpp


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