当前位置: 首页>>代码示例>>C++>>正文


C++ QBitmap::resize方法代码示例

本文整理汇总了C++中QBitmap::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ QBitmap::resize方法的具体用法?C++ QBitmap::resize怎么用?C++ QBitmap::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QBitmap的用法示例。


在下文中一共展示了QBitmap::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawValue

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;
}
开发者ID:obrpasha,项目名称:votlis_krizh_gaz_nas,代码行数:33,代码来源:slider.cpp

示例2: 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();
}
开发者ID:BackupTheBerlios,项目名称:irate-svn,代码行数:47,代码来源:osd.cpp

示例3: resize

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;
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:41,代码来源:qpixmap.cpp


注:本文中的QBitmap::resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。