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


C++ QPicture类代码示例

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


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

示例1: loadThemeFromBlob

bool loadThemeFromBlob(const QString &themeBlob,
    QHash<QString, QPicture> &partPictures,
    QHash<QPair<QString, int>, QColor> &colors)
{
    QFile blob(themeBlob);
    if (!blob.open(QIODevice::ReadOnly)) {
        qWarning() << __FUNCTION__ << ": Could not read blob: " << themeBlob;
        return false;
    }
    QDataStream blobIn(&blob);

    quint32 version;
    blobIn >> version;

    if (version != blobVersion) {
        qWarning() << __FUNCTION__ << ": Invalid blob version: " << version << " ...expected: " << blobVersion;
        return false;
    }

    QByteArray data;
    blobIn >> data;
    data = qUncompress(data);
    QBuffer dataBuffer(&data);
    dataBuffer.open(QIODevice::ReadOnly);
    QDataStream dataIn(&dataBuffer);

    int colorsCount;
    dataIn >> colorsCount;
    for (int i = 0; i < colorsCount; ++i) {
        QPair<QString, int> key;
        dataIn >> key;
        QColor value;
        dataIn >> value;
        colors.insert(key, value);
    }

    int picturesCount;
    dataIn >> picturesCount;
    for (int i = 0; i < picturesCount; ++i) {
        QString key;
        dataIn >> key;
        QPicture value;
        dataIn >> value;
        value.setBoundingRect(QRect(0, 0, pictureSize, pictureSize)); // Bug? The forced bounding rect was not deserialized.
        partPictures.insert(key, value);
    }

    if (dataIn.status() != QDataStream::Ok) {
        qWarning() << __FUNCTION__ << ": Invalid data blob: " << themeBlob;
        return false;
    }
    return true;
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:53,代码来源:qs60style_simulated.cpp

示例2: Q_UNUSED

QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, const QSize &size,
                               QPainter *painter, QS60StylePrivate::SkinElementFlags flags)
{
    Q_UNUSED(painter);

    const QString partKey = QS60Style::partKeys().at(part);
    const QPicture partPicture = QS60StyleModeSpecifics::m_partPictures.value(partKey);
    QSize partSize(partPicture.boundingRect().size());
    if (flags & (SF_PointEast | SF_PointWest)) {
        const int temp = partSize.width();
        partSize.setWidth(partSize.height());
        partSize.setHeight(temp);
    }
    const qreal scaleX = size.width() / (qreal)partSize.width();
    const qreal scaleY = size.height() / (qreal)partSize.height();

    QImage partImage(size, QImage::Format_ARGB32);
    partImage.fill(Qt::transparent);
    QPainter resultPainter(&partImage);
    QTransform t;

    if (flags & SF_PointEast)
        t.translate(size.width(), 0);
    else if (flags & SF_PointSouth)
        t.translate(size.width(), size.height());
    else if (flags & SF_PointWest)
        t.translate(0, size.height());

    t.scale(scaleX, scaleY);

    if (flags & SF_PointEast)
        t.rotate(90);
    else if (flags & SF_PointSouth)
        t.rotate(180);
    else if (flags & SF_PointWest)
        t.rotate(270);

    resultPainter.setTransform(t, true);
    const_cast<QPicture *>(&partPicture)->play(&resultPainter);
    resultPainter.end();

    QPixmap result = QPixmap::fromImage(partImage);
    if (flags & SF_StateDisabled) {
        QStyleOption opt;
        QPalette *themePalette = QS60StylePrivate::themePalette();
        if (themePalette)
            opt.palette = *themePalette;
        result = QApplication::style()->generatedIconPixmap(QIcon::Disabled, result, &opt);
    }

    return result;
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:52,代码来源:qs60style_simulated.cpp

示例3: toImage

bool QGraph::toImage(QString path){
	if(!path.isEmpty() && path.endsWith(".svg")) {
		QPicture pic;
		QPainter  p;
		
		pintafunc(&pic);
		pic.save(path, "svg");
	} else if(!path.isEmpty() && path.endsWith(".png")) {
		front.save(path, "PNG");
	} else
		return false;
	
	return true;
}
开发者ID:BackupTheBerlios,项目名称:kalgebra-svn,代码行数:14,代码来源:qgraph.cpp

示例4: Q_D

bool QPreviewPaintEngine::begin(QPaintDevice *)
{
    Q_D(QPreviewPaintEngine);

    qDeleteAll(d->pages);
    d->pages.clear();

    QPicture *page = new QPicture;
    page->d_func()->in_memory_only = true;
    d->painter = new QPainter(page);
    d->engine = d->painter->paintEngine();
    d->pages.append(page);
    d->state = QPrinter::Active;
    return true;
}
开发者ID:maxxant,项目名称:qt,代码行数:15,代码来源:qpaintengine_preview.cpp

示例5: ensureSerializesCorrectly

void ensureSerializesCorrectly(const QPicture &picture, QDataStream::Version version)
 {
    QDataStream stream;

    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly);
    stream.setDevice(&buffer);
    stream.setVersion(version);
    stream << picture;
    buffer.close();

    buffer.open(QIODevice::ReadOnly);
    QPicture readpicture;
    stream >> readpicture;
    QVERIFY2(memcmp(picture.data(), readpicture.data(), picture.size()) == 0,
        qPrintable(QString::fromLatin1("Picture data does not compare equal for QDataStream version %1").arg(version)));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:17,代码来源:tst_qpicture.cpp

示例6: QPicture

/** Draws the section base objects to the specified painter & x/y offsets */
void MReportSection::drawHeaderObjects( FLStylePainter *p, MPageCollection *pages, MReportSection * header ) {
  MCalcObject * calcfield;

  // Set the offsets
  int xcalc = header->getLastXOffset();
  int ycalc = header->getLastYOffset();

  QPicture * currentPage = ( QPicture * ) p->painter()->device();
  QPicture * lastPage = header->onPage();
  QPicture * currentPageCopy = 0;
  QPicture * lastPageCopy = 0;

  if ( currentPage != lastPage ) {
    p->painter()->end();
    currentPageCopy = new QPicture( *currentPage );
    lastPageCopy = new QPicture( *lastPage );
    p->painter()->begin( lastPage );
    lastPageCopy->play( p->painter() );
  }

  QObject::setName( QString( "_##H%1-%2" ).arg( strIdSec_ ).arg( level ) );
  p->beginSection( xcalc, ycalc, width, height, this );
  uint countObj = 0;

  // Draw the calculated field collection
  for ( calcfield = calculatedFields.first(); calcfield != 0;
        calcfield = calculatedFields.next() ) {
    if ( calcfield->getDrawAtHeader() ) {
      calcfield->QObject::setName( QString( "_##H%1-Calc.%2-%3" ).arg( idSec_ ).arg( calcfield->fieldName ).arg( countObj++ ) );
      p->beginMark( calcfield->getX(), calcfield->getY(), calcfield );
      calcfield->draw( p );
      p->endMark();
    }
  }

  p->endSection();

  if ( currentPage != lastPage ) {
    p->painter()->end();
    p->painter()->begin( currentPage );
    currentPageCopy->play( p->painter() );
    delete lastPageCopy;
    delete currentPageCopy;
  }
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:46,代码来源:mreportsection.cpp

示例7: commitDrawing

void CollaborativeDrawingWidget::commitDrawing(QPicture drawingPictureData)
{
    qWarning() << "commitDrawing size" << drawingPictureData.size();

    BaseDrawingWidget::commitDrawing(drawingPictureData);

    emit drawingCommited(m_currentSession, drawingPictureData);

}
开发者ID:abom,项目名称:watchntouch,代码行数:9,代码来源:collaborativedrawingwidget.cpp

示例8: commitDrawing

void BaseDrawingWidget::commitDrawing(QPicture drawingPictureData)
{
    getDrawingData()->registerAction(drawingPictureData);
    getDrawingData()->setModified(true);
    // update the stage
    getDrawingData()->update(drawingPictureData.boundingRect().adjusted(-drawingPen.width()-5,
                                                         -drawingPen.width()-5,
                                                         drawingPen.width()+5,
                                                         drawingPen.width()+5));
}
开发者ID:abom,项目名称:watchntouch,代码行数:10,代码来源:basedrawingwidget.cpp

示例9: drawingArrived

void CollaborativeDrawingWidget::drawingArrived(QString sessionName, QByteArray picData, bool isInitialState)
{
    // this slot will be invoked when the user joins a new session and the server
    // sends the current drawing state for this session
    QPicture pic;
    qWarning() << "Session state data of size : " << picData.size() << "from session" << sessionName;
    if(isInitialState) {
        // set the session name
        m_currentSession = sessionName;
        // clear up any old data
        getDrawingData()->clear();
        // the widget should be enabled now
        setEnabled(true);
    }
    pic.setData(picData.constData(), picData.size());

    // commit the new data
    BaseDrawingWidget::commitDrawing(pic);
}
开发者ID:abom,项目名称:watchntouch,代码行数:19,代码来源:collaborativedrawingwidget.cpp

示例10: QPicture

void QgsSvgCache::cachePicture( QgsSvgCacheEntry *entry, bool forceVectorOutput )
{
  if ( !entry )
  {
    return;
  }

  delete entry->picture;
  entry->picture = 0;

  //correct QPictures dpi correction
  QPicture* picture = new QPicture();
  QRectF rect;
  QSvgRenderer r( entry->svgContent );
  double hwRatio = 1.0;
  if ( r.viewBoxF().width() > 0 )
  {
    hwRatio = r.viewBoxF().height() / r.viewBoxF().width();
  }
  bool drawOnScreen = qgsDoubleNear( entry->rasterScaleFactor, 1.0, 0.1 );
  if ( drawOnScreen && forceVectorOutput ) //forceVectorOutput always true in case of composer draw / composer preview
  {
    // fix to ensure rotated symbols scale with composer page (i.e. not map item) zoom
    double wSize = entry->size;
    double hSize = wSize * hwRatio;
    QSizeF s( r.viewBoxF().size() );
    s.scale( wSize, hSize, Qt::KeepAspectRatio );
    rect = QRectF( -s.width() / 2.0, -s.height() / 2.0, s.width(), s.height() );
  }
  else
  {
    // output for print or image saving @ specific dpi
    double scaledSize = entry->size / 25.4 / ( entry->rasterScaleFactor * entry->widthScaleFactor );
    double wSize = scaledSize * picture->logicalDpiX();
    double hSize = scaledSize * picture->logicalDpiY() * r.viewBoxF().height() / r.viewBoxF().width();
    rect = QRectF( QPointF( -wSize / 2.0, -hSize / 2.0 ), QSizeF( wSize, hSize ) );
  }

  QPainter p( picture );
  r.render( &p, rect );
  entry->picture = picture;
  mTotalSize += entry->picture->size();
}
开发者ID:ColeCummins,项目名称:QGIS,代码行数:43,代码来源:qgssvgcache.cpp

示例11: tr

void FLReportViewer::saveSVGStyle()
{
  if (report) {
    QString fileName = QFileDialog::getSaveFileName("", tr("Fichero SVG (*.svg)"), this, tr("Guardar en SVG"),
                                                    tr("Guardar en SVG"));
    if (fileName.isEmpty())
      return;

    if (!fileName.upper().contains(".SVG"))
      fileName += ".svg";
    if (QFile::exists(fileName)
        && QMessageBox::question(this, tr("Sobreescribir %1").arg(fileName),
                                 tr("Ya existe un fichero llamado %1. ¿ Desea sobreescribirlo ?").arg(fileName),
                                 tr("&Sí"), tr("&No"), QString::null, 0, 1))
      return;

    FLStylePainter::setSVGMode(true);
    updateReport();
    FLStylePainter::setSVGMode(false);

    QStringList fileNames;
    QString fname;
    QPicture *page;
    QSize psize;
    for (int i = 0; i < report->pageCount(); ++i) {
      fname = fileName + QString::number(i);
      fileNames.append(fname);
      page = report->getPageAt(i);
      psize = report->pageDimensions();
      page->setBoundingRect(QRect(QPoint(0, 0), psize));
      page->save(fname, "svg");
    }

    FLStylePainter::normalizeSVGFile(fileName, fileNames);

    updateReport();
  }
}
开发者ID:afibanez,项目名称:eneboo,代码行数:38,代码来源:FLReportViewer.cpp

示例12: locker

QPicture QgsSvgCache::svgAsPicture( const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth,
                                    double widthScaleFactor, bool forceVectorOutput, double fixedAspectRatio )
{
  QMutexLocker locker( &mMutex );

  QgsSvgCacheEntry *currentEntry = cacheEntry( path, size, fill, stroke, strokeWidth, widthScaleFactor, fixedAspectRatio );

  //if current entry picture is 0: cache picture for entry
  //update stats for memory usage
  if ( !currentEntry->picture )
  {
    cachePicture( currentEntry, forceVectorOutput );
    trimToMaximumSize();
  }

  QPicture p;
  // For some reason p.detach() doesn't seem to always work as intended, at
  // least with QT 5.5 on Ubuntu 16.04
  // Serialization/deserialization is a safe way to be ensured we don't
  // share a copy.
  p.setData( currentEntry->picture->data(), currentEntry->picture->size() );
  return p;
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:23,代码来源:qgssvgcache.cpp

示例13: FLPosPrinter

bool MReportViewer::printPosReport()
{
  if (report == 0)
    return false;

  posprinter = new FLPosPrinter();
  posprinter->setPaperWidth((FLPosPrinter::PaperWidth) report->pageSize());
  posprinter->setPrinterName(printerName_);

  QPicture *page;
  QPainter painter;
  bool printRev = false;

  int viewIdx = report->getCurrentIndex();

  int printCopies = numCopies_;

  painter.begin(posprinter);
  QPaintDeviceMetrics pdm(posprinter);
  QSize dim(report->pageDimensions());
  painter.setWindow(0, 0, dim.width(), dim.height());
  painter.setViewport(0, 0, pdm.width(), pdm.height());

  for (int j = 0; j < printCopies; j++) {
    report->setCurrentPage(1);
    page = report->getCurrentPage();
    page->play(&painter);
  }

  painter.end();
  report->setCurrentPage(viewIdx);

  delete posprinter;

  return true;
}
开发者ID:Miguel-J,项目名称:eneboo-core,代码行数:36,代码来源:mreportviewer.cpp

示例14: registerAction

void DrawingData::registerAction(QPicture actions)
{
    QRect boundingRect = actions.boundingRect().adjusted(-2,-2,2,2);
    // fix negative / too large coordinates
    if(boundingRect.x() < 0)
        boundingRect.setX(0);
    if(boundingRect.y() < 0)
        boundingRect.setY(0);
    if(boundingRect.x() > width())
        boundingRect.setX(width());
    if(boundingRect.y() > height())
        boundingRect.setY(height());
    // backup the area to be painted, to be used for undo'ing later
    QPixmap areaToChange = QPixmap::fromImage(stage.copy(boundingRect));
    // set the properties of this drawing step for undo/redo
    currentAction->setActions(actions);
    currentAction->setPrevPixmap(areaToChange, boundingRect);
    // add to the undo stack
    undoStack.push(currentAction);
    currentAction =  new DrawingAction(this);
}
开发者ID:abom,项目名称:watchntouch,代码行数:21,代码来源:drawingdata.cpp

示例15: QPicture

void QgsSvgCache::cachePicture( QgsSvgCacheEntry *entry )
{
  if ( !entry )
  {
    return;
  }

  delete entry->picture;
  entry->picture = 0;

  //correct QPictures dpi correction
  QPicture* picture = new QPicture();
  double pictureSize = entry->size  /  25.4 / ( entry->rasterScaleFactor * entry->widthScaleFactor )  * picture->logicalDpiX();
  QRectF rect( QPointF( -pictureSize / 2.0, -pictureSize / 2.0 ), QSizeF( pictureSize, pictureSize ) );


  QSvgRenderer renderer( entry->svgContent );
  QPainter painter( picture );
  renderer.render( &painter, rect );
  entry->picture = picture;
  mTotalSize += entry->picture->size();
}
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:22,代码来源:qgssvgcache.cpp


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