summaryrefslogtreecommitdiff
path: root/noncore/graphics/drawpad/ellipsetool.cpp
authorleseb <leseb>2002-06-23 17:47:47 (UTC)
committer leseb <leseb>2002-06-23 17:47:47 (UTC)
commit6fd46f6d23538ec6e0f48209f6c0f0d939a2effe (patch) (unidiff)
tree2a5d407155f72dc5496d3a7d412922cc6be97e61 /noncore/graphics/drawpad/ellipsetool.cpp
parent3251c55f854ecbd4ece8bf169177ffac28081aaa (diff)
downloadopie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.zip
opie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.tar.gz
opie-6fd46f6d23538ec6e0f48209f6c0f0d939a2effe.tar.bz2
Anti-aliasing as an option
Diffstat (limited to 'noncore/graphics/drawpad/ellipsetool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/ellipsetool.cpp57
1 files changed, 31 insertions, 26 deletions
diff --git a/noncore/graphics/drawpad/ellipsetool.cpp b/noncore/graphics/drawpad/ellipsetool.cpp
index 733bade..0cdb731 100644
--- a/noncore/graphics/drawpad/ellipsetool.cpp
+++ b/noncore/graphics/drawpad/ellipsetool.cpp
@@ -32,40 +32,45 @@ void EllipseTool::drawFinalShape(QPainter& p)
32{ 32{
33 p.setRasterOp(Qt::NotROP); 33 p.setRasterOp(Qt::NotROP);
34 p.drawRect(QRect(m_polyline[2], m_polyline[0])); 34 p.drawRect(QRect(m_polyline[2], m_polyline[0]));
35 p.setRasterOp(Qt::CopyROP);
35 36
36 QRect r = m_polyline.boundingRect(); 37 if (m_pDrawPad->antiAliasing()) {
37 r = r.normalize(); 38 QRect r = m_polyline.boundingRect();
38 r.setLeft(r.left() - m_pDrawPad->pen().width()); 39 r = r.normalize();
39 r.setTop(r.top() - m_pDrawPad->pen().width()); 40 r.setLeft(r.left() - m_pDrawPad->pen().width());
40 r.setRight(r.right() + m_pDrawPad->pen().width()); 41 r.setTop(r.top() - m_pDrawPad->pen().width());
41 r.setBottom(r.bottom() + m_pDrawPad->pen().width()); 42 r.setRight(r.right() + m_pDrawPad->pen().width());
43 r.setBottom(r.bottom() + m_pDrawPad->pen().width());
42 44
43 QPixmap areaPixmap(r.width(), r.height()); 45 QPixmap areaPixmap(r.width(), r.height());
44 bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); 46 bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r);
45 47
46 QImage areaImage = areaPixmap.convertToImage(); 48 QImage areaImage = areaPixmap.convertToImage();
47 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); 49 QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3);
48 50
49 QPixmap bigAreaPixmap; 51 QPixmap bigAreaPixmap;
50 bigAreaPixmap.convertFromImage(bigAreaImage); 52 bigAreaPixmap.convertFromImage(bigAreaImage);
51 53
52 QPen bigAreaPen = m_pDrawPad->pen(); 54 QPen bigAreaPen = m_pDrawPad->pen();
53 bigAreaPen.setWidth(bigAreaPen.width() * 3); 55 bigAreaPen.setWidth(bigAreaPen.width() * 3);
54 56
55 QPainter bigAreaPainter; 57 QPainter bigAreaPainter;
56 bigAreaPainter.begin(&bigAreaPixmap); 58 bigAreaPainter.begin(&bigAreaPixmap);
57 bigAreaPainter.setPen(bigAreaPen); 59 bigAreaPainter.setPen(bigAreaPen);
58 bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, 60 bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1,
59 bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), 61 bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1),
60 bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); 62 bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1)));
61 bigAreaPainter.end(); 63 bigAreaPainter.end();
62 64
63 bigAreaImage = bigAreaPixmap.convertToImage(); 65 bigAreaImage = bigAreaPixmap.convertToImage();
64 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); 66 areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3);
65 areaPixmap.convertFromImage(areaImage); 67 areaPixmap.convertFromImage(areaImage);
66 68
67 p.setRasterOp(Qt::CopyROP); 69 p.drawPixmap(r.x(), r.y(), areaPixmap);
68 p.drawPixmap(r.x(), r.y(), areaPixmap); 70 } else {
71 p.setPen(m_pDrawPad->pen());
72 p.drawEllipse(QRect(m_polyline[2], m_polyline[0]));
73 }
69} 74}
70 75
71void EllipseTool::drawTemporaryShape(QPainter& p) 76void EllipseTool::drawTemporaryShape(QPainter& p)