Debian Codegraph @

libUnionImage/UnionImage/unionimage.h

raw
1 /*
2 * Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd.
3 *
4 * Author: ZhangYong <[email protected]>
5 *
6 * Maintainer: ZhangYong <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #ifndef UNIONIMAGE_H
22 #define UNIONIMAGE_H
23
24 #include <QtCore/qglobal.h>
25
26 #if defined(UNIONIMAGE_LIBRARY)
27 # define UNIONIMAGESHARED_EXPORT Q_DECL_EXPORT
28 #else
29 # define UNIONIMAGESHARED_EXPORT Q_DECL_IMPORT
30 #endif
31
32 #include <QHash>
33 #include <QString>
34 #include <QByteArray>
35 #include <QImage>
36 #include <QFileInfo>
37 #include <QStringList>
38 #include <QMap>
39
40 namespace UnionImage_NameSpace {
41
42 enum SupportType {
43 UNKNOWNTYPE = 0, // unknown type
44 BITMAP = 1, // standard image : 1-, 4-, 8-, 16-, 24-, 32-bit
45 UINT16 = 2, // array of unsigned short : unsigned 16-bit
46 INT16 = 3, // array of short : signed 16-bit
47 UINT32 = 4, // array of unsigned long : unsigned 32-bit
48 INT32 = 5, // array of long : signed 32-bit
49 FLOAT = 6, // array of float : 32-bit IEEE floating point
50 DOUBLE = 7, // array of double : 64-bit IEEE floating point
51 COMPLEX = 8, // array of FICOMPLEX : 2 x 64-bit IEEE floating point
52 RGB16 = 9, // 48-bit RGB image : 3 x 16-bit
53 RGBA16 = 10, // 64-bit RGBA image : 4 x 16-bit
54 RGBF = 11, // 96-bit RGB float image : 3 x 32-bit IEEE floating point
55 RGBAF = 12 // 128-bit RGBA float image : 4 x 32-bit IEEE floating point
56 };
57
58 UNIONIMAGESHARED_EXPORT QString unionImageVersion();
59
60 /**
61 * @brief UnionImageSupporFormat
62 * @return const QStringList
63 * @author DJH
64 * 返回UnionImage支持的所有格式
65 * StaticFormat返回支持的静态图片
66 * DynamicFormat返回支持的动态图片
67 */
68 UNIONIMAGESHARED_EXPORT const QStringList unionImageSupportFormat();
69 UNIONIMAGESHARED_EXPORT const QStringList supportStaticFormat();
70 UNIONIMAGESHARED_EXPORT const QStringList supportMovieFormat();
71
72
73 UNIONIMAGESHARED_EXPORT bool isDynamicFormat();
74 /**
75 * @brief CreatNewImage
76 * @param[out] res
77 * @param[in] width
78 * @param[in] height
79 * @param[in] depth
80 * @param[in] type
81 * @return bool
82 * @author DJH
83 * 创建一个可以自定义深度和颜色空间的图片
84 */
85 UNIONIMAGESHARED_EXPORT bool creatNewImage(QImage &res, int width = 0, int height = 0, int depth = 0, SupportType type = UNKNOWNTYPE);
86
87 /**
88 * @brief LoadImageFromFile
89 * @param[in] path
90 * @param[out] res
91 * @param[out] errorMsg
92 * @return bool
93 * @author DJH
94 * 从文件载入图片
95 * 载入成功返回true,图片数据返回到res
96 * 载入失败返回false,如果需要可以读取errorMsg返回错误信息
97 * 载入动态图片时,只会返回动态图片的第一帧,如果需要动图请使用UUnionMovieImage
98 */
99 UNIONIMAGESHARED_EXPORT bool loadStaticImageFromFile(const QString &path, QImage &res, QString &errorMsg, const QString &format_bar = "");
100
101 /**
102 * @brief detectImageFormat
103 * @param path
104 * @return QString
105 * 返回图片的真格式
106 */
107 UNIONIMAGESHARED_EXPORT QString detectImageFormat(const QString &path);
108
109 /**
110 * @brief isNoneQImage
111 * @param[in] qi
112 * @return bool
113 * @author DJH
114 * 判断是否为空图
115 */
116 UNIONIMAGESHARED_EXPORT bool isNoneQImage(const QImage &qi);
117
118 /**
119 * @brief rotateImage
120 * @param[in] angel
121 * @param[out] image
122 * @return bool
123 * @author DJH
124 * 在内存中旋转图片
125 */
126 UNIONIMAGESHARED_EXPORT bool rotateImage(int angel, QImage &image);
127
128 /**
129 * @brief rotateImageFile
130 * @param[in] angel
131 * @param[in] path
132 * @param[out] erroMsg
133 * @return bool
134 * @author DJH
135 * 旋转图片文件,旋转成功返回true,失败返回false
136 * 当不需要获取旋转图片的结果或者只有文件地址时调用该函数
137 * 失败时会将错误信息写入erroMsg
138 */
139 UNIONIMAGESHARED_EXPORT bool rotateImageFile(int angel, const QString &path, QString &erroMsg);
140
141 /**
142 * @brief rotateImageFile
143 * @param[in] angel
144 * @param[in][out] img
145 * @param[in] path
146 * @param[out] erroMsg
147 * @return bool
148 * @author DJH
149 * 旋转图片文件,旋转成功返回true,失败返回false
150 * 旋转成功会同时旋转img
151 * 图片为空则不会旋转返回失败,失败时会将错误信息写入erroMsg
152 */
153 UNIONIMAGESHARED_EXPORT bool rotateImageFileWithImage(int angel, QImage &img, const QString &path, QString &erroMsg);
154
155 /**
156 * @brief getAllMetaData
157 * @param path
158 * @author LMH
159 * @return QMap<QString, QString>
160 * 获取图片的所有数据,包括创建时间、修改时间、大小等
161 */
162 UNIONIMAGESHARED_EXPORT QMap<QString, QString> getAllMetaData(const QString &path);
163
164 /**
165 * @brief isImageSupportRotate
166 * @param path
167 * @author LMH
168 * @return bool
169 * 图片是否可以旋转
170 */
171 UNIONIMAGESHARED_EXPORT bool isImageSupportRotate(const QString &path);
172
173 /**
174 * @brief canSave
175 * @param path
176 * @author LMH
177 * @return bool
178 * 图片是否可以保存
179 */
180 UNIONIMAGESHARED_EXPORT bool canSave(const QString &path);
181
182 /**
183 * @brief getOrientation
184 * @param path
185 * @author LMH
186 * @return QString
187 * 获得图片的数据
188 */
189 UNIONIMAGESHARED_EXPORT const QString getOrientation(const QString &path);
190
191 QT_BEGIN_NAMESPACE
192
193 class UnionMovieImagePrivate;
194 /**
195 * @brief The UnionDynamicImage class
196 * @author DJH
197 * 用来读取动态图片,使用下标来获取动图的每一帧
198 */
199 class UNIONIMAGESHARED_EXPORT UnionMovieImage
200 {
201 public:
202 explicit UnionMovieImage();
203 ~UnionMovieImage();
204
205 void setFileName(const QString &path);
206
207 /**
208 * @brief next
209 * @return QImage
210 * 返回下一帧,该函数可以循环调用
211 */
212 QImage next();
213
214 private:
215 UnionMovieImagePrivate *const d_ptr;
216 Q_DECLARE_PRIVATE(UnionMovieImage)
217 Q_DISABLE_COPY(UnionMovieImage)
218 };
219
220 QT_END_NAMESPACE
221
222 };
223
224
225 #endif // UNIONIMAGE_H