/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Copyright (C) 2016 Ivailo Monev ** ** This file is part of the test suite of the Katie Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** ** GNU Lesser General Public License Usage ** This file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #include Q_DECLARE_METATYPE(QImage::Format) /* Fill a image with "random" pixel values. */ static QImage generateImage(const QSize &size, const QImage::Format format) { QImage image(size.width(), size.height(), format); bool oddnumber = true; for (int y = 0; y < image.height(); ++y) { for (int x = 0; x < image.width(); ++x) { if (image.depth() == 1) { image.setPixel(x, y, uint(oddnumber)); oddnumber = !oddnumber; } else { image.setPixel(x, y, x ^ y); } } } return image; } class tst_QImageConversion : public QObject { Q_OBJECT private slots: void convertToFormat_data(); void convertToFormat(); }; void tst_QImageConversion::convertToFormat_data() { QTest::addColumn("sourceFormat"); QTest::addColumn("targetFormat"); QTest::addColumn("size"); QList sizes; sizes << QSize(1, 1) << QSize(10, 10) << QSize(100, 100) << QSize(1000, 1000); const char *formatNames[] = { "Invalid", "Mono", "MonoLSB", "RGB32", "ARGB32", "ARGB32_pm", "RGB16", }; for (int tar=1; tar