scantools  1.0.4
Graphics manipulation with a view towards scanned documents
imageOperations.h
1 /*
2  * Copyright © 2017--2018 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 #ifndef imageOPERATIONS
20 #define imageOPERATIONS 1
21 
22 #include <QImage>
23 #include <QSet>
24 
25 
28 namespace imageOperations
29 {
42  QImage deAlpha(const QImage &image, QRgb background=0xFFFFFFFF);
43 
63  QVector<QRgb> colors(const QImage &image);
64 
80  bool isBlackAndWhite(const QImage &image);
81 
95  bool isOpaque(const QImage &image);
96 
124  QImage optimizedFormat(const QImage &inputImage);
125 
136  QImage simplifyTransparentPixels(const QImage &image);
137 
149 
162  PNG
163  };
164 
204  QByteArray QImageToData(const QImage &image, imageDataFilter filter=identity);
205 
225  QImage DataToQImage(const QByteArray &data, int width, int height, QImage::Format format, imageDataFilter filter=identity);
226 };
227 
228 #endif
The namespace imageOperations gathers static methods for handling, analyzing and manipulating QImages...
QImage DataToQImage(const QByteArray &data, int width, int height, QImage::Format format, imageDataFilter filter=identity)
Reconstructs an image from raw data, as written by QImageToData.
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.
imageDataFilter
Image Data Filters.
@ PNG
Filter defined in the PNG specification.
@ identity
The image data is returned without modification.
QByteArray QImageToData(const QImage &image, imageDataFilter filter=identity)
Returns the image raw data as a consecutive QByteArray.
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")