soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SImgDecoder-i.h
Go to the documentation of this file.
1/**
2 * @file SImgDecoder-i.h
3 * @brief Interface definitions for image decoding.
4 * @version v1.0
5 * @author SOUI group
6 * @date 2014-05-28
7 *
8 * This file contains the interface definitions for image decoding, including
9 * interfaces for image frames, image data, and image decoder factories.
10 */
11
12#ifndef __SIMGDECODER_I__H__
13#define __SIMGDECODER_I__H__
14
15#include <interface/obj-ref-i.h>
16
17SNSBEGIN
18
19/**
20 * @interface IImgFrame
21 * @brief Interface for an image frame.
22 *
23 * This interface represents a single frame of an image, which can be part of an
24 * animated image or a single static image.
25 */
26#undef INTERFACE
27#define INTERFACE IImgFrame
28DECLARE_INTERFACE_(IImgFrame, IObjRef)
29{
30 /**
31 * @brief Get the size of the image in pixels.
32 * @param [out] UINT * pWid - Pointer to store the image width.
33 * @param [out] UINT * pHei - Pointer to store the image height.
34 * @return BOOL - TRUE if successful, FALSE otherwise.
35 */
36 STDMETHOD_(BOOL, GetSize)(THIS_ UINT * pWid, UINT * pHei) PURE;
37
38 /**
39 * @brief Get the pixel buffer of the image.
40 * @return const VOID * - Pointer to the pixel buffer.
41 */
42 STDMETHOD_(const VOID *, GetPixels)(CTHIS) SCONST PURE;
43
44 /**
45 * @brief Get the delay time for a GIF image frame.
46 * @return int - Delay time in 10-millisecond units.
47 */
48 STDMETHOD_(int, GetDelay)(THIS) PURE;
49};
50
51/**
52 * @interface IImgX
53 * @brief Interface for image data.
54 *
55 * This interface represents the image data, which can contain multiple frames
56 * for animated images.
57 */
58#undef INTERFACE
59#define INTERFACE IImgX
60DECLARE_INTERFACE_(IImgX, IObjRef)
61{
62 /**
63 * @brief Increment the reference count.
64 * @return long - Current reference count.
65 */
66 STDMETHOD_(long, AddRef)(THIS) PURE;
67
68 /**
69 * @brief Decrement the reference count.
70 * @return long - Current reference count.
71 */
72 STDMETHOD_(long, Release)(THIS) PURE;
73
74 /**
75 * @brief Final release of the object.
76 */
77 STDMETHOD_(void, OnFinalRelease)(THIS) PURE;
78
79 /**
80 * @brief Load image data from a memory buffer.
81 * @param pBuf - Pointer to the buffer containing image data.
82 * @param bufLen - Size of the buffer.
83 * @return int - Result of the operation.
84 */
85 STDMETHOD_(int, LoadFromMemory)(THIS_ void *pBuf, size_t bufLen) PURE;
86
87 /**
88 * @brief Load image data from a file (Unicode encoding).
89 * @param pszFileName - File name (Unicode encoding).
90 * @return int - Result of the operation.
91 */
92 STDMETHOD_(int, LoadFromFileW)(THIS_ LPCWSTR pszFileName) PURE;
93
94 /**
95 * @brief Load image data from a file (ANSI encoding).
96 * @param pszFileName - File name (ANSI encoding).
97 * @return int - Result of the operation.
98 */
99 STDMETHOD_(int, LoadFromFileA)(THIS_ LPCSTR pszFileName) PURE;
100
101 /**
102 * @brief Get the number of frames in the image.
103 * @return UINT - Number of frames.
104 */
105 STDMETHOD_(UINT, GetFrameCount)(THIS) PURE;
106
107 /**
108 * @brief Get a specific frame of the image.
109 * @param iFrame - Index of the frame to retrieve.
110 * @return IImgFrame * - Pointer to the retrieved frame.
111 */
112 STDMETHOD_(IImgFrame *, GetFrame)(THIS_ UINT iFrame) PURE;
113};
114
115/**
116 * @enum ImgFmt
117 * @brief Image format enumeration.
118 *
119 * This enumeration defines the supported image formats.
120 */
121typedef enum _ImgFmt
122{
123 Img_PNG, /**< PNG format */
124 Img_BMP, /**< BMP format */
125 Img_TIFF, /**< TIFF format */
126 Img_JPG, /**< JPG format */
127 Img_Webp, /**< WebP format */
128 Img_TGA, /**< TGA format */
129} ImgFmt;
130
131/**
132 * @interface IImgDecoderFactory
133 * @brief Interface for image decoder factory.
134 *
135 * This interface provides methods to create image decoders and save images in
136 * various formats.
137 */
138#undef INTERFACE
139#define INTERFACE IImgDecoderFactory
140DECLARE_INTERFACE_(IImgDecoderFactory, IObjRef)
141{
142 /**
143 * @brief Increment the reference count.
144 * @return long - Current reference count.
145 */
146 STDMETHOD_(long, AddRef)(THIS) PURE;
147
148 /**
149 * @brief Decrement the reference count.
150 * @return long - Current reference count.
151 */
152 STDMETHOD_(long, Release)(THIS) PURE;
153
154 /**
155 * @brief Final release of the object.
156 */
157 STDMETHOD_(void, OnFinalRelease)(THIS) PURE;
158
159 /**
160 * @brief Create an IImgX object.
161 * @param [out] IImgX **ppImgDecoder - Pointer to store the created IImgX object.
162 * @return BOOL - TRUE if successful, FALSE otherwise.
163 */
164 STDMETHOD_(BOOL, CreateImgX)(THIS_ IImgX * *ppImgDecoder) PURE;
165
166 /**
167 * @brief Save an image to a file with a specified format.
168 * @param [in] BYTE *pBits - Pointer to the pixel data.
169 * @param [in] int nWid - Width of the image.
170 * @param [in] int nHei - Height of the image.
171 * @param [in] LPCWSTR pszFileName - File name (Unicode encoding).
172 * @param [in] const void *pFormat - Format-specific parameters.
173 * @return HRESULT - Result of the operation.
174 */
175 STDMETHOD_(HRESULT, SaveImage)
176 (CTHIS_ BYTE * pBits, int nWid, int nHei, LPCWSTR pszFileName, const void *pFormat) SCONST PURE;
177
178 /**
179 * @brief Save an image to a file with a specified format.
180 * @param [in] BYTE *pBits - Pointer to the pixel data.
181 * @param [in] int nWid - Width of the image.
182 * @param [in] int nHei - Height of the image.
183 * @param [in] LPCWSTR pszFileName - File name (Unicode encoding).
184 * @param [in] ImgFmt imgFmt - Image format.
185 * @return HRESULT - Result of the operation.
186 */
187 STDMETHOD_(HRESULT, SaveImage2)
188 (CTHIS_ BYTE * pBits, int nWid, int nHei, LPCWSTR pszFileName, ImgFmt imgFmt) SCONST PURE;
189
190 /**
191 * @brief Get the description of the image decoder.
192 * @return LPCWSTR - Description of the image decoder.
193 */
194 STDMETHOD_(LPCWSTR, GetDescription)(CTHIS) SCONST PURE;
195};
196
197SNSEND
198#endif // __SIMGDECODER_I__H__
_ImgFmt
@ Img_TGA
@ Img_Webp
@ Img_JPG
@ Img_TIFF
@ Img_BMP
@ Img_PNG
Interface for image decoder factory.
void OnFinalRelease() PURE
Final release of the object.
HRESULT SaveImage2(BYTE *pBits, int nWid, int nHei, LPCWSTR pszFileName, ImgFmt imgFmt) SCONST PURE
Save an image to a file with a specified format.
HRESULT SaveImage(BYTE *pBits, int nWid, int nHei, LPCWSTR pszFileName, const void *pFormat) SCONST PURE
Save an image to a file with a specified format.
LPCWSTR GetDescription() SCONST PURE
Get the description of the image decoder.
long AddRef() PURE
Increment the reference count.
long Release() PURE
Decrement the reference count.
BOOL CreateImgX(IImgX **ppImgDecoder) PURE
Create an IImgX object.
Interface for an image frame.
const VOID * GetPixels() SCONST PURE
Get the pixel buffer of the image.
BOOL GetSize(UINT *pWid, UINT *pHei) PURE
Get the size of the image in pixels.
int GetDelay() PURE
Get the delay time for a GIF image frame.
Interface for image data.
int LoadFromFileA(LPCSTR pszFileName) PURE
Load image data from a file (ANSI encoding).
int LoadFromMemory(void *pBuf, size_t bufLen) PURE
Load image data from a memory buffer.
long AddRef() PURE
Increment the reference count.
void OnFinalRelease() PURE
Final release of the object.
UINT GetFrameCount() PURE
Get the number of frames in the image.
int LoadFromFileW(LPCWSTR pszFileName) PURE
Load image data from a file (Unicode encoding).
long Release() PURE
Decrement the reference count.
IImgFrame * GetFrame(UINT iFrame) PURE
Get a specific frame of the image.
Interface for reference counting.
Definition obj-ref-i.h:19