本文整理汇总了C++中QBitmap::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QBitmap::size方法的具体用法?C++ QBitmap::size怎么用?C++ QBitmap::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBitmap
的用法示例。
在下文中一共展示了QBitmap::size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setBitmap
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
}
示例2: setBitmap
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->cshape = BitmapCursor;
data->id = nextCursorId++;
data->hx = hotX >= 0 ? hotX : bitmap.width()/2;
data->hy = hotY >= 0 ? hotY : bitmap.height()/2;
QPaintDevice::qwsDisplay()->defineCursor(data->id, *data->bm,
*data->bmm, data->hx, data->hy);
}
示例3: mask
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());
}
}
示例4: pixOutsideRaw
SoundSlider::SoundSlider( QWidget *_parent, float _i_step,
char *psz_colors, int max )
: QAbstractSlider( _parent )
{
qreal scalingFactorX = static_cast<qreal>(logicalDpiX()) / DPI_REF_VALUE;
qreal scalingFactorY = static_cast<qreal>(logicalDpiY()) / DPI_REF_VALUE;
wlength = WLENGTH_BASE * scalingFactorX;
wheight = WHEIGHT_BASE * scalingFactorY;
f_step = (float)(_i_step * 10000)
/ (float)((max - SOUNDMIN) * AOUT_VOLUME_DEFAULT);
setRange( SOUNDMIN, max);
setMouseTracking( true );
isSliding = false;
b_mouseOutside = true;
b_isMuted = false;
const QPixmap pixOutsideRaw(Helper::getIconPath("volume-slider-outside.png"));
const QSize pixOutsideSize(
static_cast<qreal>(pixOutsideRaw.width()) * scalingFactorX,
static_cast<qreal>(pixOutsideRaw.height()) * scalingFactorY
);
pixOutside = pixOutsideRaw.scaled(pixOutsideSize);
const QPixmap tempRaw(Helper::getIconPath("volume-slider-inside.png"));
const QSize tempSize(
static_cast<qreal>(tempRaw.width()) * scalingFactorX,
static_cast<qreal>(tempRaw.height()) * scalingFactorY
);
const QPixmap temp = tempRaw.scaled(tempSize);
const QBitmap mask( temp.createHeuristicMask() );
setFixedSize( pixOutside.size() );
pixGradient = QPixmap( mask.size() );
pixGradient2 = QPixmap( mask.size() );
/* Gradient building from the preferences */
QLinearGradient gradient( paddingL, 2, wlength + paddingL , 2 );
QLinearGradient gradient2( paddingL, 2, wlength + paddingL , 2 );
QStringList colorList = qfu( psz_colors ).split( ";" );
free( psz_colors );
/* Fill with 255 if the list is too short */
if( colorList.count() < 12 )
for( int i = colorList.count(); i < 12; i++)
colorList.append( "255" );
background = palette().color( QPalette::Active, QPalette::Window );
foreground = palette().color( QPalette::Active, QPalette::WindowText );
foreground.setHsv( foreground.hue(),
( background.saturation() + foreground.saturation() ) / 2,
( background.value() + foreground.value() ) / 2 );
textfont.setPointSize( 9 );
textrect.setRect( 0, 0, 34.0*scalingFactorX, 15.0*scalingFactorY );
/* Regular colors */
#define c(i) colorList.at(i).toInt()
#define add_color(gradient, range, c1, c2, c3) \
gradient.setColorAt( range, QColor( c(c1), c(c2), c(c3) ) );
/* Desaturated colors */
#define desaturate(c) c->setHsvF( c->hueF(), 0.2 , 0.5, 1.0 )
#define add_desaturated_color(gradient, range, c1, c2, c3) \
foo = new QColor( c(c1), c(c2), c(c3) );\
desaturate( foo ); gradient.setColorAt( range, *foo );\
delete foo;
/* combine the two helpers */
#define add_colors( gradient1, gradient2, range, c1, c2, c3 )\
add_color( gradient1, range, c1, c2, c3 ); \
add_desaturated_color( gradient2, range, c1, c2, c3 );
float f_mid_point = ( 100.0 / maximum() );
QColor * foo;
add_colors( gradient, gradient2, 0.0, 0, 1, 2 );
if (f_mid_point + 0.05 <= 1.0) {
add_colors( gradient, gradient2, f_mid_point - 0.05, 3, 4, 5 );
add_colors( gradient, gradient2, f_mid_point + 0.05, 6, 7, 8 );
}
add_colors( gradient, gradient2, 1.0, 9, 10, 11 );
painter.begin( &pixGradient );
painter.setPen( Qt::NoPen );
painter.setBrush( gradient );
painter.drawRect( pixGradient.rect() );
painter.end();
painter.begin( &pixGradient2 );
painter.setPen( Qt::NoPen );
painter.setBrush( gradient2 );
painter.drawRect( pixGradient2.rect() );
painter.end();
pixGradient.setMask( mask );
pixGradient2.setMask( mask );
//.........这里部分代码省略.........
示例5: equal
static bool equal(const QBitmap &v1, const QBitmap &v2)
{ return v1.size() == v2.size(); }
示例6: temp
SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard,
char *psz_colors )
: QAbstractSlider( _parent )
{
f_step = ( _i_step * 100 ) / AOUT_VOLUME_MAX ;
setRange( SOUNDMIN, b_hard ? (2 * SOUNDMAX) : SOUNDMAX );
setMouseTracking( true );
isSliding = false;
b_mouseOutside = true;
b_isMuted = false;
pixOutside = QPixmap( ":/toolbar/volslide-outside" );
const QPixmap temp( ":/toolbar/volslide-inside" );
const QBitmap mask( temp.createHeuristicMask() );
setFixedSize( pixOutside.size() );
pixGradient = QPixmap( mask.size() );
pixGradient2 = QPixmap( mask.size() );
/* Gradient building from the preferences */
QLinearGradient gradient( paddingL, 2, WLENGTH + paddingL , 2 );
QLinearGradient gradient2( paddingL, 2, WLENGTH + paddingL , 2 );
QStringList colorList = qfu( psz_colors ).split( ";" );
free( psz_colors );
/* Fill with 255 if the list is too short */
if( colorList.count() < 12 )
for( int i = colorList.count(); i < 12; i++)
colorList.append( "255" );
background = palette().color( QPalette::Active, QPalette::Background );
foreground = palette().color( QPalette::Active, QPalette::WindowText );
foreground.setHsv( foreground.hue(),
( background.saturation() + foreground.saturation() ) / 2,
( background.value() + foreground.value() ) / 2 );
textfont.setPixelSize( 9 );
textrect.setRect( 0, 0, 34, 15 );
/* Regular colors */
#define c(i) colorList.at(i).toInt()
#define add_color(gradient, range, c1, c2, c3) \
gradient.setColorAt( range, QColor( c(c1), c(c2), c(c3) ) );
/* Desaturated colors */
#define desaturate(c) c->setHsvF( c->hueF(), 0.2 , 0.5, 1.0 )
#define add_desaturated_color(gradient, range, c1, c2, c3) \
foo = new QColor( c(c1), c(c2), c(c3) );\
desaturate( foo ); gradient.setColorAt( range, *foo );\
delete foo;
/* combine the two helpers */
#define add_colors( gradient1, gradient2, range, c1, c2, c3 )\
add_color( gradient1, range, c1, c2, c3 ); \
add_desaturated_color( gradient2, range, c1, c2, c3 );
float f_mid_point = ( 100.0 / maximum() );
QColor * foo;
add_colors( gradient, gradient2, 0.0, 0, 1, 2 );
add_colors( gradient, gradient2, f_mid_point - 0.05, 3, 4, 5 );
add_colors( gradient, gradient2, f_mid_point + 0.05, 6, 7, 8 );
add_colors( gradient, gradient2, 1.0, 9, 10, 11 );
painter.begin( &pixGradient );
painter.setPen( Qt::NoPen );
painter.setBrush( gradient );
painter.drawRect( pixGradient.rect() );
painter.end();
painter.begin( &pixGradient2 );
painter.setPen( Qt::NoPen );
painter.setBrush( gradient2 );
painter.drawRect( pixGradient2.rect() );
painter.end();
pixGradient.setMask( mask );
pixGradient2.setMask( mask );
}