本文整理汇总了C++中QPixmap::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::resize方法的具体用法?C++ QPixmap::resize怎么用?C++ QPixmap::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPixmap
的用法示例。
在下文中一共展示了QPixmap::resize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resize
void QSPixmapClass::resize( QSEnv *env )
{
if ( env->numArgs() < 1 || env->numArgs() > 2 ) {
env->throwError( QString::fromLatin1( "Pixmap.resize() called with %1 arguments. 1 or 2 arguments expected." ).
arg( env->numArgs() ) );
return;
}
QSObject t = env->thisValue();
QSPixmapClass *pac = (QSPixmapClass*)t.objectType();
QPixmap *pix = pac->pixmap( &t );
if ( env->numArgs() == 1 ) {
QSObject a0 = env->arg( 0 );
if ( !a0.isA( "Size" ) ) {
env->throwError( QString::fromLatin1( "Pixmap.resize() called with an argument of type %1. "
"Type Size is expeced" ).
arg( a0.typeName() ) );
return;
}
pix->resize( *( (QSSizeClass*)a0.objectType() )->size( &a0 ) );
} else {
if ( !env->arg( 0 ).isA( "Number" ) || !env->arg( 1 ).isA( "Number" ) ) {
env->throwError( QString::fromLatin1( "Pixmap.resize() called with arguments of type %1 and %2. "
"Type Number and Number is expeced" ).
arg( env->arg( 0 ).typeName() ).arg( env->arg( 1 ).typeName() ) );
return;
}
pix->resize( env->arg( 0 ).toInteger(), env->arg( 1 ).toInteger() );
}
return;
}
示例2: p
void Plot3DDialog::setColorMapPreview(const QString& fileName)
{
if (fileName.isEmpty()) {
colorMapPreviewLabel->setText(tr("None"));
return;
}
ColorVector cv;
if (!Graph3D::openColorMapFile(cv, fileName)) {
colorMapPreviewLabel->setText(tr("None"));
return;
}
int height = 20;
QPixmap pix;
pix.resize(cv.size(), height);
QPainter p(&pix);
for (unsigned i = 0; i != cv.size(); ++i) {
RGBA rgb = cv[i];
p.setPen(GL2Qt(rgb.r, rgb.g, rgb.b));
p.drawLine(QPoint(0, 0), QPoint(0, height));
p.translate(1, 0);
}
p.end();
colorMapPreviewLabel->setPixmap(pix);
}
示例3: loadRenderingPixmap
QPixmap loadRenderingPixmap( KTNEFPropertySet *pSet, const QColor& bgColor )
{
QPixmap pix;
QVariant rendData = pSet->attribute( attATTACHRENDDATA ), wmf = pSet->attribute( attATTACHMETAFILE );
if ( !rendData.isNull() && !wmf.isNull() )
{
// Get rendering size
QBuffer rendBuffer( rendData.asByteArray() );
rendBuffer.open( IO_ReadOnly );
QDataStream rendStream( &rendBuffer );
rendStream.setByteOrder( QDataStream::LittleEndian );
Q_UINT16 type, w, h;
rendStream >> type >> w >> w; // read type and skip 4 bytes
rendStream >> w >> h;
rendBuffer.close();
if ( type == 1 && w > 0 && h > 0 )
{
// Load WMF data
QWinMetaFile wmfLoader;
QBuffer wmfBuffer( wmf.asByteArray() );
wmfBuffer.open( IO_ReadOnly );
wmfLoader.setBbox( QRect( 0, 0, w, h ) );
if ( wmfLoader.load( wmfBuffer ) )
{
pix.resize( w, h );
pix.fill( bgColor );
wmfLoader.paint( &pix );
}
wmfBuffer.close();
}
}
示例4: getNewColor
/**
* Helper Function. Gets a color and fulls button 'l' with it.
* @param c initial color;
* @param l button to fill.
*/
void TextOptionsImp::getNewColor(QColor &c, QPushButton *l){
KColorDialog::getColor ( c, this );
QPixmap color;
color.resize(40,20);
color.fill(c);
l->setPixmap(color);
}
示例5: grabWidget
QPixmap QPixmap::grabWidget( QWidget * widget, int x, int y, int w, int h )
{
QPixmap res;
if ( !widget )
return res;
if ( w < 0 )
w = widget->width() - x;
if ( h < 0 )
h = widget->height() - y;
QRect wr( x, y, w, h );
if ( wr == widget->rect() )
return grabChildWidgets( widget );
if ( !wr.intersects( widget->rect() ) )
return res;
res.resize( w, h );
if( res.isNull() )
return res;
res.fill( widget, QPoint( w,h ) );
QPixmap tmp( grabChildWidgets( widget ) );
if( tmp.isNull() )
return tmp;
::bitBlt( &res, 0, 0, &tmp, x, y, w, h );
return res;
}
示例6: setFont
/**
* Changes the font associated with this item.
* The function a sample text on a pixmap using this font, and then
* assigns the pixmap to the list item.
* The font set by this function is returned by getFont().
* @param font The font to set
*/
void setFont(QFont font) {
QPixmap pix;
QFontMetrics fm(font);
QPainter painter;
QRect rc;
// Remember the font
m_font = font;
// Set the pixmap's size so it can contain the sample text
rc = fm.boundingRect(i18n("Sample"));
rc.moveTopLeft(QPoint(0, 0));
pix.resize(rc.width(), rc.height());
// Draw on the pixmap
pix.fill();
painter.begin(&pix);
painter.setFont(font);
painter.setPen(black);
painter.drawText(rc, Qt::AlignHCenter | Qt::AlignVCenter,
i18n("Sample"));
painter.end();
// Set the pixmap to the item
setPixmap(1, pix);
}
示例7: draw
void PixServer::draw(int pos, PixMap pix, int i)
{
QPixmap p;
p.resize(BRICKSIZE, BRICKSIZE);
QRect rect = board->rect(pos);
if (! plainColor)
bitBlt( &p, 0, 0, &backPix,
rect.x(), rect.y(), rect.width(), rect.height());
else
p.fill(backgroundColor);
switch (pix) {
case SamyPix: bitBlt(&p ,0,0, &samyPix[i]);
break;
case CompuSnakePix: bitBlt(&p ,0,0, &compuSnakePix[i]);
break;
case ApplePix: bitBlt(&p ,0,0, &applePix[i]);
break;
case BallPix: bitBlt(&p ,0,0, &ballPix[i]);
break;
default:
break;
}
bitBlt(&cachePix, rect.x(), rect.y(), &p);
}
示例8: getGradientPixmap
QPixmap ClsBaseQStateArrayView::getGradientPixmap(int iImgWidth, int iImgHeight, int _iColorMode ) {
#ifdef DEBUG_CLSBASEQSTATEARRAYVIEW
cout << "ClsBaseQStateArrayView::getGradientPixmap(int iImgWidth, int iImgHeight)" << endl;
#endif
// int iColorMode = ClsBaseQStateArrayView::GRAY;
// int iColorMode = ClsBaseQStateArrayView::BLUE2RED;
// int iColorMode = ClsBaseQStateArrayView::HSV;
QPixmap pmGradient;
QPainter* paintGradient = new QPainter();
QWMatrix mxRot;
int iDiag = (int)(sqrt(double(iImgWidth * iImgWidth + iImgHeight * iImgHeight))/2.);
pmGradient.resize(2 * iDiag, 2 * iDiag);
paintGradient->begin(&pmGradient);
paintGradient->setWindow( 0, 0, 2 * iDiag, 2 * iDiag );
int iNrSices = 50;
for ( int i=0; i<iNrSices; i++ ) {
paintGradient->setWorldMatrix( mxRot );
QColor c;
if(_iColorMode == ClsBaseQStateArrayView::GRAY){
c.setRgb( i* 255 / iNrSices, i* 255 / iNrSices, i* 255 / iNrSices );
}
else if(_iColorMode == ClsBaseQStateArrayView::BLUE2RED){
if(i<iNrSices/2){
/* BLUE */
c.setRgb(0, 0, 255 - i * 510/iNrSices);
}
else {
/* RED */
c.setRgb( (i - iNrSices/2) * 255/(iNrSices/2), 0,0);
}
}
else {
c.setHsv( i* 360 / iNrSices, 255, 255 );
}
paintGradient->setBrush( c );
paintGradient->setPen( c );
//zzz QPointArray a;
QPolygon a;
a.setPoints( 4,
0, 0,
iDiag * 2 / iNrSices, 0,
iDiag * 2 / iNrSices, iDiag * 2,
0, iDiag * 2 );
paintGradient->drawPolygon( a );
mxRot.translate( (double)iDiag * 2.0 / (double)iNrSices, 0.0 );
}
paintGradient->end();
return pmGradient;
}
示例9: changeColor
void PColorButton::changeColor()
{
#ifdef PURE_QT
m_color = QColorDialog::getColor(m_color,this);
updateProperty(m_color);
m_edit->setText(m_color.name());
QPixmap px;
px.resize(14,14);
px.fill(m_color);
m_edit->setIconSet(px);
#endif
}
示例10: paintEvent
void Editor::paintEvent( QPaintEvent* ) {
// first we layer on a background grid
QPixmap buff;
QPixmap *dest=drawFrame->getPreviewPixmap();
buff.resize(dest->width(), dest->height());
drawBackground(&buff);
drawTiles(&buff);
bitBlt(dest, 0,0,&buff, 0,0,buff.width(), buff.height(), CopyROP);
drawFrame->repaint(false);
}
示例11: paintEvent
/*!
\brief Repaint the widget
*/
void PTank::paintEvent(QPaintEvent *event)
{
static QPixmap pixmap;
QRect rect = event->rect();
QSize newSize = rect.size().expandedTo(pixmap.size());
pixmap.resize(newSize);
pixmap.fill(this,rect.topLeft());
QPainter painter(&pixmap,this);
painter.translate(-rect.x(),-rect.y());
drawTank(&painter);
bitBlt(this,rect.x(),rect.y(),&pixmap,0,0,rect.width(),rect.height());
}
示例12: setDefaultBuddyColors
/**
* Sets up the default buddy colors.
*/
void TextOptionsImp::setDefaultBuddyColors(){
chat_contactText_color.setRgb(0,0,0);
chat_contactName_color.setRgb(128,0,0);
chat_contactbg_color.setRgb(255,255,255);
QPixmap color;
color.resize(40,20);
color.fill(chat_contactText_color);
chat_color_btext->setPixmap(color);
color.fill(chat_contactName_color);
chat_color_bname->setPixmap(color);
color.fill(chat_contactbg_color);
chat_color_bbcolor->setPixmap(color);
}
示例13: setDefaultUserColors
/**
* Sets up the default user colors.
*/
void TextOptionsImp::setDefaultUserColors(){
chat_yourText_color.setRgb(0,0,0);
chat_yourName_color.setRgb(0,60,128);
chat_yourbg_color.setRgb(255,255,255);
QPixmap color;
color.resize(40,20);
color.fill(chat_yourText_color);
chat_color_ytext->setPixmap(color);
color.fill(chat_yourName_color);
chat_color_yname->setPixmap(color);
color.fill(chat_yourbg_color);
chat_color_ybcolor->setPixmap(color);
}
示例14: drawTitle
void KWMThemeClient::drawTitle(QPainter &dest)
{
QRect titleRect = titlebar->geometry();
QRect r(0, 0, titleRect.width(), titleRect.height());
QPixmap buffer;
if(buffer.width() == r.width())
return;
buffer.resize(r.size());
QPainter p;
p.begin(&buffer);
if(titleSunken){
qDrawShadeRect(&p, r, options()->colorGroup(KDecorationOptions::ColorFrame, isActive()),
true, 1, 0);
r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
}
KPixmap *fill = isActive() ? aTitlePix : iTitlePix;
if(fill)
p.drawTiledPixmap(r, *fill);
else if(titleGradient){
fill = isActive() ? aGradient : iGradient;
if(fill->width() != r.width()){
fill->resize(r.width(), 20);
KPixmapEffect::gradient(*fill,
options()->color(KDecorationOptions::ColorTitleBar, isActive()),
options()->color(KDecorationOptions::ColorTitleBlend, isActive()),
grType);
}
p.drawTiledPixmap(r, *fill);
}
else{
p.fillRect(r, options()->colorGroup(KDecorationOptions::ColorTitleBar, isActive()).
brush(QColorGroup::Button));
}
p.setFont(options()->font(isActive()));
p.setPen(options()->color(KDecorationOptions::ColorFont, isActive()));
// Add left & right margin
r.setLeft(r.left()+5);
r.setRight(r.right()-5);
p.drawText(r, titleAlign, caption());
p.end();
dest.drawPixmap(titleRect.x(), titleRect.y(), buffer);
}
示例15: slSetBackGround
void ThumbView::slSetBackGround( )
{
QPixmap bgPix;
if( m_bgImg.isEmpty())
{
bgPix.resize( QSize(16, 16));
bgPix.fill( QPixmap::blue );
}
else
{
bgPix.load( m_bgImg );
}
m_iconView->setPaletteBackgroundPixmap ( bgPix );
setPaletteBackgroundPixmap ( bgPix );
}