本文整理汇总了C++中QPixmap::hasAlphaChannel方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::hasAlphaChannel方法的具体用法?C++ QPixmap::hasAlphaChannel怎么用?C++ QPixmap::hasAlphaChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPixmap
的用法示例。
在下文中一共展示了QPixmap::hasAlphaChannel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: centerPixmaps
void centerPixmaps(QPixmap &from, QPixmap &to)
{
if (from.size() == to.size() && from.hasAlphaChannel() && to.hasAlphaChannel()) {
return;
}
QRect fromRect(from.rect());
QRect toRect(to.rect());
QRect actualRect = QRect(QPoint(0,0), fromRect.size().expandedTo(toRect.size()));
fromRect.moveCenter(actualRect.center());
toRect.moveCenter(actualRect.center());
if (from.size() != actualRect.size() || !from.hasAlphaChannel()) {
QPixmap result(actualRect.size());
result.fill(Qt::transparent);
QPainter p(&result);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.drawPixmap(fromRect.topLeft(), from);
p.end();
from = result;
}
if (to.size() != actualRect.size() || !to.hasAlphaChannel()) {
QPixmap result(actualRect.size());
result.fill(Qt::transparent);
QPainter p(&result);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.drawPixmap(toRect.topLeft(), to);
p.end();
to = result;
}
}
示例2: setPixmap
// The image must not have format 8888 pre multiplied...
void ImageFrame::setPixmap(const QPixmap& pixmap)
{
m_pixmap = pixmap;
m_image = QImage();
m_size = pixmap.size();
m_hasAlpha = pixmap.hasAlphaChannel();
}
示例3: QImage
// The image must not have format 8888 pre multiplied...
void RGBA32Buffer::setPixmap(const QPixmap& pixmap)
{
m_pixmap = pixmap;
m_image = QImage();
m_size = pixmap.size();
m_hasAlpha = pixmap.hasAlphaChannel();
}
示例4: drawTiledPixmap
/*!
Reimplement this function to draw the \a pixmap in the given \a
rect, starting at the given \a p. The pixmap will be
drawn repeatedly until the \a rect is filled.
*/
void QPaintEngine::drawTiledPixmap(const QRectF &rect, const QPixmap &pixmap, const QPointF &p)
{
int sw = pixmap.width();
int sh = pixmap.height();
if (sw*sh < 8192 && sw*sh < 16*rect.width()*rect.height()) {
int tw = sw, th = sh;
while (tw*th < 32678 && tw < rect.width()/2)
tw *= 2;
while (tw*th < 32678 && th < rect.height()/2)
th *= 2;
QPixmap tile;
if (pixmap.depth() == 1) {
tile = QBitmap(tw, th);
} else {
tile = QPixmap(tw, th);
if (pixmap.hasAlphaChannel())
tile.fill(Qt::transparent);
}
qt_fill_tile(&tile, pixmap);
qt_draw_tile(this, rect.x(), rect.y(), rect.width(), rect.height(), tile, p.x(), p.y());
} else {
qt_draw_tile(this, rect.x(), rect.y(), rect.width(), rect.height(), pixmap, p.x(), p.y());
}
}
示例5: paint
void ThumbnailBarItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
bool isSelected = option.state & QStyle::State_Selected;
bool isCurrent = d->mView->selectionModel()->currentIndex() == index;
QPixmap thumbnailPix = d->mView->thumbnailForIndex(index);
QRect rect = option.rect;
QStyleOptionViewItem opt = option;
const QWidget* widget = opt.widget;
QStyle* style = widget ? widget->style() : QApplication::style();
if (isSelected && !isCurrent) {
// Draw selected but not current item backgrounds with some transparency
// so that the current item stands out.
painter->setOpacity(.33);
}
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget);
painter->setOpacity(1);
// Draw thumbnail
if (!thumbnailPix.isNull()) {
QRect thumbnailRect = QRect(
rect.left() + (rect.width() - thumbnailPix.width()) / 2,
rect.top() + (rect.height() - thumbnailPix.height()) / 2 - 1,
thumbnailPix.width(),
thumbnailPix.height());
if (!thumbnailPix.hasAlphaChannel()) {
d->drawShadow(painter, thumbnailRect);
painter->setPen(d->mBorderColor);
painter->setRenderHint(QPainter::Antialiasing, false);
QRect borderRect = thumbnailRect.adjusted(-1, -1, 0, 0);
painter->drawRect(borderRect);
}
painter->drawPixmap(thumbnailRect.left(), thumbnailRect.top(), thumbnailPix);
// Draw busy indicator
if (d->mView->isBusy(index)) {
QPixmap pix = d->mView->busySequenceCurrentPixmap();
painter->drawPixmap(
thumbnailRect.left() + (thumbnailRect.width() - pix.width()) / 2,
thumbnailRect.top() + (thumbnailRect.height() - pix.height()) / 2,
pix);
}
}
}
示例6: texture
QPixmap AbstractGeoPolygonGraphicsItem::texture(const QString &texturePath, const QColor &color) const
{
QString const key = QString::number(color.rgba()) + '/' + texturePath;
QPixmap texture;
if (!QPixmapCache::find(key, texture)) {
QImageReader imageReader(style()->polyStyle().resolvePath(texturePath));
texture = QPixmap::fromImageReader(&imageReader);
if (texture.hasAlphaChannel()) {
QPixmap pixmap (texture.size());
pixmap.fill(color);
QPainter imagePainter(&pixmap);
imagePainter.drawPixmap(0, 0, texture);
imagePainter.end();
texture = pixmap;
}
QPixmapCache::insert(key, texture);
}
return texture;
}
示例7: canBlitterDrawPixmap
bool canBlitterDrawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) const
{
if (pm.pixmapData()->classId() != QPixmapData::BlitterClass)
return false;
if (checkStateAgainstMask(capabillitiesState, drawPixmapMask)) {
if (m_capabilities & (QBlittable::SourceOverPixmapCapability
| QBlittable::SourceOverScaledPixmapCapability)) {
if (r.size() != sr.size())
return m_capabilities & QBlittable::SourceOverScaledPixmapCapability;
else
return m_capabilities & QBlittable::SourceOverPixmapCapability;
}
if ((m_capabilities & QBlittable::SourcePixmapCapability) && r.size() == sr.size() && !pm.hasAlphaChannel())
return m_capabilities & QBlittable::SourcePixmapCapability;
}
return false;
}