summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-19 06:28:00 (UTC)
committer leseb <leseb>2002-06-19 06:28:00 (UTC)
commitf2cf56b43d80c16329bda01f9e37e52fb8546816 (patch) (unidiff)
treee94db34e932ca1f135f98642a6f15b03f32c920d
parentb83e9d1f794fdd6089beda10697243bb087e3d0a (diff)
downloadopie-f2cf56b43d80c16329bda01f9e37e52fb8546816.zip
opie-f2cf56b43d80c16329bda01f9e37e52fb8546816.tar.gz
opie-f2cf56b43d80c16329bda01f9e37e52fb8546816.tar.bz2
Anti-aliasing support
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/linetool.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/noncore/graphics/drawpad/linetool.cpp b/noncore/graphics/drawpad/linetool.cpp
index 94ca165..1480df2 100644
--- a/noncore/graphics/drawpad/linetool.cpp
+++ b/noncore/graphics/drawpad/linetool.cpp
@@ -18,2 +18,5 @@
18 18
19#include <qimage.h>
20#include <qpixmap.h>
21
19LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 22LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
@@ -31,5 +34,45 @@ void LineTool::drawFinalShape(QPainter& p)
31 p.drawLine(m_polyline[2], m_polyline[0]); 34 p.drawLine(m_polyline[2], m_polyline[0]);
32 p.setPen(m_pDrawPad->pen()); 35
36 QRect r = m_polyline.boundingRect();
37 r = r.normalize();
38 r.setLeft(r.left() - m_pDrawPad->pen().width());
39 r.setTop(r.top() - m_pDrawPad->pen().width());
40 r.setRight(r.right() + m_pDrawPad->pen().width());
41 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
42
43 QPixmap areaPixmap(r.width(), r.height());
44 bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
45
46 QImage areaImage = areaPixmap.convertToImage();
47 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
48
49 QPixmap bigAreaPixmap;
50 bigAreaPixmap.convertFromImage(bigAreaImage);
51
52 QPen bigAreaPen = m_pDrawPad->pen();
53 bigAreaPen.setWidth(bigAreaPen.width() * 3);
54
55 QPainter bigAreaPainter;
56 bigAreaPainter.begin(&bigAreaPixmap);
57 bigAreaPainter.setPen(bigAreaPen);
58
59 if (((m_polyline[2].x() < m_polyline[0].x()) && (m_polyline[2].y() < m_polyline[0].y()))
60 || ((m_polyline[2].x() > m_polyline[0].x()) && (m_polyline[2].y() > m_polyline[0].y()))) {
61
62 bigAreaPainter.drawLine(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
63 bigAreaPixmap.width() - bigAreaPen.width() - 2,
64 bigAreaPixmap.height() - bigAreaPen.width() - 2);
65 } else {
66 bigAreaPainter.drawLine(bigAreaPen.width() + 1, bigAreaPixmap.height() - bigAreaPen.width() - 2,
67 bigAreaPixmap.width() - bigAreaPen.width() - 2, bigAreaPen.width() + 1);
68 }
69
70 bigAreaPainter.end();
71
72 bigAreaImage = bigAreaPixmap.convertToImage();
73 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
74 areaPixmap.convertFromImage(areaImage);
75
33 p.setRasterOp(Qt::CopyROP); 76 p.setRasterOp(Qt::CopyROP);
34 p.drawLine(m_polyline[2], m_polyline[0]); 77 p.drawPixmap(r.x(), r.y(), areaPixmap);
35} 78}