本文整理汇总了C++中QPainter::isActive方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::isActive方法的具体用法?C++ QPainter::isActive怎么用?C++ QPainter::isActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::isActive方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: end
bool FLPicturePrivate::end() {
if ( ownerPte && pte->isActive() )
return pte->end();
else
if ( !ownerPte && pte->isActive() && endPte )
return pte->end();
return false;
}
示例2: platformTransformColorSpace
void ImageBufferDataPrivateUnaccelerated::platformTransformColorSpace(const Vector<int>& lookUpTable)
{
QPainter* painter = paintDevice()->paintEngine()->painter();
bool isPainting = painter->isActive();
if (isPainting)
painter->end();
QImage image = toQImage().convertToFormat(QImage::Format_ARGB32);
ASSERT(!image.isNull());
uchar* bits = image.bits();
const int bytesPerLine = image.bytesPerLine();
for (int y = 0; y < m_pixmap.height(); ++y) {
quint32* scanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine);
for (int x = 0; x < m_pixmap.width(); ++x) {
QRgb& pixel = scanLine[x];
pixel = qRgba(lookUpTable[qRed(pixel)],
lookUpTable[qGreen(pixel)],
lookUpTable[qBlue(pixel)],
qAlpha(pixel));
}
}
m_pixmap = QPixmap::fromImage(image);
if (isPainting)
painter->begin(&m_pixmap);
}
示例3: paintEvent
void Canvas::paintEvent(QPaintEvent *e)
{
QPainter *p = new QPainter(this);
QPen pen(QColor(0,0,0,255));
if(p->isActive()){
p->setRenderHint(QPainter::Antialiasing);
pen.setWidth(1);
p->setPen(pen);
p->save();
pen.setColor(QColor(255,0,0,255));
p->setPen(pen);
foreach(QPainterPath t, _ticks)
p->drawPath(t);
p->restore();
p->drawEllipse(PADDING,PADDING,_radiusX*2,_radiusY*2);
p->end();
}
QFrame::paintEvent(e);
}
示例4: paintEvent
void Canvas::paintEvent(QPaintEvent *e)
{
QPainter *p = new QPainter(this);
QPen pen(QColor(0,0,0,255));
qreal curangle = 0.0;
if(p->isActive()){
p->setRenderHint(QPainter::Antialiasing);
pen.setWidth(1);
p->setPen(pen);
p->save();
pen.setColor(QColor(255,0,0,255));
p->setPen(pen);
foreach(qreal v, _values){
qreal span = (5760.0 / _valueSum) * v;
cout << "Value: " << v << " (sum="<<_valueSum<<") , span = " << span << "/5760, curangle = " << curangle;
p->drawPie(rect(), curangle, span);
curangle += span;
cout << ", newangle = " << curangle << endl;
}
示例5: setPainter
void FLPicturePrivate::setPainter( QPainter * pt ) {
if ( pic && pt ) {
if ( pte ) {
end();
if ( ownerPte )
delete pte;
}
pte = pt;
ownerPte = false;
endPte = !pte->isActive();
}
}
示例6: resizeEvent
void SVGFrame::resizeEvent ( QResizeEvent* event )
{
QFrame::resizeEvent ( event );
emit resized ( event->size() );
if ( drawImg && event->size().width() >0 && event->size().height() >0 &&!empty )
{
QPalette pal=palette();
QImage img ( event->size(),QImage::Format_ARGB32_Premultiplied );
QPainter p ( &img );
if ( p.isActive() )
renderer->render ( &p );
pal.setBrush ( QPalette::Window,QBrush ( QPixmap::fromImage ( img ) ) );
setPalette ( pal );
}
}
示例7: qp
// Note : should be called with lock held
static inline bool maskPainter(int qtGraphDesc, QPainter &p)
{
bool r = false;
QColor c;
switch (QtGraphDescPool[qtGraphDesc].blendmode) {
case java_awt_AlphaComposite_SRC_OVER:
if((QtGraphDescPool[qtGraphDesc].currentalpha & 0x80) != 0) {
c = Qt::color1;
r = true;
}
break;
case java_awt_AlphaComposite_SRC:
c = (QtGraphDescPool[qtGraphDesc].currentalpha & 0x80) ?
Qt::color1 : Qt::color0;
r = true;
break;
case java_awt_AlphaComposite_CLEAR:
c = Qt::color0;
r = true;
break;
default:
r = false;
}
if(r)
{
QPen qp(p.pen());
QBrush qb(p.brush());
qp.setColor(c);
qb.setColor(c);
if(p.isActive()) p.end();
p.begin((QPaintDevice *)(QtImageDescPool[QtGraphDescPool[qtGraphDesc].qid].mask));
p.setPen(qp);
p.setBrush(qb);
setPainterClip(&p, qtGraphDesc) ;
}
return r;
}
示例8: paintEvent
void NLabel::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter;
QRect rect = contentsRect();
if (painter.isActive())
painter.setFont(font());
if (m_enabled && m_shadowOffset != QPoint(0, 0)) {
painter.begin(this);
painter.setPen(QPen(m_shadowColor));
painter.drawText(rect.translated(m_shadowOffset), alignment(), m_elidedText);
painter.end();
}
painter.begin(this);
painter.drawText(rect, alignment(), m_elidedText);
painter.end();
}
示例9: paintEvent
void OscilloscopeView::paintEvent( QPaintEvent *e)
{
QRect r = e->rect();
if(b_needRedraw)
{
updateOutputHeight();
const double pixelsPerSecond = Oscilloscope::self()->pixelsPerSecond();
if (!m_pixmap) {
qWarning() << Q_FUNC_INFO << " unexpected null m_pixmap in " << this;
return;
}
QPainter p;
//m_pixmap->fill( paletteBackgroundColor());
m_pixmap->fill( palette().color( backgroundRole() ));
const bool startSuccess = p.begin(m_pixmap);
if ((!startSuccess) || (!p.isActive())) {
qWarning() << Q_FUNC_INFO << " painter is not active";
}
p.setClipRegion(e->region());
//BEGIN Draw vertical marker lines
const double divisions = 5.0;
const double min_sep = 10.0;
double spacing = pixelsPerSecond/(std::pow( divisions, std::floor(std::log(pixelsPerSecond/min_sep)/std::log(divisions))));
// Pixels offset is the number of pixels that the view is scrolled along
const int64_t pixelsOffset = int64_t(Oscilloscope::self()->scrollTime()*pixelsPerSecond/LOGIC_UPDATE_RATE);
double linesOffset = - lld_modulus( pixelsOffset, spacing);
int blackness = 256 - int(184.0 * spacing / (min_sep*divisions*divisions));
p.setPen( QColor( blackness, blackness, blackness));
for( double i = linesOffset; i <= frameRect().width(); i += spacing)
p.drawLine( int(i), 1, int(i), frameRect().height()-2);
spacing *= divisions;
linesOffset = - lld_modulus( pixelsOffset, spacing);
blackness = 256 - int(184.0 * spacing / (min_sep*divisions*divisions));
p.setPen( QColor( blackness, blackness, blackness));
for( double i = linesOffset; i <= frameRect().width(); i += spacing)
p.drawLine( int(i), 1, int(i), frameRect().height()-2);
spacing *= divisions;
linesOffset = - lld_modulus( pixelsOffset, spacing);
blackness = 256 - int(184.0);
p.setPen( QColor( blackness, blackness, blackness));
for( double i = linesOffset; i <= frameRect().width(); i += spacing)
p.drawLine( int(i), 1, int(i), frameRect().height()-2);
//END Draw vertical marker lines
drawLogicData(p);
drawFloatingData(p);
p.setPen(Qt::black);
p.drawRect( frameRect());
b_needRedraw = false;
}
//bitBlt( this, r.x(), r.y(), m_pixmap, r.x(), r.y(), r.width(), r.height()); // 2018.12.07
QPainter p;
const bool paintStarted = p.begin(this);
if (!paintStarted) {
qWarning() << Q_FUNC_INFO << " failed to start painting ";
}
p.drawImage(r, m_pixmap->toImage(), r);
}
示例10: begin
bool FLPicturePrivate::begin() {
if ( !pte->isActive() )
return pte->begin( pic );
return false;
}
示例11: GetThumbnail
STDMETHODIMP CThumbnailProvider::GetThumbnail(UINT cx,
HBITMAP *phbmp,
WTS_ALPHATYPE *pdwAlpha)
{
*phbmp = NULL;
*pdwAlpha = WTSAT_ARGB;
int width, height;
QSize size = renderer.defaultSize();
if(size.width() == size.height()){
width = cx;
height = cx;
} else if (size.width() > size.height()){
width = cx;
height = size.height() * ((double)cx / (double)size.width());
} else {
width = size.width() * ((double)cx / (double)size.height());
height = cx;
}
QFile * f = new QFile("C:\\dev\\svg.log");
f->open(QFile::Append);
f->write(QString("Size: %1 \n.").arg(cx).toAscii());
f->flush();
f->close();
QImage * device = new QImage(width, height, QImage::Format_ARGB32);
device->fill(Qt::transparent);
QPainter * painter = new QPainter();
QFont font;
QColor color_font = QColor(255, 0, 0);
painter->begin(device);
painter->setRenderHints(QPainter::Antialiasing |
QPainter::SmoothPixmapTransform |
QPainter::TextAntialiasing);
assert(device->paintingActive() && painter->isActive());
if(loaded){
renderer.render(painter);
} else {
int font_size = cx / 10;
font.setStyleHint(QFont::Monospace);
font.setPixelSize(font_size);
painter->setPen(color_font);
painter->setFont(font);
painter->drawText(font_size, (cx - font_size) / 2, "Invalid SVG file.");
}
painter->end();
assert(!device->isNull());
#ifndef NDEBUG
device->save(QString("C:\\dev\\%1.png").arg(QDateTime::currentMSecsSinceEpoch()), "PNG");
#endif
*phbmp = QPixmap::fromImage(*device).toWinHBITMAP(QPixmap::Alpha);
assert(*phbmp != NULL);
delete painter;
delete device;
if( *phbmp != NULL )
return NOERROR;
return E_NOTIMPL;
}