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

List:       kde-kimageshop
Subject:    Re: Finishing a paint action.
From:       Boudewijn Rempt <boud () valdyas ! org>
Date:       2003-10-09 12:58:05
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Thursday 09 October 2003 01:12, Patrick Julien wrote:

> 1) invalidate will not do anything here.

But if it's not there, nothing shows up on screen -- even though it is present 
in the image data. If it's there, painting works as it should.

I've added a temporary drawPolyline (to be replaced with something a little
more intelligent that also supports undo/redo, colour strategies and raster 
operations) to KisPainter now:

void KisPainter::drawPolyline(const QPointArray& polyline)
{
    QRect r = polyline.boundingRect();
    r = r.normalize();

    KisTileMgrSP tileMgr =  m_device -> data();

    KisPixelDataSP pd = new KisPixelData;
    QImage img;

    pd -> mgr = 0;
    pd -> tile = 0;
    pd -> mode = TILEMODE_READ;
    pd -> x1 = r.x();
    pd -> x2 = r.x() + r.width() -1;
    pd -> y1 = r.y();
    pd -> y2 = r.y() + r.height() - 1;
    pd -> width = pd -> x2 - pd -> x1 + 1;
    pd -> height = pd -> y2 - pd -> y1 + 1;
    pd -> depth = tileMgr -> depth();
    pd -> stride = pd -> depth * pd -> width;
    pd -> owner = false;
    // XXX: this assumes RGBA.
    pd -> data = new QUANTUM[pd->width * pd->height * 4];

    tileMgr -> readPixelData(pd);
    img = QImage(pd -> data,
                 pd -> width, pd -> height,
                 pd -> depth * CHAR_BIT,
                 0, 0,
                 QImage::LittleEndian);


    QPixmap buffer = QPixmap( img );

    QPainter p;
    p.begin(&buffer);
    p.translate( -r.x(),  -r.y() );
    p.drawPolyline( polyline );
    p.end();

    img = buffer.convertToImage();
    pd-> data = img.bits();

    tileMgr->writePixelData( pd );
}

And that works... After a fashion, and is not too slow. I'll add more 
operations on this line, after all, once the tools work again, it's easy
to replace this code with intelligent code operation for operation.

One idea would be to replace 

    pd-> data = img.bits();
    tileMgr->writePixelData( pd );

With code that does to a QImage what the image-magick based builder does; 
create the necessary KisPaintDevice and blit that to the image; that would
support undo/redo and raster ops one go, even if it would be horribly 
inefficient. But as long as I haven't finished reading Newman & Sproul, Hearn 
& Baker and Foley & van Dam, I don't feel up to coding tile-aware graphics 
primitives myself.

-- 
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