[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    Bwerk!
From:       Boudewijn Rempt <boud () valdyas ! org>
Date:       2003-10-08 21:04:14
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


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

[Attachment #5 (application/pgp-signature)]

_______________________________________________
kimageshop mailing list
kimageshop@mail.kde.org
http://mail.kde.org/mailman/listinfo/kimageshop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic