本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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)));
}
示例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;
}
}
示例7: commitDrawing
void CollaborativeDrawingWidget::commitDrawing(QPicture drawingPictureData)
{
qWarning() << "commitDrawing size" << drawingPictureData.size();
BaseDrawingWidget::commitDrawing(drawingPictureData);
emit drawingCommited(m_currentSession, drawingPictureData);
}
示例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));
}
示例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);
}
示例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();
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}