本文整理汇总了C++中QPixmap::transformed方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::transformed方法的具体用法?C++ QPixmap::transformed怎么用?C++ QPixmap::transformed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPixmap
的用法示例。
在下文中一共展示了QPixmap::transformed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createCard
// Create turn animation, i.e. card combined out of backside and frontside
QPixmap CardSprite::createCard(const QPixmap &front, const QPixmap &back, int curNo, int count)
{
int halfCount = count/2;
// Turn the frontside of the card 0..90 degree
if (curNo < halfCount)
{
QMatrix m;
// Get an angle eps..90 deg for the values i is running
double angle = (double)curNo/(double)halfCount*90.0;
// Conversion to rad
angle = angle/180.0*M_PI;
// Scale pixmap to simulate rotating card
m.scale(cos(angle), 1.0);
QPixmap pm = front.transformed(m, Qt::SmoothTransformation);
return pm;
}
// Turn the backside of the card 90..eps degree
else
{
QMatrix m;
// Get an angle 0..90 deg for the values i is running
double angle = 90.0-((double)(curNo-halfCount+1)/(double)halfCount*90.0);
// Conversion to rad
angle = angle/180.0*M_PI;
// Scale pixmap to simulate rotating card
m.scale(cos(angle), 1.0);
QPixmap pm = back.transformed(m, Qt::SmoothTransformation);
return pm;
}
}
示例2: createThumbnail
void TsEnv::createThumbnail(const QPixmap& source,
int angle,
const void* userData)
{
try {
QPixmap thumbnailSource;
const Qt::Axis rotationAxis(Qt::ZAxis);
if ( 270 <= angle ) {
thumbnailSource = source.transformed(QTransform().rotate(270.0f,
rotationAxis),
Qt::SmoothTransformation);
} else if( 180 <= angle ) {
thumbnailSource = source.transformed(QTransform().rotate(180.0f,
rotationAxis),
Qt::SmoothTransformation);
} else if( 90 <= angle ) {
thumbnailSource = source.transformed(QTransform().rotate(90.0f,
rotationAxis),
Qt::SmoothTransformation);
} else {
thumbnailSource = source;
}
const QRect expectedRect(0, 0, thumbnailWidth, thumbnailHeight);
const QPixmap thumbanail(thumbnailSource.scaled(expectedRect.size(),
Qt::KeepAspectRatioByExpanding,
Qt::SmoothTransformation));
emit thumbnailCreated(thumbanail.copy(expectedRect), userData);
} catch (...) {
}
}
示例3: applyEffects
QPixmap Icon::applyEffects() const
{
QPixmap gfx = pixmap;
if (isColor && !qFuzzyIsNull(depth)) {
QLabel w;
QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect();
effect->setColor(color);
effect->setStrength(depth);
w.setPixmap(gfx);
w.setGraphicsEffect(effect);
gfx = w.grab();
}
if (!qFuzzyIsNull(radius)) {
QImage canvas(gfx.size(), QImage::Format_ARGB32_Premultiplied);
QPainter painter(&canvas);
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.fillRect(gfx.rect(), Qt::transparent);
painter.setPen(Qt::NoPen);
painter.setBrush(QBrush(gfx));
painter.setRenderHint(QPainter::Antialiasing);
painter.drawRoundedRect(gfx.rect(), radius, radius);
painter.end();
gfx = QPixmap::fromImage(canvas);
}
if (blur > 1.0) {
QLabel w;
QGraphicsBlurEffect *effect = new QGraphicsBlurEffect();
effect->setBlurRadius(blur);
effect->setBlurHints(QGraphicsBlurEffect::QualityHint);
w.setPixmap(gfx);
w.setGraphicsEffect(effect);
gfx = w.grab();
}
if (flipX) {
gfx = gfx.transformed(QTransform().scale(-1, 1));
}
if (flipY) {
gfx = gfx.transformed(QTransform().scale(1, -1));
}
if (angle != 0) {
gfx = gfx.transformed(QTransform().rotate(angle));
}
return gfx;
}
示例4: p
GameWidget::GameWidget(QWidget *parent)
:QLabel(parent), m_gunX(32), m_shipXHeading(1), m_soser(250, 65)
{
srand(QDateTime::currentDateTime().toTime_t());
m_shipTimeInt = 200.0;
m_shottimer = new QTimer(this);
connect(m_shottimer, SIGNAL(timeout()), this, SLOT(shotTimeout()));
m_shottimer->start(30);
m_shiptimer = new QTimer(this);
connect(m_shiptimer, SIGNAL(timeout()), this, SLOT(shipTimeout()));
m_shiptimer->start((int)m_shipTimeInt);
m_soserShowTimer = new QTimer(this);
connect(m_soserShowTimer, SIGNAL(timeout()), this, SLOT(soserShowTimeout()));
m_soserShowTimer->setSingleShot(false);
int tm = (((rand() % 6) + 5) * 1000);
m_soserShowTimer->start(tm);
m_soserMoveTimer = new QTimer(this);
connect(m_soserMoveTimer, SIGNAL(timeout()), this, SLOT(soserMoveTimeout()));
m_levelFinTimer = new QTimer(this);
connect(m_levelFinTimer, SIGNAL(timeout()), this, SLOT(levelFinTimeout()));
setMouseTracking(true);
// draw soser pixmap
m_soser.fill(Qt::transparent);
QPainter p(&m_soser);
QPixmap a = PicBucket::instance().getPic(4, 0).pixmap;
QPixmap b = PicBucket::instance().getPic(4, 3).pixmap;
p.drawPixmap(0, 0, a);
p.drawPixmap(51, 0, b.transformed(QMatrix().rotate(270), Qt::SmoothTransformation).transformed(
QMatrix(QMatrix(1, 0, 0, -1, 0, 0)), Qt::SmoothTransformation)); // flip it, looks better
p.drawPixmap(102, 0, b);
p.drawPixmap(153, 0, a.transformed(QMatrix(-1, 0, 0, 1, 0, 0), Qt::SmoothTransformation));
p.end();
m_soser = m_soser.scaled(QSize(170, 43), Qt::KeepAspectRatio, Qt::SmoothTransformation);
m_soserMask = QRegion(m_soser.mask());
m_score = 0;
m_level = 1;
m_lives = 3;
m_soserX = 0;
sizeY = 9999;
loadScores();
initLevel(m_level);
}
示例5: on_pushButton_clicked
//Rotate the left/right image function
void HelloGUIWorld::on_pushButton_clicked() {
QPixmap pixmapLeft = *ui.leftImage->pixmap();
QPixmap pixmapRight = *ui.rightImage->pixmap();
QMatrix imageRotationMatrix;
imageRotationMatrix.rotate(90);
pixmapLeft = pixmapLeft.transformed(imageRotationMatrix);
pixmapRight = pixmapRight.transformed(imageRotationMatrix);
ui.leftImage->setPixmap(pixmapLeft);
ui.rightImage->setPixmap(pixmapRight);
}
示例6: updateStandardIcons
void pDockWidgetTitleBar::updateStandardIcons()
{
const QSize size( 16, 16 );
QPixmap pixmap;
QRect rect( QPoint(), iconSize() );
QTransform transform;
transform.rotate( 90 );
pixmap = style()->standardIcon( QStyle::SP_ToolBarHorizontalExtensionButton, 0, widgetForAction( aOrientation ) ).pixmap( size );
rect.moveCenter( pixmap.rect().center() );
pixmap = pixmap.copy( rect );
pixmap = pixmap.transformed( transform, Qt::SmoothTransformation );
aOrientation->setIcon( pixmap );
pixmap = style()->standardIcon( QStyle::SP_TitleBarNormalButton, 0, widgetForAction( aFloat ) ).pixmap( size );
rect.moveCenter( pixmap.rect().center() );
pixmap = pixmap.copy( rect );
aFloat->setIcon( pixmap );
pixmap = style()->standardIcon( QStyle::SP_TitleBarCloseButton, 0, widgetForAction( aClose ) ).pixmap( size );
rect.moveCenter( pixmap.rect().center() );
pixmap = pixmap.copy( rect );
aClose->setIcon( pixmap );
}
示例7: mirror_notRunning
void tst_qsganimatedimage::mirror_notRunning()
{
QFETCH(QUrl, fileUrl);
QSGView *canvas = new QSGView;
canvas->show();
canvas->setSource(fileUrl);
QSGAnimatedImage *anim = qobject_cast<QSGAnimatedImage *>(canvas->rootObject());
QVERIFY(anim);
int width = anim->property("width").toInt();
QPixmap screenshot = canvas->renderPixmap();
QTransform transform;
transform.translate(width, 0).scale(-1, 1.0);
QPixmap expected = screenshot.transformed(transform);
int frame = anim->currentFrame();
bool playing = anim->isPlaying();
bool paused = anim->isPlaying();
anim->setProperty("mirror", true);
screenshot = canvas->renderPixmap();
QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved", SkipSingle);
QCOMPARE(screenshot, expected);
// mirroring should not change the current frame or playing status
QCOMPARE(anim->currentFrame(), frame);
QCOMPARE(anim->isPlaying(), playing);
QCOMPARE(anim->isPaused(), paused);
delete canvas;
}
示例8: writePicture
void QTextDocumentExporter::writePicture(cf::CEDPicture& pic) {
if(!pic.image()) {
qDebug() << Q_FUNC_INFO << "empty image given";
return;
}
if(!page_) {
qDebug() << Q_FUNC_INFO << "NULL page pointer";
return;
}
QPixmap pixmap;
QTransform t = QTransform().rotate(page_->angle());
ImageCache::load(page_->imageURL(), &pixmap);
cf::Rect r = pic.boundingRect();
pixmap = pixmap.transformed(t);
pixmap = pixmap.copy(r.x(), r.y(), r.width(), r.height());
static int image_counter = 0;
cursor_.insertImage(pixmap.toImage(), QString("image %1").arg(++image_counter));
// QTextFrameFormat format;
// cursor_.currentFrame()->setFrameFormat(format);
}
示例9: modifiedIcon
CategorieButton::CategorieButton(QPixmap icon, QString name, QWidget *parent) : QWidget(parent) // This widget shows the icon and name of a menu's categorie
{
resize(100, 100);
isHovered = false;
m_iconLabel = new QLabel(this);
m_iconLabel->resize(size());
m_iconLabel->setAlignment(Qt::AlignCenter);
QPixmap modifiedIcon(48, 100);
modifiedIcon.fill(Qt::transparent);
QPainter p(&modifiedIcon);
p.drawPixmap(0, 2, 48, 48, icon);
QTransform t;
p.drawPixmap(0, 50, 48, 48, icon.transformed(t.rotate(180, Qt::XAxis), Qt::SmoothTransformation));
QLinearGradient alphaGradient(0, 0, 0, height());
alphaGradient.setColorAt(0.0, Qt::black);
alphaGradient.setColorAt(0.5, Qt::black);
alphaGradient.setColorAt(0.8, Qt::transparent);
QGraphicsOpacityEffect *iconEffect = new QGraphicsOpacityEffect(this);
iconEffect->setOpacity(1);
iconEffect->setOpacityMask(alphaGradient);
m_iconLabel->setPixmap(modifiedIcon);
m_iconLabel->setGraphicsEffect(iconEffect);
m_nameLabel = new QLabel(name, this);
m_nameLabel->setStyleSheet("color: white;");
QGraphicsDropShadowEffect *nameEffect = new QGraphicsDropShadowEffect();
nameEffect->setOffset(1);
nameEffect->setColor(Qt::black);
m_nameLabel->setGraphicsEffect(nameEffect);
m_nameLabel->setAlignment(Qt::AlignCenter);
m_nameLabel->setGeometry(0, 60, width(), m_nameLabel->height());
}
示例10: getPixmap
QPixmap
View::getPixmapForTile( std::string const & inTileId, View::Rotation inRotation )
{
QPixmap const pixmap = getPixmap( inTileId );
QTransform rotation = QTransform();
rotation.rotate( getAngle( inRotation ) );
return pixmap.transformed( rotation );
}
示例11: drawProgress
void StylePainterMobile::drawProgress(const QRect& rect, double progress, bool leftToRight, bool animated, bool vertical) const
{
const int horizontalBorder = (vertical ? rect.width() / 4 : 0);
const int verticalBorder = (vertical ? 0 : rect.height() / 4);
const QRect targetRect = rect.adjusted(horizontalBorder, verticalBorder, -horizontalBorder, -verticalBorder);
QPixmap result;
QSize imageSize = sizeForPainterScale(targetRect);
if (vertical)
qSwap(imageSize.rheight(), imageSize.rwidth());
KeyIdentifier id;
id.type = KeyIdentifier::Progress;
id.width = imageSize.width();
id.height = imageSize.height();
id.trait1 = animated;
id.trait2 = (!animated && !leftToRight);
id.trait3 = progress * 100;
if (!findCachedControl(id, &result)) {
if (imageSize.isNull())
return;
result = QPixmap(imageSize);
result.fill(Qt::transparent);
QPainter painter(&result);
painter.setRenderHint(QPainter::Antialiasing);
QRect progressRect(QPoint(0, 0), imageSize);
qreal radius = radiusFactor * progressRect.height();
painter.setBrush(Qt::NoBrush);
painter.setPen(borderPen());
progressRect.adjust(1, 1, -1, -1);
painter.drawRoundedRect(progressRect, radius, radius);
progressRect.adjust(1, 1, -1, -1);
if (animated) {
const int right = progressRect.right();
const int startPos = right * (1 - progressBarChunkPercentage) * 2 * fabs(progress - 0.5);
progressRect.setWidth(progressBarChunkPercentage * right);
progressRect.moveLeft(startPos);
} else {
progressRect.setWidth(progress * progressRect.width());
if (!leftToRight)
progressRect.moveRight(imageSize.width() - 2);
}
if (progressRect.width() > 0) {
QLinearGradient gradient;
gradient.setStart(progressRect.bottomLeft());
gradient.setFinalStop(progressRect.topLeft());
gradient.setColorAt(0.0, highlightColor);
gradient.setColorAt(1.0, highlightColor.lighter());
painter.setBrush(gradient);
painter.setPen(Qt::NoPen);
radius = radiusFactor * progressRect.height();
painter.drawRoundedRect(progressRect, radius, radius);
}
insertIntoCache(id, result);
}
QTransform transform;
transform.rotate(-90);
painter->drawPixmap(targetRect, vertical ? result.transformed(transform) : result);
}
示例12: transformed
void tst_QPixmap::transformed()
{
QFETCH(QSize, size);
QFETCH(QTransform, transform);
QFETCH(Qt::TransformationMode, transformMode);
QPixmap opaque = rasterPixmap(size);
QPixmap transparent = rasterPixmap(size);
opaque.fill(QColor(255, 0, 0));
transparent.fill(QColor(255, 0, 0, 200));
QPixmap transformed1;
QPixmap transformed2;
QBENCHMARK {
transformed1 = opaque.transformed(transform, transformMode);
transformed2 = transparent.transformed(transform, transformMode);
}
}
示例13: rotateIcon
QIcon UserWidget::rotateIcon(QIcon ico){
//Rotate the given icon to appear vertical in the tab widget
QPixmap pix = ico.pixmap(32,32);
QTransform tran;
tran.rotate(+90); //For tabs on the left/West
pix = pix.transformed(tran);
ico = QIcon(pix);
return ico;
}
示例14: render
void Player::render(QPainter *p)
{
QPixmap* tx = texIndex > 8 ? texture1 : texture2;
QPixmap tex = tx->transformed(QTransform()
.translate(-width/2, -height/2)
.rotate(dir*90)
.translate(width/2, height/2));
p->drawPixmap(getX() + getMap()->offsetX, getY() + getMap()->offsetY, tex);
}
示例15: adjustBrush
QBrush DBrushAdjuster::adjustBrush(const QBrush &brush, const QRect &rect )
{
QBrush brush1(brush);
if(brush.gradient())
{
QGradient grad = DGradientAdjuster::adjustGradient( brush.gradient(), rect );
brush1 = QBrush(grad);
}
else if(!brush.texture().isNull())
{
QPixmap p = (brush.texture()/*.toImage ()*/);
int offset= 0;
QRect br = p.rect();
QMatrix matrix;
float sx = 1, sy = 1;
if ( rect.width() < br.width() )
{
sx = static_cast<float>(rect.width()-offset) / static_cast<float>(br.width());
}
if ( rect.height() < br.height() )
{
sy = static_cast<float>(rect.height()-offset) / static_cast<float>(br.height());
}
float factor = qMin(sx, sy);
matrix.scale(sx, sy);
p = p.transformed(matrix ,Qt::SmoothTransformation );
matrix.reset();
QPointF pos = br.topLeft();
float tx = offset/2-pos.x(), ty = offset/2-pos.y();
matrix.translate(tx, ty);
p = p.transformed(matrix ,Qt::SmoothTransformation );
// brush1 = QBrush(p);
brush1.setTexture ( p );
}
return brush1;
}