1 // ximainfo.cpp : main attributes
2 /* 03/10/2004 v1.00 - Davide Pizzolato - www.xdp.it
3 * CxImage version 6.0.0 02/Feb/2008
8 ////////////////////////////////////////////////////////////////////////////////
10 * \return the color used for transparency, and/or for background color
12 RGBQUAD CxImage::GetTransColor()
14 if (head.biBitCount<24 && info.nBkgndIndex>=0) 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 if (idx<(long)head.biClrUsed)
32 info.nBkgndIndex = idx;
36 ////////////////////////////////////////////////////////////////////////////////
38 * Sets the color used for transparency with 24 bpp images.
39 * You must call SetTransIndex(0) to enable the effect, SetTransIndex(-1) to disable it.
41 void CxImage::SetTransColor(RGBQUAD rgb)
44 info.nBkgndColor = rgb;
46 ////////////////////////////////////////////////////////////////////////////////
47 bool CxImage::IsTransparent() const
49 return info.nBkgndIndex>=0; // <vho>
51 ////////////////////////////////////////////////////////////////////////////////
53 * Returns true if the image has 256 colors or less.
55 bool CxImage::IsIndexed() const
57 return head.biClrUsed!=0;
59 ////////////////////////////////////////////////////////////////////////////////
61 * \return 1 = indexed, 2 = RGB, 4 = RGBA
63 BYTE CxImage::GetColorType()
65 BYTE b = (BYTE)((head.biBitCount>8) ? 2 /*COLORTYPE_COLOR*/ : 1 /*COLORTYPE_PALETTE*/);
66 #if CXIMAGE_SUPPORT_ALPHA
67 if (AlphaIsValid()) b = 4 /*COLORTYPE_ALPHA*/;
68 #endif //CXIMAGE_SUPPORT_ALPHA
71 ////////////////////////////////////////////////////////////////////////////////
73 * \return Resolution for TIFF, JPEG, PNG and BMP formats.
75 long CxImage::GetXDPI() const
79 ////////////////////////////////////////////////////////////////////////////////
81 * \return Resolution for TIFF, JPEG, PNG and BMP formats.
83 long CxImage::GetYDPI() const
87 ////////////////////////////////////////////////////////////////////////////////
89 * Set resolution for TIFF, JPEG, PNG and BMP formats.
91 void CxImage::SetXDPI(long dpi)
93 if (dpi<=0) dpi = CXIMAGE_DEFAULT_DPI;
95 head.biXPelsPerMeter = (long) floor(dpi * 10000.0 / 254.0 + 0.5);
96 if (pDib) ((BITMAPINFOHEADER*)pDib)->biXPelsPerMeter = head.biXPelsPerMeter;
98 ////////////////////////////////////////////////////////////////////////////////
100 * Set resolution for TIFF, JPEG, PNG and BMP formats.
102 void CxImage::SetYDPI(long dpi)
104 if (dpi<=0) dpi = CXIMAGE_DEFAULT_DPI;
106 head.biYPelsPerMeter = (long) floor(dpi * 10000.0 / 254.0 + 0.5);
107 if (pDib) ((BITMAPINFOHEADER*)pDib)->biYPelsPerMeter = head.biYPelsPerMeter;
109 ////////////////////////////////////////////////////////////////////////////////
113 DWORD CxImage::GetFlags() const
117 ////////////////////////////////////////////////////////////////////////////////
119 * Image flags, for future use
121 * - 0x??00000 = reserved for 16 bit, CMYK, multilayer
122 * - 0x00??0000 = blend modes
123 * - 0x0000???? = layer id or user flags
125 * \param bLockReservedFlags protects the "reserved" and "blend modes" flags
127 void CxImage::SetFlags(DWORD flags, bool bLockReservedFlags)
129 if (bLockReservedFlags) info.dwFlags = flags & 0x0000ffff;
130 else info.dwFlags = flags;
132 ////////////////////////////////////////////////////////////////////////////////
136 DWORD CxImage::GetCodecOption(DWORD imagetype)
138 imagetype = GetTypeIndexFromId(imagetype);
140 imagetype = GetTypeIndexFromId(GetType());
142 return info.dwCodecOpt[imagetype];
144 ////////////////////////////////////////////////////////////////////////////////
146 * Encode option for GIF, TIF and JPG.
147 * - GIF : 0 = LZW (default), 1 = none, 2 = RLE.
148 * - TIF : 0 = automatic (default), or a valid compression code as defined in "tiff.h" (COMPRESSION_NONE = 1, COMPRESSION_CCITTRLE = 2, ...)
149 * - JPG : valid values stored in enum CODEC_OPTION ( ENCODE_BASELINE = 0x01, ENCODE_PROGRESSIVE = 0x10, ...)
150 * - RAW : valid values stored in enum CODEC_OPTION ( DECODE_QUALITY_LIN = 0x00, DECODE_QUALITY_VNG = 0x01, ...)
152 * \return true if everything is ok
154 bool CxImage::SetCodecOption(DWORD opt, DWORD imagetype)
156 imagetype = GetTypeIndexFromId(imagetype);
158 imagetype = GetTypeIndexFromId(GetType());
160 info.dwCodecOpt[imagetype] = opt;
163 ////////////////////////////////////////////////////////////////////////////////
165 * \return internal hDib object..
167 void* CxImage::GetDIB() const
171 ////////////////////////////////////////////////////////////////////////////////
172 DWORD CxImage::GetHeight() const
174 return head.biHeight;
176 ////////////////////////////////////////////////////////////////////////////////
177 DWORD CxImage::GetWidth() const
181 ////////////////////////////////////////////////////////////////////////////////
183 * \return DWORD aligned width of the image.
185 DWORD CxImage::GetEffWidth() const
187 return info.dwEffWidth;
189 ////////////////////////////////////////////////////////////////////////////////
191 * \return 2, 16, 256; 0 for RGB images.
193 DWORD CxImage::GetNumColors() const
195 return head.biClrUsed;
197 ////////////////////////////////////////////////////////////////////////////////
199 * \return: 1, 4, 8, 24.
201 WORD CxImage::GetBpp() const
203 return head.biBitCount;
205 ////////////////////////////////////////////////////////////////////////////////
207 * \return original image format
208 * \sa ENUM_CXIMAGE_FORMATS.
210 DWORD CxImage::GetType() const
214 ////////////////////////////////////////////////////////////////////////////////
216 * change image format identifier
217 * \sa ENUM_CXIMAGE_FORMATS.
219 bool CxImage::SetType(DWORD type)
222 #if CXIMAGE_SUPPORT_BMP
223 case CXIMAGE_FORMAT_BMP:
225 #if CXIMAGE_SUPPORT_GIF
226 case CXIMAGE_FORMAT_GIF:
228 #if CXIMAGE_SUPPORT_JPG
229 case CXIMAGE_FORMAT_JPG:
231 #if CXIMAGE_SUPPORT_PNG
232 case CXIMAGE_FORMAT_PNG:
234 #if CXIMAGE_SUPPORT_MNG
235 case CXIMAGE_FORMAT_MNG:
237 #if CXIMAGE_SUPPORT_ICO
238 case CXIMAGE_FORMAT_ICO:
240 #if CXIMAGE_SUPPORT_TIF
241 case CXIMAGE_FORMAT_TIF:
243 #if CXIMAGE_SUPPORT_TGA
244 case CXIMAGE_FORMAT_TGA:
246 #if CXIMAGE_SUPPORT_PCX
247 case CXIMAGE_FORMAT_PCX:
249 #if CXIMAGE_SUPPORT_WBMP
250 case CXIMAGE_FORMAT_WBMP:
252 #if CXIMAGE_SUPPORT_WMF
253 case CXIMAGE_FORMAT_WMF:
255 #if CXIMAGE_SUPPORT_JBG
256 case CXIMAGE_FORMAT_JBG:
258 #if CXIMAGE_SUPPORT_JP2
259 case CXIMAGE_FORMAT_JP2:
261 #if CXIMAGE_SUPPORT_JPC
262 case CXIMAGE_FORMAT_JPC:
264 #if CXIMAGE_SUPPORT_PGX
265 case CXIMAGE_FORMAT_PGX:
267 #if CXIMAGE_SUPPORT_PNM
268 case CXIMAGE_FORMAT_PNM:
270 #if CXIMAGE_SUPPORT_RAS
271 case CXIMAGE_FORMAT_RAS:
273 #if CXIMAGE_SUPPORT_SKA
274 case CXIMAGE_FORMAT_SKA:
276 #if CXIMAGE_SUPPORT_RAW
277 case CXIMAGE_FORMAT_RAW:
282 info.dwType = CXIMAGE_FORMAT_UNKNOWN;
285 ////////////////////////////////////////////////////////////////////////////////
286 DWORD CxImage::GetNumTypes()
288 return CMAX_IMAGE_FORMATS-1;
290 ////////////////////////////////////////////////////////////////////////////////
291 DWORD CxImage::GetTypeIdFromName(const TCHAR* ext)
293 #if CXIMAGE_SUPPORT_BMP
294 if (_tcsnicmp(ext,_T("bmp"),3)==0 ) return CXIMAGE_FORMAT_BMP;
296 #if CXIMAGE_SUPPORT_JPG
297 if (_tcsnicmp(ext,_T("jpg"),3)==0 ||
298 _tcsnicmp(ext,_T("jpe"),3)==0 ||
299 _tcsnicmp(ext,_T("jfi"),3)==0 ) return CXIMAGE_FORMAT_JPG;
301 #if CXIMAGE_SUPPORT_GIF
302 if (_tcsnicmp(ext,_T("gif"),3)==0 ) return CXIMAGE_FORMAT_GIF;
304 #if CXIMAGE_SUPPORT_PNG
305 if (_tcsnicmp(ext,_T("png"),3)==0 ) return CXIMAGE_FORMAT_PNG;
307 #if CXIMAGE_SUPPORT_ICO
308 if (_tcsnicmp(ext,_T("ico"),3)==0 ||
309 _tcsnicmp(ext,_T("cur"),3)==0 ) return CXIMAGE_FORMAT_ICO;
311 #if CXIMAGE_SUPPORT_TIF
312 if (_tcsnicmp(ext,_T("tif"),3)==0 ) return CXIMAGE_FORMAT_TIF;
314 #if CXIMAGE_SUPPORT_TGA
315 if (_tcsnicmp(ext,_T("tga"),3)==0 ) return CXIMAGE_FORMAT_TGA;
317 #if CXIMAGE_SUPPORT_PCX
318 if (_tcsnicmp(ext,_T("pcx"),3)==0 ) return CXIMAGE_FORMAT_PCX;
320 #if CXIMAGE_SUPPORT_WBMP
321 if (_tcsnicmp(ext,_T("wbm"),3)==0 ) return CXIMAGE_FORMAT_WBMP;
323 #if CXIMAGE_SUPPORT_WMF
324 if (_tcsnicmp(ext,_T("wmf"),3)==0 ||
325 _tcsnicmp(ext,_T("emf"),3)==0 ) return CXIMAGE_FORMAT_WMF;
327 #if CXIMAGE_SUPPORT_JP2
328 if (_tcsnicmp(ext,_T("jp2"),3)==0 ||
329 _tcsnicmp(ext,_T("j2k"),3)==0 ) return CXIMAGE_FORMAT_JP2;
331 #if CXIMAGE_SUPPORT_JPC
332 if (_tcsnicmp(ext,_T("jpc"),3)==0 ||
333 _tcsnicmp(ext,_T("j2c"),3)==0 ) return CXIMAGE_FORMAT_JPC;
335 #if CXIMAGE_SUPPORT_PGX
336 if (_tcsnicmp(ext,_T("pgx"),3)==0 ) return CXIMAGE_FORMAT_PGX;
338 #if CXIMAGE_SUPPORT_RAS
339 if (_tcsnicmp(ext,_T("ras"),3)==0 ) return CXIMAGE_FORMAT_RAS;
341 #if CXIMAGE_SUPPORT_PNM
342 if (_tcsnicmp(ext,_T("pnm"),3)==0 ||
343 _tcsnicmp(ext,_T("pgm"),3)==0 ||
344 _tcsnicmp(ext,_T("ppm"),3)==0 ) return CXIMAGE_FORMAT_PNM;
346 #if CXIMAGE_SUPPORT_JBG
347 if (_tcsnicmp(ext,_T("jbg"),3)==0 ) return CXIMAGE_FORMAT_JBG;
349 #if CXIMAGE_SUPPORT_MNG
350 if (_tcsnicmp(ext,_T("mng"),3)==0 ||
351 _tcsnicmp(ext,_T("jng"),3)==0 ) return CXIMAGE_FORMAT_MNG;
353 #if CXIMAGE_SUPPORT_SKA
354 if (_tcsnicmp(ext,_T("ska"),3)==0 ) return CXIMAGE_FORMAT_SKA;
356 #if CXIMAGE_SUPPORT_RAW
357 if (_tcsnicmp(ext,_T("nef"),3)==0 ||
358 _tcsnicmp(ext,_T("crw"),3)==0 ||
359 _tcsnicmp(ext,_T("cr2"),3)==0 ||
360 _tcsnicmp(ext,_T("dng"),3)==0 ||
361 _tcsnicmp(ext,_T("arw"),3)==0 ||
362 _tcsnicmp(ext,_T("erf"),3)==0 ||
363 _tcsnicmp(ext,_T("3fr"),3)==0 ||
364 _tcsnicmp(ext,_T("dcr"),3)==0 ||
365 _tcsnicmp(ext,_T("raw"),3)==0 ||
366 _tcsnicmp(ext,_T("x3f"),3)==0 ||
367 _tcsnicmp(ext,_T("mef"),3)==0 ||
368 _tcsnicmp(ext,_T("raf"),3)==0 ||
369 _tcsnicmp(ext,_T("mrw"),3)==0 ||
370 _tcsnicmp(ext,_T("pef"),3)==0 ||
371 _tcsnicmp(ext,_T("sr2"),3)==0 ||
372 _tcsnicmp(ext,_T("orf"),3)==0 ) return CXIMAGE_FORMAT_RAW;
375 return CXIMAGE_FORMAT_UNKNOWN;
377 ////////////////////////////////////////////////////////////////////////////////
378 DWORD CxImage::GetTypeIdFromIndex(const DWORD index)
382 n=0; if (index == n) return CXIMAGE_FORMAT_UNKNOWN;
383 #if CXIMAGE_SUPPORT_BMP
384 n++; if (index == n) return CXIMAGE_FORMAT_BMP;
386 #if CXIMAGE_SUPPORT_GIF
387 n++; if (index == n) return CXIMAGE_FORMAT_GIF;
389 #if CXIMAGE_SUPPORT_JPG
390 n++; if (index == n) return CXIMAGE_FORMAT_JPG;
392 #if CXIMAGE_SUPPORT_PNG
393 n++; if (index == n) return CXIMAGE_FORMAT_PNG;
395 #if CXIMAGE_SUPPORT_ICO
396 n++; if (index == n) return CXIMAGE_FORMAT_ICO;
398 #if CXIMAGE_SUPPORT_TIF
399 n++; if (index == n) return CXIMAGE_FORMAT_TIF;
401 #if CXIMAGE_SUPPORT_TGA
402 n++; if (index == n) return CXIMAGE_FORMAT_TGA;
404 #if CXIMAGE_SUPPORT_PCX
405 n++; if (index == n) return CXIMAGE_FORMAT_PCX;
407 #if CXIMAGE_SUPPORT_WBMP
408 n++; if (index == n) return CXIMAGE_FORMAT_WBMP;
410 #if CXIMAGE_SUPPORT_WMF
411 n++; if (index == n) return CXIMAGE_FORMAT_WMF;
413 #if CXIMAGE_SUPPORT_JP2
414 n++; if (index == n) return CXIMAGE_FORMAT_JP2;
416 #if CXIMAGE_SUPPORT_JPC
417 n++; if (index == n) return CXIMAGE_FORMAT_JPC;
419 #if CXIMAGE_SUPPORT_PGX
420 n++; if (index == n) return CXIMAGE_FORMAT_PGX;
422 #if CXIMAGE_SUPPORT_PNM
423 n++; if (index == n) return CXIMAGE_FORMAT_PNM;
425 #if CXIMAGE_SUPPORT_RAS
426 n++; if (index == n) return CXIMAGE_FORMAT_RAS;
428 #if CXIMAGE_SUPPORT_JBG
429 n++; if (index == n) return CXIMAGE_FORMAT_JBG;
431 #if CXIMAGE_SUPPORT_MNG
432 n++; if (index == n) return CXIMAGE_FORMAT_MNG;
434 #if CXIMAGE_SUPPORT_SKA
435 n++; if (index == n) return CXIMAGE_FORMAT_SKA;
437 #if CXIMAGE_SUPPORT_RAW
438 n++; if (index == n) return CXIMAGE_FORMAT_RAW;
441 return CXIMAGE_FORMAT_UNKNOWN;
443 ////////////////////////////////////////////////////////////////////////////////
444 DWORD CxImage::GetTypeIndexFromId(const DWORD id)
448 n=0; if (id == CXIMAGE_FORMAT_UNKNOWN) return n;
449 #if CXIMAGE_SUPPORT_BMP
450 n++; if (id == CXIMAGE_FORMAT_BMP) return n;
452 #if CXIMAGE_SUPPORT_GIF
453 n++; if (id == CXIMAGE_FORMAT_GIF) return n;
455 #if CXIMAGE_SUPPORT_JPG
456 n++; if (id == CXIMAGE_FORMAT_JPG) return n;
458 #if CXIMAGE_SUPPORT_PNG
459 n++; if (id == CXIMAGE_FORMAT_PNG) return n;
461 #if CXIMAGE_SUPPORT_ICO
462 n++; if (id == CXIMAGE_FORMAT_ICO) return n;
464 #if CXIMAGE_SUPPORT_TIF
465 n++; if (id == CXIMAGE_FORMAT_TIF) return n;
467 #if CXIMAGE_SUPPORT_TGA
468 n++; if (id == CXIMAGE_FORMAT_TGA) return n;
470 #if CXIMAGE_SUPPORT_PCX
471 n++; if (id == CXIMAGE_FORMAT_PCX) return n;
473 #if CXIMAGE_SUPPORT_WBMP
474 n++; if (id == CXIMAGE_FORMAT_WBMP) return n;
476 #if CXIMAGE_SUPPORT_WMF
477 n++; if (id == CXIMAGE_FORMAT_WMF) return n;
479 #if CXIMAGE_SUPPORT_JP2
480 n++; if (id == CXIMAGE_FORMAT_JP2) return n;
482 #if CXIMAGE_SUPPORT_JPC
483 n++; if (id == CXIMAGE_FORMAT_JPC) return n;
485 #if CXIMAGE_SUPPORT_PGX
486 n++; if (id == CXIMAGE_FORMAT_PGX) return n;
488 #if CXIMAGE_SUPPORT_PNM
489 n++; if (id == CXIMAGE_FORMAT_PNM) return n;
491 #if CXIMAGE_SUPPORT_RAS
492 n++; if (id == CXIMAGE_FORMAT_RAS) return n;
494 #if CXIMAGE_SUPPORT_JBG
495 n++; if (id == CXIMAGE_FORMAT_JBG) return n;
497 #if CXIMAGE_SUPPORT_MNG
498 n++; if (id == CXIMAGE_FORMAT_MNG) return n;
500 #if CXIMAGE_SUPPORT_SKA
501 n++; if (id == CXIMAGE_FORMAT_SKA) return n;
503 #if CXIMAGE_SUPPORT_RAW
504 n++; if (id == CXIMAGE_FORMAT_RAW) return n;
509 ////////////////////////////////////////////////////////////////////////////////
511 * \return current frame delay in milliseconds. Only for GIF and MNG formats.
513 DWORD CxImage::GetFrameDelay() const
515 return info.dwFrameDelay;
517 ////////////////////////////////////////////////////////////////////////////////
519 * Sets current frame delay. Only for GIF format.
520 * \param d = delay in milliseconds
522 void CxImage::SetFrameDelay(DWORD d)
526 ////////////////////////////////////////////////////////////////////////////////
527 void CxImage::GetOffset(long *x,long *y)
532 ////////////////////////////////////////////////////////////////////////////////
533 void CxImage::SetOffset(long x,long y)
538 ////////////////////////////////////////////////////////////////////////////////
540 * \sa SetJpegQuality, GetJpegQualityF
541 * \author [DP]; changes [Stefan Schürmans]
543 BYTE CxImage::GetJpegQuality() const
545 return (BYTE)(info.fQuality + 0.5f);
547 ////////////////////////////////////////////////////////////////////////////////
549 * \sa SetJpegQuality, GetJpegQuality
550 * \author [Stefan Schürmans]
552 float CxImage::GetJpegQualityF() const
554 return info.fQuality;
556 ////////////////////////////////////////////////////////////////////////////////
558 * quality level for JPEG and JPEG2000
559 * \param q: can be from 0 to 100
560 * \author [DP]; changes [Stefan Schürmans]
562 void CxImage::SetJpegQuality(BYTE q){
563 info.fQuality = (float)q;
565 ////////////////////////////////////////////////////////////////////////////////
567 * quality level for JPEG and JPEG2000
568 * necessary for JPEG2000 when quality is between 0.0 and 1.0
569 * \param q: can be from 0.0 to 100.0
570 * \author [Stefan Schürmans]
572 void CxImage::SetJpegQualityF(float q){
573 if (q>0) info.fQuality = q;
574 else info.fQuality = 0.0f;
576 ////////////////////////////////////////////////////////////////////////////////
580 BYTE CxImage::GetJpegScale() const
582 return info.nJpegScale;
584 ////////////////////////////////////////////////////////////////////////////////
586 * scaling down during JPEG decoding valid numbers are 1, 2, 4, 8
589 void CxImage::SetJpegScale(BYTE q){
592 ////////////////////////////////////////////////////////////////////////////////
594 * Used to monitor the slow loops.
595 * \return value is from 0 to 100.
598 long CxImage::GetProgress() const
600 return info.nProgress;
602 ////////////////////////////////////////////////////////////////////////////////
604 * \return the escape code.
607 long CxImage::GetEscape() const
611 ////////////////////////////////////////////////////////////////////////////////
613 * Forces the value of the internal progress variable.
614 * \param p should be from 0 to 100.
617 void CxImage::SetProgress(long p)
621 ////////////////////////////////////////////////////////////////////////////////
623 * Used to quit the slow loops or the codecs.
624 * - SetEscape(-1) before Decode forces the function to exit, right after
625 * the image width and height are available ( for bmp, jpg, gif, tif )
627 void CxImage::SetEscape(long i)
631 ////////////////////////////////////////////////////////////////////////////////
633 * Checks if the image is correctly initializated.
635 bool CxImage::IsValid() const
639 ////////////////////////////////////////////////////////////////////////////////
641 * True if the image is enabled for painting.
643 bool CxImage::IsEnabled() const
645 return info.bEnabled;
647 ////////////////////////////////////////////////////////////////////////////////
649 * Enables/disables the image.
651 void CxImage::Enable(bool enable)
653 info.bEnabled=enable;
655 ////////////////////////////////////////////////////////////////////////////////
657 * This function must be used after a Decode() / Load() call.
658 * Use the sequence SetFrame(-1); Load(...); GetNumFrames();
659 * to get the number of images without loading the first image.
660 * \return the number of images in the file.
662 long CxImage::GetNumFrames() const
664 return info.nNumFrames;
666 ////////////////////////////////////////////////////////////////////////////////
668 * \return the current selected image (zero-based index).
670 long CxImage::GetFrame() const
674 ////////////////////////////////////////////////////////////////////////////////
676 * Sets the image number that the next Decode() / Load() call will load
678 void CxImage::SetFrame(long nFrame){
681 ////////////////////////////////////////////////////////////////////////////////
683 * Sets the method for drawing the frame related to others
684 * \sa GetDisposalMethod
686 void CxImage::SetDisposalMethod(BYTE dm)
687 { info.dispmeth=dm; }
688 ////////////////////////////////////////////////////////////////////////////////
690 * Gets the method for drawing the frame related to others
691 * Values : 0 - No disposal specified. The decoder is
692 * not required to take any action.
693 * 1 - Do not dispose. The graphic is to be left
695 * 2 - Restore to background color. The area used by the
696 * graphic must be restored to the background color.
697 * 3 - Restore to previous. The decoder is required to
698 * restore the area overwritten by the graphic with
699 * what was there prior to rendering the graphic.
700 * 4-7 - To be defined.
702 BYTE CxImage::GetDisposalMethod() const
703 { return info.dispmeth; }
704 ////////////////////////////////////////////////////////////////////////////////
705 bool CxImage::GetRetreiveAllFrames() const
706 { return info.bGetAllFrames; }
707 ////////////////////////////////////////////////////////////////////////////////
708 void CxImage::SetRetreiveAllFrames(bool flag)
709 { info.bGetAllFrames = flag; }
710 ////////////////////////////////////////////////////////////////////////////////
711 CxImage * CxImage::GetFrame(long nFrame) const
713 if ( ppFrames == NULL) return NULL;
714 if ( info.nNumFrames == 0) return NULL;
715 if ( nFrame >= info.nNumFrames ) return NULL;
716 if ( nFrame < 0) nFrame = info.nNumFrames - 1;
717 return ppFrames[nFrame];
719 ////////////////////////////////////////////////////////////////////////////////
720 short CxImage::ntohs(const short word)
722 if (info.bLittleEndianHost) return word;
723 return ( (word & 0xff) << 8 ) | ( (word >> 8) & 0xff );
725 ////////////////////////////////////////////////////////////////////////////////
726 long CxImage::ntohl(const long dword)
728 if (info.bLittleEndianHost) return dword;
729 return ((dword & 0xff) << 24 ) | ((dword & 0xff00) << 8 ) |
730 ((dword >> 8) & 0xff00) | ((dword >> 24) & 0xff);
732 ////////////////////////////////////////////////////////////////////////////////
733 void CxImage::bihtoh(BITMAPINFOHEADER* bih)
735 bih->biSize = ntohl(bih->biSize);
736 bih->biWidth = ntohl(bih->biWidth);
737 bih->biHeight = ntohl(bih->biHeight);
738 bih->biPlanes = ntohs(bih->biPlanes);
739 bih->biBitCount = ntohs(bih->biBitCount);
740 bih->biCompression = ntohl(bih->biCompression);
741 bih->biSizeImage = ntohl(bih->biSizeImage);
742 bih->biXPelsPerMeter = ntohl(bih->biXPelsPerMeter);
743 bih->biYPelsPerMeter = ntohl(bih->biYPelsPerMeter);
744 bih->biClrUsed = ntohl(bih->biClrUsed);
745 bih->biClrImportant = ntohl(bih->biClrImportant);
747 ////////////////////////////////////////////////////////////////////////////////
749 * Returns the last reported error.
751 const char* CxImage::GetLastError()
753 return info.szLastError;
755 ////////////////////////////////////////////////////////////////////////////////
756 DWORD CxImage::DumpSize()
759 n = sizeof(BITMAPINFOHEADER) + sizeof(CXIMAGEINFO) + GetSize();
762 n += 1 + head.biWidth * head.biHeight;
766 n += 1 + head.biWidth * head.biHeight;
770 for (long m=0; m<GetNumLayers(); m++){
772 n += 1 + GetLayer(m)->DumpSize();
778 for (long m=0; m<GetNumFrames(); m++){
780 n += 1 + GetFrame(m)->DumpSize();
787 ////////////////////////////////////////////////////////////////////////////////
788 DWORD CxImage::Dump(BYTE * dst)
792 memcpy(dst,&head,sizeof(BITMAPINFOHEADER));
793 dst += sizeof(BITMAPINFOHEADER);
795 memcpy(dst,&info,sizeof(CXIMAGEINFO));
796 dst += sizeof(CXIMAGEINFO);
798 memcpy(dst,pDib,GetSize());
803 memcpy(dst,pAlpha,head.biWidth * head.biHeight);
804 dst += head.biWidth * head.biHeight;
811 memcpy(dst,pSelection,head.biWidth * head.biHeight);
812 dst += head.biWidth * head.biHeight;
819 for (long m=0; m<GetNumLayers(); m++){
821 dst += GetLayer(m)->Dump(dst);
830 for (long m=0; m<GetNumFrames(); m++){
832 dst += GetFrame(m)->Dump(dst);
841 ////////////////////////////////////////////////////////////////////////////////
842 DWORD CxImage::UnDump(const BYTE * src)
848 if (!DestroyFrames())
853 memcpy(&head,src,sizeof(BITMAPINFOHEADER));
854 n += sizeof(BITMAPINFOHEADER);
856 memcpy(&info,&src[n],sizeof(CXIMAGEINFO));
857 n += sizeof(CXIMAGEINFO);
859 if (!Create(head.biWidth, head.biHeight, head.biBitCount, info.dwType))
862 memcpy(pDib,&src[n],GetSize());
867 memcpy(pAlpha, &src[n], head.biWidth * head.biHeight);
869 n += head.biWidth * head.biHeight;
873 RECT box = info.rSelectionBox;
874 if (SelectionCreate()){
875 info.rSelectionBox = box;
876 memcpy(pSelection, &src[n], head.biWidth * head.biHeight);
878 n += head.biWidth * head.biHeight;
882 ppLayers = new CxImage*[info.nNumLayers];
883 for (long m=0; m<GetNumLayers(); m++){
884 ppLayers[m] = new CxImage();
885 n += ppLayers[m]->UnDump(&src[n]);
890 ppFrames = new CxImage*[info.nNumFrames];
891 for (long m=0; m<GetNumFrames(); m++){
892 ppFrames[m] = new CxImage();
893 n += ppFrames[m]->UnDump(&src[n]);
899 ////////////////////////////////////////////////////////////////////////////////
901 * \return A.BBCCCDDDD
903 * - BB = main revision
904 * - CCC = minor revision (letter)
905 * - DDDD = experimental revision
907 const float CxImage::GetVersionNumber()
911 ////////////////////////////////////////////////////////////////////////////////
912 const TCHAR* CxImage::GetVersion()
914 static const TCHAR CxImageVersion[] = _T("CxImage 6.0.0");
915 return (CxImageVersion);
917 ////////////////////////////////////////////////////////////////////////////////