Undo and Redo and KisPainter

Boudewijn Rempt boud at valdyas.org
Thu Dec 11 22:15:07 CET 2003


On Thursday 11 December 2003 22:05, Patrick Julien wrote:

> Can you post what the mouse move, I would think the problem is actually
> there.
>

Sure:

From

void KisToolBrush::mouseMove(QMouseEvent *e)
{
 	if (m_mode == PAINT) {
 		paint(e->pos(), 128, 0, 0);
 	}
	
}

To:

void KisToolBrush::paint(const QPoint & pos, 
			 const Q_INT32 /*pressure*/,
			 const Q_INT32 /*xTilt*/,
			 const Q_INT32 /*yTilt*/)
{
	KisImageSP currentImage = m_subject -> currentImg();

	if (!currentImage) return;

	QImage img = m_subject -> currentBrush() -> img();
	KisLayerSP tmpLayer = new KisLayer(img.width(), img.height(), 
					   currentImage->imgType(), "dab");
	tmpLayer->opacity(OPACITY_TRANSPARENT);
	for (int x = 0; x < img.width(); x++) {
		for (int y = 0; y < img.height(); y++) {
			QRgb c = img.pixel(x,y);
			QUANTUM a = ((255 - qRed(c))
				     + (255 - qGreen(c))
				     + (255 - qBlue(c))) / 3;
			tmpLayer->setPixel(x, y, m_subject -> fgColor(), a);
		}
	}
        KisPaintDeviceSP device = currentImage -> activeDevice();
        if (device) {
		KisPainter p( device );
		// This is the interesting bit, I guess.
		p.bitBlt( pos.x(),  pos.y(),  COMPOSITE_NORMAL, tmpLayer.data() );
		device->anchor();
	}
        currentImage->invalidate( pos.x(),  pos.y(),  
				  tmpLayer->width(),  
				  tmpLayer->height() );
	currentImage -> notify(pos.x(), 
			pos.y(), 
			tmpLayer -> width(), 
			tmpLayer -> height());
}

-- 
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/20031211/39822b2c/attachment.pgp


More information about the kimageshop mailing list