From kde-kimageshop Thu Oct 09 12:58:05 2003 From: Boudewijn Rempt Date: Thu, 09 Oct 2003 12:58:05 +0000 To: kde-kimageshop Subject: Re: Finishing a paint action. X-MARC-Message: https://marc.info/?l=kde-kimageshop&m=106570489714198 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============041808712110863011==" --===============041808712110863011== Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_jtVh/lF64wtBAsW"; charset="iso-8859-1" Content-Transfer-Encoding: 7bit --Boundary-02=_jtVh/lF64wtBAsW Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline 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 pres= ent=20 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= =20 operations) to KisPainter now: void KisPainter::drawPolyline(const QPointArray& polyline) { QRect r =3D polyline.boundingRect(); r =3D r.normalize(); KisTileMgrSP tileMgr =3D m_device -> data(); KisPixelDataSP pd =3D new KisPixelData; QImage img; pd -> mgr =3D 0; pd -> tile =3D 0; pd -> mode =3D TILEMODE_READ; pd -> x1 =3D r.x(); pd -> x2 =3D r.x() + r.width() -1; pd -> y1 =3D r.y(); pd -> y2 =3D r.y() + r.height() - 1; pd -> width =3D pd -> x2 - pd -> x1 + 1; pd -> height =3D pd -> y2 - pd -> y1 + 1; pd -> depth =3D tileMgr -> depth(); pd -> stride =3D pd -> depth * pd -> width; pd -> owner =3D false; // XXX: this assumes RGBA. pd -> data =3D new QUANTUM[pd->width * pd->height * 4]; tileMgr -> readPixelData(pd); img =3D QImage(pd -> data, pd -> width, pd -> height, pd -> depth * CHAR_BIT, 0, 0, QImage::LittleEndian); QPixmap buffer =3D QPixmap( img ); QPainter p; p.begin(&buffer); p.translate( -r.x(), -r.y() ); p.drawPolyline( polyline ); p.end(); img =3D buffer.convertToImage(); pd-> data =3D img.bits(); tileMgr->writePixelData( pd ); } And that works... After a fashion, and is not too slow. I'll add more=20 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=20 pd-> data =3D img.bits(); tileMgr->writePixelData( pd ); With code that does to a QImage what the image-magick based builder does;=20 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=20 inefficient. But as long as I haven't finished reading Newman & Sproul, Hea= rn=20 & Baker and Foley & van Dam, I don't feel up to coding tile-aware graphics= =20 primitives myself. =2D-=20 Boudewijn Rempt | http://www.valdyas.org/index2.html --Boundary-02=_jtVh/lF64wtBAsW Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQA/hVtjdaCcgCmN5d8RAj/xAJ9bIbNfa5qtPGXE0y1VJSvV8ji2TwCglSO3 o0END86BGtNOLn0vX06U+nk= =499d -----END PGP SIGNATURE----- --Boundary-02=_jtVh/lF64wtBAsW-- --===============041808712110863011== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kimageshop mailing list kimageshop@mail.kde.org http://mail.kde.org/mailman/listinfo/kimageshop --===============041808712110863011==--