Bwerk!
Patrick Julien
freak at codepimps.org
Wed Oct 8 20:13:11 CEST 2003
On October 8, 2003 05:04 pm, Boudewijn Rempt wrote:
> 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:
>
>
The raw tile stuff is actually 2 coordinates, not 1 coordinate and a size.
> 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.
More information about the kimageshop
mailing list