scantools  1.0.4
Graphics manipulation with a view towards scanned documents
imageOperationsTest.h
1 /*
2  * Copyright © 2017 Stefan Kebekus <stefan.kebekus@math.uni-freiburg.de>
3  *
4  * This program is free software: you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation, either version 3 of the License, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 #include <QDebug>
20 #include <QtGlobal>
21 #include <QTest>
22 
23 class imageOperationsTest: public QObject
24 {
25  Q_OBJECT
26 
27  QImage Hydrogenea;
28  QImage Hydrogenea88;
29  QImage HydrogeneaGray;
30  QImage HydrogeneaBW;
31  QImage Monocolor;
32 
33 
34  // Test data
35  QVector<QImage> images;
36 
37  private slots:
38  void initTestCase();
39  void cleanupTestCase();
40 
41  void colors_data();
42  void colors();
43  void deAlpha_data();
44  void deAlpha();
45  void isBlackAndWhite_data();
46  void isBlackAndWhite();
47  void isOpaque_data();
48  void isOpaque();
49  void optimizedFormat_data();
50  void optimizedFormat();
52  void ToAndFromData_data();
53  void ToAndFromData();
54 };
bool isBlackAndWhite(const QImage &image)
Determine whether an image is black-and-white only.
QImage deAlpha(const QImage &image, QRgb background=0xFFFFFFFF)
Removes alpha channel from image.
QImage optimizedFormat(const QImage &inputImage)
Convert image to memory-saving format.
bool isOpaque(const QImage &image)
Check if the image is opaque.
QVector< QRgb > colors(const QImage &image)
Finds the set of all colors used in a given image.
QImage simplifyTransparentPixels(const QImage &image)
Replaces all fully transparent pixels by pixels of color 0x00FFFFFF (="fully transparent white")