1
// ximainfo.cpp : main attributes
2
/* 03/10/2004 v1.00 - Davide Pizzolato - www.xdp.it
3
* CxImage version 5.99c 17/Oct/2004
8
////////////////////////////////////////////////////////////////////////////////
10
* \return the color used for transparency, and/or for background color
12
RGBQUAD CxImage::GetTransColor()
14
if (head.biBitCount<24 && info.nBkgndIndex != -1) return GetPaletteColor((BYTE)info.nBkgndIndex);
15
return info.nBkgndColor;
17
////////////////////////////////////////////////////////////////////////////////
19
* Gets the index used for transparency. Returns -1 for no transparancy.
21
long CxImage::GetTransIndex() const
23
return info.nBkgndIndex;
25
////////////////////////////////////////////////////////////////////////////////
27
* Sets the index used for transparency with 1, 4 and 8 bpp images. Set to -1 to remove the effect.
29
void CxImage::SetTransIndex(long idx)
31
info.nBkgndIndex = idx;
33
////////////////////////////////////////////////////////////////////////////////
35
* Sets the color used for transparency with 24 bpp images.
36
* You must call SetTransIndex(0) to enable the effect, SetTransIndex(-1) to disable it.
38
void CxImage::SetTransColor(RGBQUAD rgb)
41
info.nBkgndColor = rgb;
43
////////////////////////////////////////////////////////////////////////////////
44
bool CxImage::IsTransparent() const
46
return info.nBkgndIndex>=0; // <vho>
48
////////////////////////////////////////////////////////////////////////////////
50
* Returns true if the image has 256 colors or less.
52
bool CxImage::IsIndexed() const
54
return head.biClrUsed!=0;
56
////////////////////////////////////////////////////////////////////////////////
58
* Sets the method for drawing the frame related to others
60
void CxImage::SetDisposalMethod(int dm)
61
{ info.m_dispmeth=dm; }
62
////////////////////////////////////////////////////////////////////////////////
64
* Gets the method for drawing the frame related to others
65
* Values : 0 - No disposal specified. The decoder is
66
* not required to take any action.
67
* 1 - Do not dispose. The graphic is to be left
69
* 2 - Restore to background color. The area used by the
70
* graphic must be restored to the background color.
71
* 3 - Restore to previous. The decoder is required to
72
* restore the area overwritten by the graphic with
73
* what was there prior to rendering the graphic.
74
* 4-7 - To be defined.
76
long CxImage::GetDisposalMethod()
77
{ return info.m_dispmeth; }
78
////////////////////////////////////////////////////////////////////////////////
80
* \return 1 = indexed, 2 = RGB, 4 = RGBA
82
BYTE CxImage::GetColorType()
84
BYTE b = (BYTE)((head.biBitCount>8) ? 2 /*COLORTYPE_COLOR*/ : 1 /*COLORTYPE_PALETTE*/);
85
#if CXIMAGE_SUPPORT_ALPHA
86
if (AlphaIsValid()) b = 4 /*COLORTYPE_ALPHA*/;
87
#endif //CXIMAGE_SUPPORT_ALPHA
90
////////////////////////////////////////////////////////////////////////////////
92
* \return Resolution for TIFF, JPEG, PNG and BMP formats.
94
long CxImage::GetXDPI() const
98
////////////////////////////////////////////////////////////////////////////////
100
* \return Resolution for TIFF, JPEG, PNG and BMP formats.
102
long CxImage::GetYDPI() const
106
////////////////////////////////////////////////////////////////////////////////
108
* Set resolution for TIFF, JPEG, PNG and BMP formats.
110
void CxImage::SetXDPI(long dpi)
114
head.biXPelsPerMeter = (long) floor(dpi * 10000.0 / 254.0 + 0.5);
116
////////////////////////////////////////////////////////////////////////////////
118
* Set resolution for TIFF, JPEG, PNG and BMP formats.
120
void CxImage::SetYDPI(long dpi)
124
head.biYPelsPerMeter = (long) floor(dpi * 10000.0 / 254.0 + 0.5);
126
////////////////////////////////////////////////////////////////////////////////
130
DWORD CxImage::GetFlags() const
134
////////////////////////////////////////////////////////////////////////////////
136
* Image flags, for future use
138
* - 0x??00000 = reserved for 16 bit, CMYK, multilayer
139
* - 0x00??0000 = blend modes
140
* - 0x0000???? = layer id or user flags
142
* \param bLockReservedFlags protects the "reserved" and "blend modes" flags
144
void CxImage::SetFlags(DWORD flags, bool bLockReservedFlags)
146
if (bLockReservedFlags) info.dwFlags = flags & 0x0000ffff;
147
else info.dwFlags = flags;
149
////////////////////////////////////////////////////////////////////////////////
153
DWORD CxImage::GetCodecOption(DWORD imagetype)
155
if (imagetype<CMAX_IMAGE_FORMATS){
157
imagetype = GetType();
159
return info.dwCodecOpt[imagetype];
163
////////////////////////////////////////////////////////////////////////////////
165
* Encode option for GIF, TIF and JPG.
166
* - GIF : 0 = LZW (default), 1 = none, 2 = RLE.
167
* - TIF : 0 = automatic (default), or a valid compression code as defined in "tiff.h" (COMPRESSION_NONE = 1, COMPRESSION_CCITTRLE = 2, ...)
168
* - JPG : valid values stored in enum CODEC_OPTION ( ENCODE_BASELINE = 0x01, ENCODE_PROGRESSIVE = 0x10, ...)
170
* \return true if everything is ok
172
bool CxImage::SetCodecOption(DWORD opt, DWORD imagetype)
174
if (imagetype<CMAX_IMAGE_FORMATS){
176
imagetype = GetType();
178
info.dwCodecOpt[imagetype] = opt;
183
////////////////////////////////////////////////////////////////////////////////
185
* \return internal hDib object..
187
void* CxImage::GetDIB() const
191
////////////////////////////////////////////////////////////////////////////////
192
DWORD CxImage::GetHeight() const
194
return head.biHeight;
196
////////////////////////////////////////////////////////////////////////////////
197
DWORD CxImage::GetWidth() const
201
////////////////////////////////////////////////////////////////////////////////
203
* \return DWORD aligned width of the image.
205
DWORD CxImage::GetEffWidth() const
207
return info.dwEffWidth;
209
////////////////////////////////////////////////////////////////////////////////
211
* \return 2, 16, 256; 0 for RGB images.
213
DWORD CxImage::GetNumColors() const
215
return head.biClrUsed;
217
////////////////////////////////////////////////////////////////////////////////
219
* \return: 1, 4, 8, 24.
221
WORD CxImage::GetBpp() const
223
return head.biBitCount;
225
////////////////////////////////////////////////////////////////////////////////
227
* \return original image format
228
* \sa ENUM_CXIMAGE_FORMATS.
230
DWORD CxImage::GetType() const
234
////////////////////////////////////////////////////////////////////////////////
236
* \return current frame delay in milliseconds. Only for GIF and MNG formats.
238
DWORD CxImage::GetFrameDelay() const
240
return info.dwFrameDelay;
242
////////////////////////////////////////////////////////////////////////////////
244
* Sets current frame delay. Only for GIF format.
245
* \param d = delay in milliseconds
247
void CxImage::SetFrameDelay(DWORD d)
251
////////////////////////////////////////////////////////////////////////////////
252
void CxImage::GetOffset(long *x,long *y)
257
////////////////////////////////////////////////////////////////////////////////
258
void CxImage::SetOffset(long x,long y)
263
////////////////////////////////////////////////////////////////////////////////
267
BYTE CxImage::GetJpegQuality() const
269
return info.nQuality;
271
////////////////////////////////////////////////////////////////////////////////
273
* quality level for JPEG and JPEG2000
274
* \param q: can be from 0 to 100
276
void CxImage::SetJpegQuality(BYTE q){
279
////////////////////////////////////////////////////////////////////////////////
283
BYTE CxImage::GetJpegScale() const
285
return info.nJpegScale;
287
////////////////////////////////////////////////////////////////////////////////
289
* scaling down during JPEG decoding valid numbers are 1, 2, 4, 8
292
void CxImage::SetJpegScale(BYTE q){
295
////////////////////////////////////////////////////////////////////////////////
297
* Used to monitor the slow loops.
298
* \return value is from 0 to 100.
301
long CxImage::GetProgress() const
303
return info.nProgress;
305
////////////////////////////////////////////////////////////////////////////////
307
* \return the escape code.
310
long CxImage::GetEscape() const
314
////////////////////////////////////////////////////////////////////////////////
316
* Forces the value of the internal progress variable.
317
* \param p should be from 0 to 100.
320
void CxImage::SetProgress(long p)
324
////////////////////////////////////////////////////////////////////////////////
326
* Used to quit the slow loops or the codecs.
327
* - SetEscape(-1) before Decode forces the function to exit, right after
328
* the image width and height are available ( for bmp, jpg, gif, tif )
330
void CxImage::SetEscape(long i)
334
////////////////////////////////////////////////////////////////////////////////
336
* Checks if the image is correctly initializated.
338
bool CxImage::IsValid() const
342
////////////////////////////////////////////////////////////////////////////////
344
* True if the image is enabled for painting.
346
bool CxImage::IsEnabled() const
348
return info.bEnabled;
350
////////////////////////////////////////////////////////////////////////////////
352
* Enables/disables the image.
354
void CxImage::Enable(bool enable)
356
info.bEnabled=enable;
358
////////////////////////////////////////////////////////////////////////////////
360
* This function must be used after a Decode() / Load() call.
361
* Use the sequence SetFrame(-1); Load(...); GetNumFrames();
362
* to get the number of images without loading the first image.
363
* \return the number of images in the file.
365
long CxImage::GetNumFrames() const
367
return info.nNumFrames;
369
////////////////////////////////////////////////////////////////////////////////
371
* \return the current selected image (zero-based index).
373
long CxImage::GetFrame() const
377
////////////////////////////////////////////////////////////////////////////////
379
* Sets the image number that the next Decode() / Load() call will load
381
void CxImage::SetFrame(long nFrame){
385
CxImage * CxImage::GetFrameNo(long nFrame) const {
386
if (info.GifFrames && nFrame <= info.nNumFrames && info.GifFrames[nFrame]) {
387
return info.GifFrames[nFrame];
389
return (CxImage * const)this;
392
void CxImage::RetreiveAllFrame() {
393
info.bGetAllFrames = true;
396
void CxImage::RetreiveSingleFrame() {
397
info.bGetAllFrames = false;
400
////////////////////////////////////////////////////////////////////////////////
402
* Returns the last reported error.
404
const char* CxImage::GetLastError()
406
return info.szLastError;
408
////////////////////////////////////////////////////////////////////////////////
410
* \return A.BBCCCDDDD
412
* - BB = main revision
413
* - CCC = minor revision (letter)
414
* - DDDD = experimental revision
416
const float CxImage::GetVersionNumber()
420
////////////////////////////////////////////////////////////////////////////////
421
const TCHAR* CxImage::GetVersion()
423
static const TCHAR CxImageVersion[] = _T("CxImage 5.99c");
424
return (CxImageVersion);
426
////////////////////////////////////////////////////////////////////////////////