Bwerk!
Boudewijn Rempt
boud at valdyas.org
Thu Oct 9 00:04:14 CEST 2003
I managed to mess things up good and well...
I added the following to kis_painter, knowing full well I wasn't supposed to
mess about with QPixmaps, but still doing so for the sake of quick results:
void KisPainter::drawPolyline(const QPointArray& polyline)
{
QRect r = polyline.boundingRect();
r = r.normalize();
KisTileMgrSP tileMgr = m_device -> data();
// Let's hope that PJ counts from left-top to right-bottom, too,
KisPixelDataSP pixels = tileMgr->pixelData( r.left(),
r.top(),
r.right(),
r.bottom(),
TILEMODE_RW );
QImage image = QImage( ( int ) pixels->data,
r.width(),
r.height(),
tileMgr->depth() );
QPixmap buffer = QPixmap( image );
QPainter p;
p.begin(&buffer);
p.drawPolyline( polyline );
p.end();
tileMgr->writePixelData( pixels ); // memcpy to destination
tileMgr->releasePixelData( pixels ); // Is this necessary?
m_device->invalidate( r ); // And this?
}
And then I called that like this:
void KisToolBrush2::mouseMove(QMouseEvent *e)
{
if ( m_mousePressed ) {
m_polyline[2] = m_polyline[1];
m_polyline[1] = m_polyline[0];
m_polyline[0] = e->pos();
QRect r = m_polyline.boundingRect();
r = r.normalize();
KisImageSP img = m_view -> currentImg();
if (img) {
KisPaintDeviceSP device = img -> activeDevice();
if (device) {
KisPainter p;
p.begin(device);
p.drawPolyline( m_polyline );
p.end();
//m_doc -> addCommand(new Brush2Cmd(img));
device->anchor();
}
}
img -> invalidate(r);
m_view -> updateCanvas(r);
}
And now Krita crashes in drawPolyline, giving me the distinc impression I
should finish reading Accelerated C++ as soon as possible... Back to comfy
chair and the meditative pipe for now.
--
Boudewijn Rempt | http://www.valdyas.org/index2.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: signature
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20031008/586a86a7/attachment.bin
More information about the kimageshop
mailing list