| 1 |
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#ifndef DIMAGEHANDLER_H |
| 6 |
#define DIMAGEHANDLER_H |
| 7 |
|
| 8 |
#include <dtkgui_global.h> |
| 9 |
#include <DObject> |
| 10 |
|
| 11 |
#include <QObject> |
| 12 |
#include <QImage> |
| 13 |
|
| 14 |
DGUI_BEGIN_NAMESPACE |
| 15 |
|
| 16 |
class DImageHandlerPrivate; |
| 17 |
class DImageHandler : public QObject, public DTK_CORE_NAMESPACE::DObject |
| 18 |
{ |
| 19 |
Q_OBJECT |
| 20 |
|
| 21 |
public: |
| 22 |
explicit DImageHandler(QObject *parent = nullptr); |
| 23 |
~DImageHandler(); |
| 24 |
|
| 25 |
void setFileName(const QString &fileName); |
| 26 |
QString fileName() const; |
| 27 |
|
| 28 |
QImage readImage(); |
| 29 |
QImage thumbnail(const QSize &size, Qt::AspectRatioMode mode); |
| 30 |
QString imageFormat() const; |
| 31 |
QSize imageSize(); |
| 32 |
QHash<QString, QString> findAllMetaData(); |
| 33 |
void clearCache(); |
| 34 |
|
| 35 |
bool saveImage(const QString &fileName, const QString &format = QString()); |
| 36 |
bool saveImage(const QImage &image, const QString &fileName, const QString &format = QString()); |
| 37 |
bool rotateImage(QImage &image, int angle); |
| 38 |
bool rotateImageFile(const QString &fileName, int angle); |
| 39 |
|
| 40 |
bool isReadable() const; |
| 41 |
bool isWriteable() const; |
| 42 |
bool isRotatable() const; |
| 43 |
|
| 44 |
QString lastError() const; |
| 45 |
|
| 46 |
static QStringList supportFormats(); |
| 47 |
static QString detectImageFormat(const QString &fileName); |
| 48 |
|
| 49 |
static QImage oldColorFilter(const QImage &img); |
| 50 |
static QImage warmColorFilter(const QImage &img, int intensity = 30); |
| 51 |
static QImage coolColorFilter(const QImage &img, int intensity = 30); |
| 52 |
static QImage grayScaleColorFilter(const QImage &img); |
| 53 |
static QImage antiColorFilter(const QImage &img); |
| 54 |
static QImage metalColorFilter(const QImage &img); |
| 55 |
|
| 56 |
static QImage bilateralFilter(const QImage &img, double spatialDecay = 0.02, double photometricStandardDeviation = 10); |
| 57 |
static QImage contourExtraction(const QImage &img); |
| 58 |
static QImage binaryzation(const QImage &img); |
| 59 |
static QImage grayScale(const QImage &img); |
| 60 |
|
| 61 |
static QImage laplaceSharpen(const QImage &img); |
| 62 |
static QImage sobelEdgeDetector(const QImage &img); |
| 63 |
|
| 64 |
static QImage changeLightAndContrast(const QImage &img, int light = 100, int contrast = 150); |
| 65 |
static QImage changeBrightness(const QImage &img, int brightness); |
| 66 |
static QImage changeTransparency(const QImage &img, int transparency); |
| 67 |
static QImage changeStauration(const QImage &img, int saturation); |
| 68 |
static QImage replacePointColor(const QImage &img, QColor oldColor, QColor newColor); |
| 69 |
|
| 70 |
static QImage flipHorizontal(const QImage &img); |
| 71 |
static QImage flipVertical(const QImage &img); |
| 72 |
|
| 73 |
private: |
| 74 |
D_DECLARE_PRIVATE(DImageHandler) |
| 75 |
Q_DISABLE_COPY(DImageHandler) |
| 76 |
}; |
| 77 |
|
| 78 |
DGUI_END_NAMESPACE |
| 79 |
|
| 80 |
#endif // DIMAGEHANDLER_H |