本文整理汇总了C++中QPixmap::mask方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::mask方法的具体用法?C++ QPixmap::mask怎么用?C++ QPixmap::mask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPixmap
的用法示例。
在下文中一共展示了QPixmap::mask方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resize
QPixmap BitmapFactoryInst::resize(int w, int h, const QPixmap& p, Qt::BGMode bgmode) const
{
if (bgmode == Qt::TransparentMode) {
if (p.width() == 0 || p.height() == 0)
w = 1;
QPixmap pix = p;
int x = pix.width () > w ? 0 : (w - pix.width ())/2;
int y = pix.height() > h ? 0 : (h - pix.height())/2;
if (x == 0 && y == 0)
return pix;
QPixmap pm (w,h);
QBitmap mask (w,h);
mask.fill(Qt::color0);
QBitmap bm = pix.mask();
if (!bm.isNull())
{
QPainter painter(&mask);
painter.drawPixmap(QPoint(x, y), bm, QRect(0, 0, pix.width(), pix.height()));
pm.setMask(mask);
}
else
{
pm.setMask(mask);
pm = fillRect(x, y, pix.width(), pix.height(), pm, Qt::OpaqueMode);
}
QPainter pt;
pt.begin( &pm );
pt.drawPixmap(x, y, pix);
pt.end();
return pm;
} else { // Qt::OpaqueMode
QPixmap pix = p;
if (pix.width() == 0 || pix.height() == 0)
return pix; // do not resize a null pixmap
QPalette pal = qApp->palette();
QColor dl = pal.color(QPalette::Disabled, QPalette::Light);
QColor dt = pal.color(QPalette::Disabled, QPalette::Text);
QPixmap pm = pix;
pm = QPixmap(w,h);
pm.fill(dl);
QPainter pt;
pt.begin( &pm );
pt.setPen( dl );
pt.drawPixmap(1, 1, pix);
pt.setPen( dt );
pt.drawPixmap(0, 0, pix);
pt.end();
return pm;
}
}
示例2: QWidget
ShapeWidget::ShapeWidget(QWidget *parent)
: QWidget(parent,Qt::FramelessWindowHint)
{
QPixmap pix;
pix.load(":/images/tux.png",0,Qt::AvoidDither|Qt::ThresholdDither|Qt::ThresholdAlphaDither);
resize(pix.size());
setMask(pix.mask());
}
示例3: setWindowIcon_sys
void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/)
{
#if 0
QTLWExtra* x = d->topData();
delete x->icon;
x->icon = 0;
QBitmap mask;
if (unscaledPixmap.isNull()) {
} else {
QImage unscaledIcon = unscaledPixmap.toImage();
QPixmap pixmap =
QPixmap::fromImage(unscaledIcon.scale(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
x->icon = new QPixmap(pixmap);
mask = pixmap.mask() ? *pixmap.mask() : pixmap.createHeuristicMask();
}
#endif
}
示例4: ret
// Transparent images are converted to 32bpp pixmaps, but
// setting those as window background needs ARGB visual
// and compositing - convert to 24bpp, at least for now.
static QPixmap make24bpp( const QPixmap& p )
{
QPixmap ret( p.size());
QPainter pt( &ret );
pt.drawPixmap( 0, 0, p );
pt.end();
ret.setMask( p.mask());
return ret;
}
示例5: setIcon
void KWM::setIcon(Window w, const QPixmap &pm){
XWMHints *hints = XGetWMHints(qt_xdisplay(), w);
if (!hints)
hints = XAllocWMHints();
QPixmap *p = new QPixmap;
*p = pm;
hints->icon_pixmap=p->handle();
hints->flags |= IconPixmapHint;
if(p->mask()){
hints->icon_mask = p->mask()->handle();
hints->flags |= IconMaskHint;
}
else
hints->flags &= ~IconMaskHint;
XSetWMHints( qt_xdisplay(), w, hints );
XFree((char*)hints);
delete p;
}
示例6: setSize
void QSanButton::setSize(QSize newSize) {
_m_size = newSize;
if (_m_size.width() == 0 || _m_size.height() == 0) {
_m_mask = QRegion();
return;
}
Q_ASSERT(!_m_bgPixmap[0].isNull());
QPixmap pixmap = _m_bgPixmap[0];
_m_mask = QRegion(pixmap.mask().scaled(newSize));
}
示例7: p
void
set_background_properties(QWidget *w)
{
QPixmap bg = getClassPixmap((char*)"EPPLET_BACKGROUND_VERTICAL", (char*)"normal", w);
if (!bg.isNull()){
int border = 2;
QPixmap img = getClassPixmap((char*)"EPPLET_DRAWINGAREA", (char*)"normal", w,
w->width() - border * 2, w->height() - border * 2);
if (!img.isNull()){
QPainter p(&bg);
p.drawPixmap(border, border, img);
}
w->setBackgroundPixmap(bg);
if (bg.mask()){
w->setMask(*bg.mask());
}else{
w->clearMask();
}
}
}
示例8: paintEvent
//ÖØдpaintEvent,Ìí¼Ó±³¾°Í¼Æ¬
void MusicListWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
QPixmap backgroundImage;
backgroundImage.load(":/images/musicList.png");
//ÏÈͨ¹ýpixµÄ·½·¨»ñµÃͼƬµÄ¹ýÂ˵ô͸Ã÷µÄ²¿·ÖµÃµ½µÄͼƬ£¬×÷ΪloginPanelµÄ²»¹æÔò±ß¿ò
this ->setMask(backgroundImage.mask());
painter.drawPixmap(0, 0, 400, 450, backgroundImage);
event ->accept();
}
示例9: paintEvent
//重写paintEvent,添加背景图片
void MinMusicWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
QPixmap backgroundImage;
backgroundImage.load(":/images/minMainBg2.png");
//先通过pix的方法获得图片的过滤掉透明的部分得到的图片,作为loginPanel的不规则边框
this ->setMask(backgroundImage.mask());
painter.drawPixmap(0, 0, 200, 159, backgroundImage);
event ->accept();
}
示例10: drawBackground
//! ----------------------------------------------------------------------------------------------------------------
//!
//! \brief TestWindow::drawBackground
//!
void TestWindow::drawBackground(){
QPixmap *pixmap = new QPixmap(":/images/background.png");
QPalette p = this->palette();
p.setBrush(QPalette::Background,
QBrush(pixmap->scaled(QSize(appSize.width(), appSize.height()),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation)));
this->setPalette(p);
this->setMask(pixmap->mask());
}
示例11: merge
QPixmap BitmapFactoryInst::merge(const QPixmap& p1, const QPixmap& p2, bool vertical) const
{
int width = 0;
int height = 0;
int x = 0;
int y = 0;
// get the size for the new pixmap
if (vertical) {
y = p1.height();
width = qMax( p1.width(), p2.width() );
height = p1.height() + p2.height();
} else {
x = p1.width();
width = p1.width() + p2.width();
height = qMax( p1.height(), p2.height() );
}
QPixmap res( width, height );
QBitmap mask( width, height );
QBitmap mask1 = p1.mask();
QBitmap mask2 = p2.mask();
mask.fill( Qt::color0 );
QPainter* pt1 = new QPainter(&res);
pt1->drawPixmap(0, 0, p1);
pt1->drawPixmap(x, y, p2);
delete pt1;
QPainter* pt2 = new QPainter(&mask);
pt2->drawPixmap(0, 0, mask1);
pt2->drawPixmap(x, y, mask2);
delete pt2;
res.setMask(mask);
return res;
}
示例12: set
void WharfIcon::set(const char *icon, const char *msg)
{
const QIconSet &icons = Icon(icon);
QPixmap *nvis = new QPixmap(icons.pixmap(QIconSet::Large, QIconSet::Normal));
QPixmap *nvish = new QPixmap(icons.pixmap(QIconSet::Large, QIconSet::Active));
resize(nvis->width(), nvis->height());
if (msg){
QPixmap msgPict = Pict(msg);
QRegion *rgn = NULL;
if (nvis->mask() && msgPict.mask()){
rgn = new QRegion(*msgPict.mask());
rgn->translate(nvis->width() - msgPict.width() - 2,
nvis->height() - msgPict.height() - 2);
*rgn += *nvis->mask();
}
QPainter p;
p.begin(nvis);
p.drawPixmap(nvis->width() - msgPict.width() - 2,
nvis->height() - msgPict.height() - 2, msgPict);
p.end();
p.begin(nvish);
p.drawPixmap(nvish->width() - msgPict.width() - 2,
nvish->height() - msgPict.height() - 2, msgPict);
p.end();
if (rgn){
setMask(*rgn);
delete rgn;
}
}else{
const QBitmap *mask = nvis->mask();
if (mask) setMask(*mask);
}
if (vis) delete vis;
vis = nvis;
if (vish) delete vish;
vish = nvish;
repaint();
}
示例13: setIcon
void QWidget::setIcon( const QPixmap &unscaledPixmap )
{
if ( extra && extra->topextra ) {
delete extra->topextra->icon;
extra->topextra->icon = 0;
} else {
createTLExtra();
}
QBitmap mask;
if ( unscaledPixmap.isNull() ) {
} else {
QImage unscaledIcon = unscaledPixmap.convertToImage();
QPixmap pixmap;
#ifndef QT_NO_IMAGE_SMOOTHSCALE
pixmap.convertFromImage( unscaledIcon.smoothScale( 16, 16 ) );
#else
pixmap.convertFromImage( unscaledIcon );
#endif
extra->topextra->icon = new QPixmap( pixmap );
mask = pixmap.mask() ? *pixmap.mask() : pixmap.createHeuristicMask();
}
// XXX
}
示例14: MaskWidget
/*------------------------------------------------------------------*
* MODIFICATIONS *
* Date Description Author *
* =========== ================================== =============== *
* *
*------------------------------------------------------------------*/
void ZUtils::MaskWidget(QWidget* pWidget, const QString& pImage)
{
QPixmap vPix;
QBitmap vBitmap;
QImage vImg(QImage::fromMimeSource(pImage));
vPix.convertFromImage(vImg);
if (!vPix.mask())
{
if (vImg.hasAlphaBuffer())
{
vBitmap = vImg.createAlphaMask();
vPix.setMask(vBitmap);
}
else
{
vBitmap = vImg.createHeuristicMask();
vPix.setMask(vBitmap);
}
}
if (vPix.mask())
pWidget->setMask(*vPix.mask());
}
示例15: MaskButton
/*------------------------------------------------------------------*
* MODIFICATIONS *
* Date Description Author *
* =========== ================================== =============== *
* *
*------------------------------------------------------------------*/
void ZPushButton::MaskButton(const QPixmap *pPix)
{
QPixmap vPix;
QBitmap vBitMask;
QImage vImg(pPix->convertToImage());
vPix = *pPix;
if (!vPix.mask())
{
if (vImg.hasAlphaBuffer())
{
vBitMask = vImg.createAlphaMask();
vPix.setMask(vBitMask);
}
else
{
vBitMask = vImg.createHeuristicMask();
vPix.setMask(vBitMask);
}
}
if (vPix.mask())
setMask(*vPix.mask());
}