diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-06-04 16:41:47 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-06-05 08:20:19 (GMT) |
commit | fd6e80b7cc36ebc111d062301ba8bfca5e6e6f50 (patch) | |
tree | 29b1720a5e251045c9ebf0e7331c790b8d6390f0 /tests/auto | |
parent | 7b9b55e3a0deb69a6ff04ee9b76840a5f8d11545 (diff) | |
download | Qt-fd6e80b7cc36ebc111d062301ba8bfca5e6e6f50.zip Qt-fd6e80b7cc36ebc111d062301ba8bfca5e6e6f50.tar.gz Qt-fd6e80b7cc36ebc111d062301ba8bfca5e6e6f50.tar.bz2 |
Introduce Symbian CFbsBitmap <-> QPixmap conversion functions.
Introduce functions for converting to and from a CFbsBitmap on Symbian.
Currently these functions unfortunately have to copy the data to the
internal QImage stored in the raster pixmap data backend :( Hopefully
we can improve this with a native Symbian pixmap backend in the future.
The autotest generates both small and large CFbsBitmaps of different
formats and then verifies that the color makes it into the QPixmap.
Currently the indexed image formats don't seem to work, but this is
most likely because we don't set a palette for them. The semi-trans
bitmaps seem to work fine (verified visually), but the current QCOMPARE
doesn't consider the fact that the color was alpha blended.
Reviewed-by: Sami Merilä
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qpixmap/qpixmap.pro | 19 | ||||
-rw-r--r-- | tests/auto/qpixmap/tst_qpixmap.cpp | 101 |
2 files changed, 108 insertions, 12 deletions
diff --git a/tests/auto/qpixmap/qpixmap.pro b/tests/auto/qpixmap/qpixmap.pro index aa767aa..c992f6e 100644 --- a/tests/auto/qpixmap/qpixmap.pro +++ b/tests/auto/qpixmap/qpixmap.pro @@ -1,26 +1,21 @@ load(qttest_p4) SOURCES += tst_qpixmap.cpp contains(QT_CONFIG, qt3support): QT += qt3support -wince*: { +wince*|symbian*: { task31722_0.sources = convertFromImage/task31722_0/* task31722_0.path = convertFromImage/task31722_0 task31722_1.sources = convertFromImage/task31722_1/* task31722_1.path = convertFromImage/task31722_1 DEPLOYMENT += task31722_0 task31722_1 - DEFINES += SRCDIR=\\\".\\\" } -symbian*:{ - task31722_0.sources = convertFromImage/task31722_0/* - task31722_0.path = convertFromImage/task31722_0 - task31722_1.sources = convertFromImage/task31722_1/* - task31722_1.path = convertFromImage/task31722_1 - DEPLOYMENT += task31722_0 task31722_1 + +wince*: { + DEFINES += SRCDIR=\\\".\\\" +} symbian*: { DEPLOYMENT_PLUGIN += qmng -} -else { + LIBS += -lfbscli.lib -lbitgdi.lib -lgdi.lib +} else { DEFINES += SRCDIR=\\\"$$PWD\\\" win32:LIBS += -lgdi32 -luser32 } - - diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 493333b..9f73e34 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -58,6 +58,14 @@ #include <qscreen_qws.h> #endif +#ifdef Q_OS_SYMBIAN +#include <e32std.h> +#include <fbs.h> +#include <gdi.h> +#include <bitdev.h> +#endif + + //TESTED_CLASS= //TESTED_FILES= #if defined(Q_OS_SYMBIAN) @@ -120,6 +128,11 @@ private slots: void fromWinHBITMAP(); #endif +#if defined(Q_WS_S60) + void fromSymbianCFbsBitmap_data(); + void fromSymbianCFbsBitmap(); +#endif + void onlyNullPixmapsOutsideGuiThread(); void refUnref(); @@ -798,6 +811,94 @@ void tst_QPixmap::fromWinHBITMAP() #endif +#if defined(Q_WS_S60) +Q_DECLARE_METATYPE(TDisplayMode) + +void tst_QPixmap::fromSymbianCFbsBitmap_data() +{ + QTest::addColumn<TDisplayMode>("format"); + QTest::addColumn<int>("width"); + QTest::addColumn<int>("height"); + QTest::addColumn<QColor>("color"); + + const int smallWidth = 20; + const int smallHeight = 20; + const int largeWidth = 240; + const int largeHeight = 320; + + // Indexed Color Formats - Disabled since images seem to be blank -> no palette? +// QTest::newRow("EGray2 small") << EGray2 << smallWidth << smallHeight << QColor(Qt::black); +// QTest::newRow("EGray2 big") << EGray2 << largeWidth << largeHeight << QColor(Qt::black); +// QTest::newRow("EGray256 small") << EGray256 << smallWidth << smallHeight << QColor(Qt::blue); +// QTest::newRow("EGray256 big") << EGray256 << largeWidth << largeHeight << QColor(Qt::blue); +// QTest::newRow("EColor256 small") << EColor256 << smallWidth << smallHeight << QColor(Qt::red); +// QTest::newRow("EColor256 big") << EColor256 << largeWidth << largeHeight << QColor(Qt::red); + + // Direct Color Formats + QTest::newRow("EColor4K small") << EColor4K << smallWidth << smallHeight << QColor(Qt::red); + QTest::newRow("EColor4K big") << EColor4K << largeWidth << largeHeight << QColor(Qt::red); + QTest::newRow("EColor64K small") << EColor64K << smallWidth << smallHeight << QColor(Qt::green); + QTest::newRow("EColor64K big") << EColor64K << largeWidth << largeHeight << QColor(Qt::green); + QTest::newRow("EColor16MU small") << EColor16MU << smallWidth << smallHeight << QColor(Qt::red); + QTest::newRow("EColor16MU big") << EColor16MU << largeWidth << largeHeight << QColor(Qt::red); + QTest::newRow("EColor16MA small opaque") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0); + QTest::newRow("EColor16MA big opaque") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0); + + // Semi-transparent Colors - Disabled for now, since the QCOMPARE fails, but visually confirmed to work +// QTest::newRow("EColor16MA small semi") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 127); +// QTest::newRow("EColor16MA big semi") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0, 127); +// QTest::newRow("EColor16MA small trans") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 0); +// QTest::newRow("EColor16MA big trans") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0, 0); + +#if !defined(__SERIES60_31__) && !defined(__S60_32__) + QTest::newRow("EColor16MAP small") << EColor16MAP << smallWidth << smallHeight << QColor(Qt::red); + QTest::newRow("EColor16MAP big") << EColor16MAP << largeWidth << largeHeight << QColor(Qt::red); +#endif +} + +void tst_QPixmap::fromSymbianCFbsBitmap() +{ + QFETCH(TDisplayMode, format); + QFETCH(int, width); + QFETCH(int, height); + QFETCH(QColor, color); + int expectedDepth = TDisplayModeUtils::NumDisplayModeBitsPerPixel(format); + + CFbsBitmap *nativeBitmap = 0; + CFbsBitmapDevice *bitmapDevice = 0; + CBitmapContext *bitmapContext = 0; + + nativeBitmap = new (ELeave) CFbsBitmap(); + TInt err = nativeBitmap->Create(TSize(width, height), format); + CleanupStack::PushL(nativeBitmap); + QVERIFY(err == KErrNone); + bitmapDevice = CFbsBitmapDevice::NewL(nativeBitmap); + CleanupStack::PushL(bitmapDevice); + + err = bitmapDevice->CreateBitmapContext(bitmapContext); + CleanupStack::PushL(bitmapContext); + QVERIFY(err == KErrNone); + TRgb symbianColor = TRgb(color.red(), color.green(), color.blue(), color.alpha()); + bitmapContext->SetBrushColor(symbianColor); + bitmapContext->Clear(); + + __UHEAP_MARK; + { // Test the normal case + QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(nativeBitmap); +// QCOMPARE(pixmap.depth(), expectedDepth); // Depth is not preserved now + QCOMPARE(pixmap.width(), width); + QCOMPARE(pixmap.height(), height); + QImage image = pixmap.toImage(); + + QColor actualColor(image.pixel(1, 1)); + QCOMPARE(actualColor, color); + } + __UHEAP_MARKEND; + + CleanupStack::PopAndDestroy(3); +} +#endif + void tst_QPixmap::onlyNullPixmapsOutsideGuiThread() { #if !defined(Q_WS_WIN) |