本文整理汇总了C++中QBitmap类的典型用法代码示例。如果您正苦于以下问题:C++ QBitmap类的具体用法?C++ QBitmap怎么用?C++ QBitmap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QBitmap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: needleArrow
QCursor KarbonCursor::needleArrow()
{
static const unsigned char needle_bits[] = {
0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x60, 0x00, 0xc0, 0x00, 0xc0, 0x01,
0x80, 0x03, 0x80, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, 0x3e, 0x00, 0x7e,
0x00, 0x7c, 0x00, 0x1c, 0x00, 0x18, 0x00, 0x00
};
QBitmap b = QBitmap::fromData(QSize(16, 16), needle_bits);
QBitmap m = b.createHeuristicMask(false);
return QCursor(b, m, 2, 0);
}
示例2: crossHair
QCursor KarbonCursor::crossHair()
{
static unsigned char cross_bits[] = {
0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
0x80, 0x00, 0xff, 0x7f, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
0x80, 0x00, 0x80, 0x00, 0x80, 0x00
};
QBitmap b = QBitmap::fromData(QSize(15, 15), cross_bits);
QBitmap m = b.createHeuristicMask(false);
return QCursor(b, m, 7, 7);
}
示例3: kpToolWidgetBase
kpToolWidgetSpraycanSize::kpToolWidgetSpraycanSize (QWidget *parent, const char *name)
: kpToolWidgetBase (parent, name)
{
#if DEBUG_KP_TOOL_WIDGET_SPRAYCAN_SIZE
kdDebug () << "kpToolWidgetSpraycanSize::kpToolWidgetSpraycanSize() CALLED!" << endl;
#endif
for (int i = 0; i < int (sizeof (spraycanSizes) / sizeof (spraycanSizes [0])); i++)
{
int s = spraycanSizes [i];
QString iconName = QString ("tool_spraycan_%1x%1").arg (s).arg(s);
#if DEBUG_KP_TOOL_WIDGET_SPRAYCAN_SIZE
kdDebug () << "\ticonName=" << iconName << endl;
#endif
QPixmap pixmap (s, s);
pixmap.fill (Qt::white);
QPainter painter (&pixmap);
painter.drawPixmap (0, 0, UserIcon (iconName));
painter.end ();
QImage image = kpPixmapFX::convertToImage (pixmap);
QBitmap mask (pixmap.width (), pixmap.height ());
mask.fill (Qt::color0);
painter.begin (&mask);
painter.setPen (Qt::color1);
for (int y = 0; y < image.height (); y++)
{
for (int x = 0; x < image.width (); x++)
{
if ((image.pixel (x, y) & RGB_MASK) == 0/*black*/)
painter.drawPoint (x, y); // mark as opaque
}
}
painter.end ();
pixmap.setMask (mask);
addOption (pixmap, i18n ("%1x%2").arg (s).arg (s)/*tooltip*/);
if (i == 1)
startNewOptionRow ();
}
finishConstruction (0, 0);
}
示例4: fm
QBitmap Slider::drawValue()
{
QFontMetrics fm(this->font());
QString st;
st.setNum(value,'f',precision);
QPainter painter;
int _x,_y;
QBitmap res;
if (orientation == 0) {
res.resize(width(),(height()-20)/2);
res.fill(Qt::color0);
painter.begin(&res);
painter.setPen(Qt::color1);
painter.setBrush(Qt::color1);
painter.setFont(this->font());
_x = (int)((res.width()-fm.width(st))/2);
_y = (int)(res.height());
painter.drawText(_x,_y,st);
}
else if (orientation == 1) {
res.resize((width()-20)/2,height());
res.fill(Qt::color0);
painter.begin(&res);
painter.setPen(Qt::color1);
painter.setBrush(Qt::color1);
painter.setFont(this->font());
_x = 0;
_y = (int)((res.height()+fm.height())/2);
painter.drawText(_x,_y,st);
}
painter.end();
return res;
}
示例5: QPixmap
void VlcPrimitiveBackgroundWidget::paintEvent(QPaintEvent *e)
{
int i_maxwidth, i_maxheight;
QPixmap pixmap = QPixmap(_path);
QPainter painter(this);
QBitmap pMask;
float f_alpha = 1.0;
i_maxwidth = __MIN(maximumWidth(), width()) - MARGIN * 2;
i_maxheight = __MIN(maximumHeight(), height()) - MARGIN * 2;
painter.setOpacity(property("opacity").toFloat());
if (height() > MARGIN * 2)
{
/* Scale down the pixmap if the widget is too small */
if (pixmap.width() > i_maxwidth || pixmap.height() > i_maxheight)
{
pixmap = pixmap.scaled(i_maxwidth, i_maxheight,
Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
else
if (b_expandPixmap &&
pixmap.width() < width() && pixmap.height() < height())
{
/* Scale up the pixmap to fill widget's size */
f_alpha = ((float) pixmap.height() / (float) height());
pixmap = pixmap.scaled(
width() - MARGIN * 2,
height() - MARGIN * 2,
Qt::KeepAspectRatio,
(f_alpha < .2)? /* Don't waste cpu when not visible */
Qt::SmoothTransformation:
Qt::FastTransformation
);
/* Non agressive alpha compositing when sizing up */
pMask = QBitmap(pixmap.width(), pixmap.height());
pMask.fill(QColor::fromRgbF(1.0, 1.0, 1.0, f_alpha));
pixmap.setMask(pMask);
}
painter.drawPixmap(
MARGIN + (i_maxwidth - pixmap.width()) /2,
MARGIN + (i_maxheight - pixmap.height()) /2,
pixmap);
}
QWidget::paintEvent( e );
}
示例6: QFETCH
void tst_QPixmap::mask()
{
QFETCH(QSize, size);
QPixmap src = rasterPixmap(size);
src.fill(Qt::transparent);
{
QPainter p(&src);
p.drawLine(QPoint(0, 0), QPoint(src.width(), src.height()));
}
QBENCHMARK {
QBitmap bitmap = src.mask();
QVERIFY(bitmap.size() == src.size());
}
}
示例7: renderOSDText
void OSDWidget::renderOSDText( const QString &text) {
static QBitmap mask;
// Set a sensible maximum size, don't cover the whole desktop or cross the screen
//Actually unused but it definitly should
//QSize max = QApplication::desktop() ->screen( m_screen ) ->size() - QSize( MARGIN*2 + 20, 100 );
if(this->m_srt!=0){
delete m_srt;
}
this->m_srt=new QSimpleRichText(text,this->font(),this->m_context);
// The title cannnot be taller than one line
// AlignAuto = align Arabic to the right, etc.
int w=this->m_srt->widthUsed();
int h=this->m_srt->height();
osdBuffer.resize(w,h);
mask.resize(w,h);
// Start painting!
QPainter bufferPainter( &osdBuffer );
QPainter maskPainter( &mask );
// Draw backing rectangle
//bufferPainter.save();
bufferPainter.setPen( Qt::black );
bufferPainter.setBrush( backgroundColor() );
bufferPainter.drawRoundRect( 0,0,w,h, 1500 /w, 1500/h);
//bufferPainter.restore();
this->m_srt->draw(&bufferPainter,0,0,QRect(),this->colorGroup());
// Masking for transparency
mask.fill( Qt::black );
maskPainter.setBrush( Qt::white );
maskPainter.drawRoundRect(0,0,w,h, 1500/w,1500/h);
setMask( mask );
//do last to reduce noticeable change when showing multiple OSDs in succession
reposition(QSize(w,h));
m_currentText = text;
m_dirty = false;
if(this->m_linking&&this==this->mouseGrabber()){
this->releaseMouse();
this->m_linking=false;
}
update();
}
示例8: while
/*!
\internal
A static function for reading the sprite files containing
pixmaps for displaying animated elements seen in the game.
*/
void KSprite::loadSprites()
{
QString sprites_prefix = IMG_BACKGROUND;
int sep = sprites_prefix.lastIndexOf("/");
sprites_prefix.truncate(sep);
int i = 0;
QString file_name;
QString base = sprites_prefix + '/';
while (animations_[i].id_) {
QList<QPixmap> p;
if (animations_[i].frames_) {
for (int j=0; j<animations_[i].frames_; ++j) {
QString s(animations_[i].path_);
file_name = base + s.arg(j,4,10,QLatin1Char('0'));
QPixmap pixmap(file_name);
p.insert(j,pixmap);
}
}
else {
file_name = base + QString(animations_[i].path_);
QPixmap pixmap(file_name);
p.insert(0,pixmap);
}
QList<Frame> frameshape;
for (int f = 0; f < p.size(); ++f) {
QPixmap pixmap = p.at(f);
Frame frame;
frame.pixmap = pixmap;
QPainterPath path;
QBitmap m = pixmap.mask();
if (m.width())
path.addRegion(QRegion(m));
else
path.addRegion(QRect(pixmap.rect()));
frame.shape = path;
frame.boundingRect = path.controlPointRect();
frameshape << frame;
}
shapemap_.insert(animations_[i].id_,frameshape);
i++;
}
spritesLoaded_ = true;
}
示例9: setValue
void PixmapEditor::setValue(const QBitmap &aValue)
{
mValue=QPixmap::fromImage(aValue.toImage());
ui->valueEdit->setText(bitmapToString(aValue));
setIcon(iconForPixmap(mValue));
mDataType=BITMAP;
}
示例10: QBitmap
void GLWidget::createCursors()
{
QBitmap pic = QBitmap(":/zoomIn.png");
if(pic.isNull())
{
ui.print("Warning: Null pic");
}
QBitmap mask = QBitmap(":/zoomIn-mask.png");
if(mask.isNull())
{
ui.print("Warning: Null mask");
}
zoomInCursor = QCursor( pic, mask);
QBitmap pic2 = QBitmap(":/zoomOut.png");
if(pic2.isNull())
{
ui.print("Warning: Null pic2");
}
zoomOutCursor = QCursor( pic2, mask);
}
示例11:
QRegion::QRegion( const QBitmap & bm )
{
data = new QRegionData;
Q_CHECK_PTR( data );
data->hgt = 0;
data->is_null = FALSE;
if ( bm.isNull() )
data->rgn = 0;
else
data->rgn = qt_pm_bitmapToRegion( bm );
}
示例12: pm
void QPixmap::resize( int w, int h )
{
if ( w < 1 || h < 1 ) { // becomes null
QPixmap pm( 0, 0, 0, data->bitmap, data->optim );
*this = pm;
return;
}
int d;
if ( depth() > 0 )
d = depth();
else
d = isQBitmap() ? 1 : -1;
// Create new pixmap
QPixmap pm( w, h, d, data->bitmap, data->optim );
#ifdef Q_WS_X11
pm.x11SetScreen( x11Screen() );
#endif // Q_WS_X11
if ( !data->uninit && !isNull() ) // has existing pixmap
bitBlt( &pm, 0, 0, this, 0, 0, // copy old pixmap
QMIN(width(), w),
QMIN(height(),h), CopyROP, TRUE );
#if defined(Q_WS_MAC)
if(data->alphapm) {
data->alphapm->resize(w, h);
} else
#elif defined(Q_WS_X11) && !defined(QT_NO_XFTFREETYPE)
if (data->alphapm)
qWarning("QPixmap::resize: TODO: resize alpha data");
else
#endif // Q_WS_X11
if ( data->mask ) { // resize mask as well
if ( data->selfmask ) { // preserve self-mask
pm.setMask( *((QBitmap*)&pm) );
} else { // independent mask
QBitmap m = *data->mask;
m.resize( w, h );
pm.setMask( m );
}
}
*this = pm;
}
示例13: Py_INCREF
static PyObject *meth_QBitmap_clear(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QBitmap *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QBitmap, &sipCpp))
{
sipCpp->clear();
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QBitmap, sipName_clear, doc_QBitmap_clear);
return NULL;
}
示例14: fillRect
QPixmap BitmapFactoryInst::fillRect(int x, int y, int w, int h, const QPixmap& p, Qt::BGMode bgmode) const
{
QBitmap b = p.mask();
if (b.isNull())
return p; // sorry, but cannot do anything
QPixmap pix = p;
// modify the mask
QPainter pt;
pt.begin(&b);
if (bgmode == Qt::OpaqueMode)
pt.fillRect(x, y, w, h, Qt::color1); // make opaque
else // Qt::TransparentMode
pt.fillRect(x, y, w, h, Qt::color0); // make transparent
pt.end();
pix.setMask(b);
return pix;
}
示例15: initialize
void QCursor::setBitmap( const QBitmap &bitmap, const QBitmap &mask,
int hotX, int hotY )
{
if ( !initialized )
initialize();
if ( bitmap.depth() != 1 || mask.depth() != 1 ||
bitmap.size() != mask.size() ) {
#if defined(QT_CHECK_NULL)
qWarning( "QCursor: Cannot create bitmap cursor; invalid bitmap(s)" );
#endif
QCursor *c = &cursorTable[arrowCursorIdx];
c->data->ref();
data = c->data;
return;
}
data = new QCursorData;
Q_CHECK_PTR( data );
data->bm = new QBitmap( bitmap );
data->bmm = new QBitmap( mask );
data->hcurs = 0;
data->cshape = BitmapCursor;
data->hx = hotX >= 0 ? hotX : bitmap.width()/2;
data->hy = hotY >= 0 ? hotY : bitmap.height()/2;
data->fg.red = 0 << 8;
data->fg.green = 0 << 8;
data->fg.blue = 0 << 8;
data->bg.red = 255 << 8;
data->bg.green = 255 << 8;
data->bg.blue = 255 << 8;
update(); // Xcursor's backward compatibility hack needs the cursor to be created
// right after the bitmaps are created and filled with data
}