992 p.setTransform(QTransform(-1,0,0,-1,173.5,153.5)); |
993 p.setTransform(QTransform(-1,0,0,-1,173.5,153.5)); |
993 qDrawBorderPixmap(&p, QRect(0,0,75,105), QMargins(39,39,39,39), src, QRect(0,0,79,79), QMargins(39,39,39,39), |
994 qDrawBorderPixmap(&p, QRect(0,0,75,105), QMargins(39,39,39,39), src, QRect(0,0,79,79), QMargins(39,39,39,39), |
994 QTileRules(Qt::StretchTile,Qt::StretchTile), 0); |
995 QTileRules(Qt::StretchTile,Qt::StretchTile), 0); |
995 } |
996 } |
996 |
997 |
|
998 void tst_QPainter::drawPixmapFragments() |
|
999 { |
|
1000 QPixmap origPixmap(20, 20); |
|
1001 QPixmap resPixmap(20, 20); |
|
1002 QPainter::PixmapFragment fragments[4] = { {15, 15, 0, 0, 10, 10, 1, 1, 0, 1}, |
|
1003 { 5, 15, 10, 0, 10, 10, 1, 1, 0, 1}, |
|
1004 {15, 5, 0, 10, 10, 10, 1, 1, 0, 1}, |
|
1005 { 5, 5, 10, 10, 10, 10, 1, 1, 0, 1} }; |
|
1006 { |
|
1007 QPainter p(&origPixmap); |
|
1008 p.fillRect(0, 0, 10, 10, Qt::red); |
|
1009 p.fillRect(10, 0, 10, 10, Qt::green); |
|
1010 p.fillRect(0, 10, 10, 10, Qt::blue); |
|
1011 p.fillRect(10, 10, 10, 10, Qt::yellow); |
|
1012 } |
|
1013 { |
|
1014 QPainter p(&resPixmap); |
|
1015 p.drawPixmapFragments(fragments, 4, origPixmap); |
|
1016 } |
|
1017 |
|
1018 QImage origImage = origPixmap.toImage().convertToFormat(QImage::Format_ARGB32); |
|
1019 QImage resImage = resPixmap.toImage().convertToFormat(QImage::Format_ARGB32); |
|
1020 |
|
1021 QVERIFY(resImage.size() == resPixmap.size()); |
|
1022 QVERIFY(resImage.pixel(5, 5) == origImage.pixel(15, 15)); |
|
1023 QVERIFY(resImage.pixel(5, 15) == origImage.pixel(15, 5)); |
|
1024 QVERIFY(resImage.pixel(15, 5) == origImage.pixel(5, 15)); |
|
1025 QVERIFY(resImage.pixel(15, 15) == origImage.pixel(5, 5)); |
|
1026 |
|
1027 |
|
1028 QPainter::PixmapFragment fragment = QPainter::PixmapFragment::create(QPointF(20, 20), QRectF(30, 30, 2, 2)); |
|
1029 QVERIFY(fragment.x == 20); |
|
1030 QVERIFY(fragment.y == 20); |
|
1031 QVERIFY(fragment.sourceLeft == 30); |
|
1032 QVERIFY(fragment.sourceTop == 30); |
|
1033 QVERIFY(fragment.width == 2); |
|
1034 QVERIFY(fragment.height == 2); |
|
1035 QVERIFY(fragment.scaleX == 1); |
|
1036 QVERIFY(fragment.scaleY == 1); |
|
1037 QVERIFY(fragment.rotation == 0); |
|
1038 QVERIFY(fragment.opacity == 1); |
|
1039 } |
|
1040 |
997 void tst_QPainter::drawLine_data() |
1041 void tst_QPainter::drawLine_data() |
998 { |
1042 { |
999 QTest::addColumn<QLine>("line"); |
1043 QTest::addColumn<QLine>("line"); |
1000 |
1044 |
1001 QTest::newRow("0-45") << QLine(0, 20, 100, 0); |
1045 QTest::newRow("0-45") << QLine(0, 20, 100, 0); |