Finishing a paint action.

Boudewijn Rempt boud at valdyas.org
Thu Oct 9 15:58:05 CEST 2003


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
-------------- 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/20031009/88aec48c/attachment.bin


More information about the kimageshop mailing list