ReactOS 0.4.15-dev-5893-g1bb4167
atlimage.h
Go to the documentation of this file.
1// PROJECT: ReactOS ATL CImage
2// LICENSE: Public Domain
3// PURPOSE: Provides compatibility to Microsoft ATL
4// PROGRAMMERS: Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
5
6#ifndef __ATLIMAGE_H__
7#define __ATLIMAGE_H__
8
9// !!!!
10// TODO: The backend (gdi+) that this class relies on is not yet complete!
11// Before that is finished, this class will not be a perfect replacement.
12// See rostest/apitests/atl/CImage_WIP.txt for test results.
13// !!!!
14
15// TODO: CImage::Load, CImage::Save
16// TODO: make CImage thread-safe
17
18#pragma once
19
20#include <atlcore.h> // for ATL Core
21#include <atlstr.h> // for CAtlStringMgr
22#include <atlsimpstr.h> // for CSimpleString
23#include <atlsimpcoll.h> // for CSimpleArray
24
25#include <wingdi.h>
26#include <cguid.h> // for GUID_NULL
27#include <gdiplus.h> // GDI+
28
29namespace ATL
30{
31
32class CImage
33{
34public:
35 // flags for CImage::Create/CreateEx
36 enum
37 {
38 createAlphaChannel = 1 // enable alpha
39 };
40
41 // orientation of DIB
43 {
44 DIBOR_DEFAULT, // default
45 DIBOR_BOTTOMUP, // bottom-up DIB
46 DIBOR_TOPDOWN // top-down DIB
47 };
48
49 CImage() throw()
50 {
51 m_hbm = NULL;
52 m_hbmOld = NULL;
53 m_hDC = NULL;
54
56 m_bHasAlphaCh = false;
57 m_bIsDIBSec = false;
59 ZeroMemory(&m_ds, sizeof(m_ds));
60
61 if (GetCommon().AddRef() == 1)
62 {
64 }
65 }
66
68 {
69 Destroy();
71 }
72
73 operator HBITMAP()
74 {
75 return m_hbm;
76 }
77
78public:
80 {
81 AttachInternal(hBitmap, eOrientation, -1);
82 }
83
84 HBITMAP Detach() throw()
85 {
87 m_bHasAlphaCh = false;
89 ZeroMemory(&m_ds, sizeof(m_ds));
90
92 m_hbm = NULL;
93 return hBitmap;
94 }
95
96 HDC GetDC() const throw()
97 {
98 if (m_hDC)
99 return m_hDC;
100
103 return m_hDC;
104 }
105
106 void ReleaseDC() const throw()
107 {
109
110 if (m_hDC == NULL)
111 return;
112
113 if (m_hbmOld)
114 {
116 m_hbmOld = NULL;
117 }
119 m_hDC = NULL;
120 }
121
122public:
124 int xDest, int yDest, int nDestWidth, int nDestHeight,
125 int xSrc, int ySrc, int nSrcWidth, int nSrcHeight,
126 BYTE bSrcAlpha = 0xFF, BYTE bBlendOp = AC_SRC_OVER) const
127 {
129
130 BLENDFUNCTION bf;
131 bf.BlendOp = bBlendOp;
132 bf.BlendFlags = 0;
133 bf.SourceConstantAlpha = bSrcAlpha;
135
136 GetDC();
137 BOOL ret = ::AlphaBlend(hDestDC, xDest, yDest, nDestWidth, nDestHeight,
138 m_hDC, xSrc, ySrc, nSrcWidth, nSrcHeight, bf);
139 ReleaseDC();
140 return ret;
141 }
142 BOOL AlphaBlend(HDC hDestDC, int xDest, int yDest,
143 BYTE bSrcAlpha = 0xFF, BYTE bBlendOp = AC_SRC_OVER) const
144 {
145 int width = GetWidth();
146 int height = GetHeight();
147 return AlphaBlend(hDestDC, xDest, yDest, width, height, 0, 0,
148 width, height, bSrcAlpha, bBlendOp);
149 }
150 BOOL AlphaBlend(HDC hDestDC, const POINT& pointDest,
151 BYTE bSrcAlpha = 0xFF, BYTE bBlendOp = AC_SRC_OVER) const
152 {
153 return AlphaBlend(hDestDC, pointDest.x, pointDest.y, bSrcAlpha, bBlendOp);
154 }
155 BOOL AlphaBlend(HDC hDestDC, const RECT& rectDest, const RECT& rectSrc,
156 BYTE bSrcAlpha = 0xFF, BYTE bBlendOp = AC_SRC_OVER) const
157 {
158 return AlphaBlend(hDestDC, rectDest.left, rectDest.top,
159 rectDest.right - rectDest.left,
160 rectDest.bottom - rectDest.top,
161 rectSrc.left, rectSrc.top,
162 rectSrc.right - rectSrc.left,
163 rectSrc.bottom - rectSrc.top,
164 bSrcAlpha, bBlendOp);
165 }
166
167 BOOL BitBlt(HDC hDestDC, int xDest, int yDest,
168 int nDestWidth, int nDestHeight,
169 int xSrc, int ySrc, DWORD dwROP = SRCCOPY) const throw()
170 {
171 GetDC();
172 BOOL ret = ::BitBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight,
173 m_hDC, xSrc, ySrc, dwROP);
174 ReleaseDC();
175 return ret;
176 }
177 BOOL BitBlt(HDC hDestDC, int xDest, int yDest,
178 DWORD dwROP = SRCCOPY) const throw()
179 {
180 return BitBlt(hDestDC, xDest, yDest,
181 GetWidth(), GetHeight(), 0, 0, dwROP);
182 }
183 BOOL BitBlt(HDC hDestDC, const POINT& pointDest,
184 DWORD dwROP = SRCCOPY) const throw()
185 {
186 return BitBlt(hDestDC, pointDest.x, pointDest.y, dwROP);
187 }
188 BOOL BitBlt(HDC hDestDC, const RECT& rectDest, const POINT& pointSrc,
189 DWORD dwROP = SRCCOPY) const throw()
190 {
191 return BitBlt(hDestDC, rectDest.left, rectDest.top,
192 rectDest.right - rectDest.left,
193 rectDest.bottom - rectDest.top,
194 pointSrc.x, pointSrc.y, dwROP);
195 }
196
197 BOOL Create(int nWidth, int nHeight, int nBPP, DWORD dwFlags = 0) throw()
198 {
199 return CreateEx(nWidth, nHeight, nBPP, BI_RGB, NULL, dwFlags);
200 }
201
202 BOOL CreateEx(int nWidth, int nHeight, int nBPP, DWORD eCompression,
203 const DWORD* pdwBitmasks = NULL, DWORD dwFlags = 0) throw()
204 {
205 return CreateInternal(nWidth, nHeight, nBPP, eCompression, pdwBitmasks, dwFlags);
206 }
207
208 void Destroy() throw()
209 {
210 if (m_hbm)
211 {
213 }
214 }
215
216 BOOL Draw(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight,
217 int xSrc, int ySrc, int nSrcWidth, int nSrcHeight) const throw()
218 {
220 if (m_bHasAlphaCh)
221 {
222 return AlphaBlend(hDestDC, xDest, yDest, nDestWidth, nDestHeight,
223 xSrc, ySrc, nSrcWidth, nSrcHeight);
224 }
225 else if (m_rgbTransColor != CLR_INVALID)
226 {
228 if ((m_rgbTransColor & 0xFF000000) == 0x01000000)
230 else
232 return TransparentBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight,
233 xSrc, ySrc, nSrcWidth, nSrcHeight, rgb);
234 }
235 else
236 {
237 return StretchBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight,
238 xSrc, ySrc, nSrcWidth, nSrcHeight);
239 }
240 }
241 BOOL Draw(HDC hDestDC, const RECT& rectDest, const RECT& rectSrc) const throw()
242 {
243 return Draw(hDestDC, rectDest.left, rectDest.top,
244 rectDest.right - rectDest.left,
245 rectDest.bottom - rectDest.top,
246 rectSrc.left, rectSrc.top,
247 rectSrc.right - rectSrc.left,
248 rectSrc.bottom - rectSrc.top);
249 }
250 BOOL Draw(HDC hDestDC, int xDest, int yDest) const throw()
251 {
252 return Draw(hDestDC, xDest, yDest, GetWidth(), GetHeight());
253 }
254 BOOL Draw(HDC hDestDC, const POINT& pointDest) const throw()
255 {
256 return Draw(hDestDC, pointDest.x, pointDest.y);
257 }
258 BOOL Draw(HDC hDestDC, int xDest, int yDest,
259 int nDestWidth, int nDestHeight) const throw()
260 {
261 return Draw(hDestDC, xDest, yDest, nDestWidth, nDestHeight,
262 0, 0, GetWidth(), GetHeight());
263 }
264 BOOL Draw(HDC hDestDC, const RECT& rectDest) const throw()
265 {
266 return Draw(hDestDC, rectDest.left, rectDest.top,
267 rectDest.right - rectDest.left,
268 rectDest.bottom - rectDest.top);
269 }
270
271 void *GetBits() throw()
272 {
274 BYTE *pb = (BYTE *)m_bm.bmBits;
276 {
277 pb += m_bm.bmWidthBytes * (m_bm.bmHeight - 1);
278 }
279 return pb;
280 }
281
282 int GetBPP() const throw()
283 {
285 return m_bm.bmBitsPixel;
286 }
287
288 void GetColorTable(UINT iFirstColor, UINT nColors,
289 RGBQUAD* prgbColors) const throw()
290 {
292 GetDC();
293 ::GetDIBColorTable(m_hDC, iFirstColor, nColors, prgbColors);
294 ReleaseDC();
295 }
296
297 int GetHeight() const throw()
298 {
300 return m_bm.bmHeight;
301 }
302
303 int GetMaxColorTableEntries() const throw()
304 {
307 return m_ds.dsBmih.biClrUsed;
308 switch (m_bm.bmBitsPixel)
309 {
310 case 1: return 2;
311 case 4: return 16;
312 case 8: return 256;
313 case 16: case 32:
315 return 3;
316 return 0;
317 case 24:
318 default:
319 return 0;
320 }
321 }
322
323 int GetPitch() const throw()
324 {
327 return -m_bm.bmWidthBytes;
328 else
329 return m_bm.bmWidthBytes;
330 }
331
332 COLORREF GetPixel(int x, int y) const throw()
333 {
334 GetDC();
336 ReleaseDC();
337 return ret;
338 }
339
340 void* GetPixelAddress(int x, int y) throw()
341 {
343 BYTE *pb = (BYTE *)GetBits();
344 pb += GetPitch() * y;
345 pb += (GetBPP() * x) / 8;
346 return pb;
347 }
348
350 {
351 return m_rgbTransColor;
352 }
353
354 int GetWidth() const throw()
355 {
357 return m_bm.bmWidth;
358 }
359
360 bool IsDIBSection() const throw()
361 {
363 return m_bIsDIBSec;
364 }
365
366 bool IsIndexed() const throw()
367 {
369 return GetBPP() <= 8;
370 }
371
372 bool IsNull() const throw()
373 {
374 return m_hbm == NULL;
375 }
376
378 {
379 // convert the file name string into Unicode
380 CStringW pszNameW(pszFileName);
381
382 // create a GpBitmap object from file
383 using namespace Gdiplus;
384 GpBitmap *pBitmap = NULL;
385 if (GetCommon().CreateBitmapFromFile(pszNameW, &pBitmap) != Ok)
386 {
387 return E_FAIL;
388 }
389
390 // TODO & FIXME: get parameters (m_rgbTransColor etc.)
391
392 // get bitmap handle
393 HBITMAP hbm = NULL;
394 Color color(0xFF, 0xFF, 0xFF);
395 Gdiplus::Status status;
397 pBitmap, &hbm, color.GetValue());
398
399 // delete GpBitmap
400 GetCommon().DisposeImage(pBitmap);
401
402 // attach it
403 if (status == Ok)
404 Attach(hbm);
405 return (status == Ok ? S_OK : E_FAIL);
406 }
407 HRESULT Load(IStream* pStream) throw()
408 {
409 // create GpBitmap from stream
410 using namespace Gdiplus;
411 GpBitmap *pBitmap = NULL;
412 if (GetCommon().CreateBitmapFromStream(pStream, &pBitmap) != Ok)
413 {
414 return E_FAIL;
415 }
416
417 // TODO & FIXME: get parameters (m_rgbTransColor etc.)
418
419 // get bitmap handle
420 HBITMAP hbm = NULL;
421 Color color(0xFF, 0xFF, 0xFF);
422 Gdiplus::Status status;
424 pBitmap, &hbm, color.GetValue());
425
426 // delete Bitmap
427 GetCommon().DisposeImage(pBitmap);
428
429 // attach it
430 if (status == Ok)
431 Attach(hbm);
432 return (status == Ok ? S_OK : E_FAIL);
433 }
434
435 // NOTE: LoadFromResource loads BITMAP resource only
436 void LoadFromResource(HINSTANCE hInstance, LPCTSTR pszResourceName) throw()
437 {
438 HANDLE hHandle = ::LoadImage(hInstance, pszResourceName,
440 Attach(reinterpret_cast<HBITMAP>(hHandle));
441 }
442 void LoadFromResource(HINSTANCE hInstance, UINT nIDResource) throw()
443 {
445 }
446
447 BOOL MaskBlt(HDC hDestDC, int xDest, int yDest,
448 int nDestWidth, int nDestHeight, int xSrc, int ySrc,
449 HBITMAP hbmMask, int xMask, int yMask,
450 DWORD dwROP = SRCCOPY) const throw()
451 {
453 GetDC();
454 BOOL ret = ::MaskBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight,
455 m_hDC, xSrc, ySrc,
456 hbmMask, xMask, yMask, dwROP);
457 ReleaseDC();
458 return ret;
459 }
460 BOOL MaskBlt(HDC hDestDC, const RECT& rectDest, const POINT& pointSrc,
461 HBITMAP hbmMask, const POINT& pointMask,
462 DWORD dwROP = SRCCOPY) const throw()
463 {
464 return MaskBlt(hDestDC, rectDest.left, rectDest.top,
465 rectDest.right - rectDest.left, rectDest.bottom - rectDest.top,
466 pointSrc.x, pointSrc.y, hbmMask, pointMask.x, pointMask.y, dwROP);
467 }
468 BOOL MaskBlt(HDC hDestDC, int xDest, int yDest,
469 HBITMAP hbmMask, DWORD dwROP = SRCCOPY) const throw()
470 {
471 return MaskBlt(hDestDC, xDest, yDest, GetWidth(), GetHeight(),
472 0, 0, hbmMask, 0, 0, dwROP);
473 }
474 BOOL MaskBlt(HDC hDestDC, const POINT& pointDest,
475 HBITMAP hbmMask, DWORD dwROP = SRCCOPY) const throw()
476 {
477 return MaskBlt(hDestDC, pointDest.x, pointDest.y, hbmMask, dwROP);
478 }
479
480 BOOL PlgBlt(HDC hDestDC, const POINT* pPoints,
481 int xSrc, int ySrc, int nSrcWidth, int nSrcHeight,
482 HBITMAP hbmMask = NULL,
483 int xMask = 0, int yMask = 0) const throw()
484 {
486 GetDC();
487 BOOL ret = ::PlgBlt(hDestDC, pPoints, m_hDC,
488 xSrc, ySrc, nSrcWidth, nSrcHeight,
489 hbmMask, xMask, yMask);
490 ReleaseDC();
491 return ret;
492 }
493 BOOL PlgBlt(HDC hDestDC, const POINT* pPoints,
494 HBITMAP hbmMask = NULL) const throw()
495 {
496 return PlgBlt(hDestDC, pPoints, 0, 0, GetWidth(), GetHeight(),
497 hbmMask);
498 }
499 BOOL PlgBlt(HDC hDestDC, const POINT* pPoints, const RECT& rectSrc,
500 HBITMAP hbmMask, const POINT& pointMask) const throw()
501 {
502 return PlgBlt(hDestDC, pPoints, rectSrc.left, rectSrc.top,
503 rectSrc.right - rectSrc.left, rectSrc.bottom - rectSrc.top,
504 hbmMask, pointMask.x, pointMask.y);
505 }
506 BOOL PlgBlt(HDC hDestDC, const POINT* pPoints, const RECT& rectSrc,
507 HBITMAP hbmMask = NULL) const throw()
508 {
509 POINT pointMask = {0, 0};
510 return PlgBlt(hDestDC, pPoints, rectSrc, hbmMask, pointMask);
511 }
512
513 void ReleaseGDIPlus() throw()
514 {
515 COMMON*& pCommon = GetCommonPtr();
516 if (pCommon && pCommon->Release() == 0)
517 {
518 delete pCommon;
519 pCommon = NULL;
520 }
521 }
522
523 HRESULT Save(IStream* pStream, GUID *guidFileType) const throw()
524 {
525 using namespace Gdiplus;
527
528 // TODO & FIXME: set parameters (m_rgbTransColor etc.)
529 CLSID clsid;
530 if (!GetClsidFromFileType(&clsid, guidFileType))
531 return E_FAIL;
532
533 // create a GpBitmap from HBITMAP
534 GpBitmap *pBitmap = NULL;
536
537 // save to stream
539 status = GetCommon().SaveImageToStream(pBitmap, pStream, &clsid, NULL);
540
541 // destroy GpBitmap
542 GetCommon().DisposeImage(pBitmap);
543
544 return (status == Ok ? S_OK : E_FAIL);
545 }
546
548 REFGUID guidFileType = GUID_NULL) const throw()
549 {
550 using namespace Gdiplus;
552
553 // TODO & FIXME: set parameters (m_rgbTransColor etc.)
554
555 // convert the file name string into Unicode
556 CStringW pszNameW(pszFileName);
557
558 // if the file type is null, get the file type from extension
559 const GUID *FileType = &guidFileType;
560 if (IsGuidEqual(guidFileType, GUID_NULL))
561 {
562 LPCWSTR pszExt = GetFileExtension(pszNameW);
564 }
565
566 // get CLSID from file type
567 CLSID clsid;
569 return E_FAIL;
570
571 // create a GpBitmap from HBITMAP
572 GpBitmap *pBitmap = NULL;
574
575 // save to file
577 status = GetCommon().SaveImageToFile(pBitmap, pszNameW, &clsid, NULL);
578
579 // destroy GpBitmap
580 GetCommon().DisposeImage(pBitmap);
581
582 return (status == Ok ? S_OK : E_FAIL);
583 }
584
585 void SetColorTable(UINT iFirstColor, UINT nColors,
586 const RGBQUAD* prgbColors) throw()
587 {
589 GetDC();
590 ::SetDIBColorTable(m_hDC, iFirstColor, nColors, prgbColors);
591 ReleaseDC();
592 }
593
594 void SetPixel(int x, int y, COLORREF color) throw()
595 {
596 GetDC();
598 ReleaseDC();
599 }
600
601 void SetPixelIndexed(int x, int y, int iIndex) throw()
602 {
604 GetDC();
605 ::SetPixelV(m_hDC, x, y, PALETTEINDEX(iIndex));
606 ReleaseDC();
607 }
608
609 void SetPixelRGB(int x, int y, BYTE r, BYTE g, BYTE b) throw()
610 {
611 SetPixel(x, y, RGB(r, g, b));
612 }
613
614 COLORREF SetTransparentColor(COLORREF rgbTransparent) throw()
615 {
617 COLORREF rgbOldColor = m_rgbTransColor;
618 m_rgbTransColor = rgbTransparent;
619 return rgbOldColor;
620 }
621
622 BOOL StretchBlt(HDC hDestDC, int xDest, int yDest,
623 int nDestWidth, int nDestHeight,
624 int xSrc, int ySrc, int nSrcWidth, int nSrcHeight,
625 DWORD dwROP = SRCCOPY) const throw()
626 {
627 GetDC();
628 BOOL ret = ::StretchBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight,
629 m_hDC, xSrc, ySrc, nSrcWidth, nSrcHeight, dwROP);
630 ReleaseDC();
631 return ret;
632 }
633 BOOL StretchBlt(HDC hDestDC, int xDest, int yDest,
634 int nDestWidth, int nDestHeight,
635 DWORD dwROP = SRCCOPY) const throw()
636 {
637 return StretchBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight,
638 0, 0, GetWidth(), GetHeight(), dwROP);
639 }
640 BOOL StretchBlt(HDC hDestDC, const RECT& rectDest,
641 DWORD dwROP = SRCCOPY) const throw()
642 {
643 return StretchBlt(hDestDC, rectDest.left, rectDest.top,
644 rectDest.right - rectDest.left,
645 rectDest.bottom - rectDest.top, dwROP);
646 }
647 BOOL StretchBlt(HDC hDestDC, const RECT& rectDest,
648 const RECT& rectSrc, DWORD dwROP = SRCCOPY) const throw()
649 {
650 return StretchBlt(hDestDC, rectDest.left, rectDest.top,
651 rectDest.right - rectDest.left,
652 rectDest.bottom - rectDest.top,
653 rectSrc.left, rectSrc.top,
654 rectSrc.right - rectSrc.left,
655 rectSrc.bottom - rectSrc.top, dwROP);
656 }
657
658 BOOL TransparentBlt(HDC hDestDC, int xDest, int yDest,
659 int nDestWidth, int nDestHeight,
660 int xSrc, int ySrc, int nSrcWidth, int nSrcHeight,
661 UINT crTransparent = CLR_INVALID) const throw()
662 {
664 GetDC();
665 BOOL ret = ::TransparentBlt(hDestDC, xDest, yDest,
666 nDestWidth, nDestHeight,
667 m_hDC, xSrc, ySrc,
668 nSrcWidth, nSrcHeight, crTransparent);
669 ReleaseDC();
670 return ret;
671 }
672 BOOL TransparentBlt(HDC hDestDC, int xDest, int yDest,
673 int nDestWidth, int nDestHeight,
674 UINT crTransparent = CLR_INVALID) const throw()
675 {
676 return TransparentBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight,
677 0, 0, GetWidth(), GetHeight(), crTransparent);
678 }
679 BOOL TransparentBlt(HDC hDestDC, const RECT& rectDest,
680 UINT crTransparent = CLR_INVALID) const throw()
681 {
682 return TransparentBlt(hDestDC, rectDest.left, rectDest.top,
683 rectDest.right - rectDest.left,
684 rectDest.bottom - rectDest.top, crTransparent);
685 }
687 HDC hDestDC, const RECT& rectDest,
688 const RECT& rectSrc, UINT crTransparent = CLR_INVALID) const throw()
689 {
690 return TransparentBlt(hDestDC, rectDest.left, rectDest.top,
691 rectDest.right - rectDest.left, rectDest.bottom - rectDest.left,
692 rectSrc.left, rectSrc.top, rectSrc.right - rectSrc.left,
693 rectSrc.bottom - rectSrc.top, crTransparent);
694 }
695
696public:
698 {
699 return TRUE;
700 }
701
703 {
712 excludeOther = 0x80000000,
715 };
716
717 struct FILTER_DATA {
719 const TCHAR *title;
721 const GUID *guid;
722 };
723
724protected:
726 CSimpleString& strFilter,
727 CSimpleArray<GUID>& aguidFileTypes,
728 LPCTSTR pszAllFilesDescription,
729 DWORD dwExclude,
730 TCHAR chSeparator)
731 {
732 static const FILTER_DATA table[] =
733 {
734 {excludeBMP, TEXT("BMP"), TEXT("*.BMP;*.DIB;*.RLE"), &Gdiplus::ImageFormatBMP},
735 {excludeJPEG, TEXT("JPEG"), TEXT("*.JPG;*.JPEG;*.JPE;*.JFIF"), &Gdiplus::ImageFormatJPEG},
736 {excludeGIF, TEXT("GIF"), TEXT("*.GIF"), &Gdiplus::ImageFormatGIF},
737 {excludeEMF, TEXT("EMF"), TEXT("*.EMF"), &Gdiplus::ImageFormatEMF},
738 {excludeWMF, TEXT("WMF"), TEXT("*.WMF"), &Gdiplus::ImageFormatWMF},
739 {excludeTIFF, TEXT("TIFF"), TEXT("*.TIF;*.TIFF"), &Gdiplus::ImageFormatTIFF},
740 {excludePNG, TEXT("PNG"), TEXT("*.PNG"), &Gdiplus::ImageFormatPNG},
741 {excludeIcon, TEXT("ICO"), TEXT("*.ICO"), &Gdiplus::ImageFormatIcon}
742 };
743
744 if (pszAllFilesDescription)
745 {
746 strFilter += pszAllFilesDescription;
747 strFilter += chSeparator;
748
749 BOOL bFirst = TRUE;
750 for (size_t i = 0; i < _countof(table); ++i)
751 {
752 if ((dwExclude & table[i].dwExclude) != 0)
753 continue;
754
755 if (bFirst)
756 bFirst = FALSE;
757 else
758 strFilter += TEXT(';');
759
760 strFilter += table[i].extensions;
761 }
762 strFilter += chSeparator;
763
764 aguidFileTypes.Add(GUID_NULL);
765 }
766
767 for (size_t i = 0; i < _countof(table); ++i)
768 {
769 if ((dwExclude & table[i].dwExclude) != 0)
770 continue;
771 strFilter += table[i].title;
772 strFilter += TEXT(" (");
773 strFilter += table[i].extensions;
774 strFilter += TEXT(")");
775 strFilter += chSeparator;
776 strFilter += table[i].extensions;
777 strFilter += chSeparator;
778
779 aguidFileTypes.Add(*table[i].guid);
780 }
781
782 strFilter += chSeparator;
783
784 return S_OK;
785 }
786
787public:
789 CSimpleString& strImporters,
790 CSimpleArray<GUID>& aguidFileTypes,
791 LPCTSTR pszAllFilesDescription = NULL,
792 DWORD dwExclude = excludeDefaultLoad,
793 TCHAR chSeparator = TEXT('|'))
794 {
795 return GetCommonFilterString(strImporters,
796 aguidFileTypes,
797 pszAllFilesDescription,
798 dwExclude,
799 chSeparator);
800 }
801
803 CSimpleString& strExporters,
804 CSimpleArray<GUID>& aguidFileTypes,
805 LPCTSTR pszAllFilesDescription = NULL,
806 DWORD dwExclude = excludeDefaultSave,
807 TCHAR chSeparator = TEXT('|'))
808 {
809 return GetCommonFilterString(strExporters,
810 aguidFileTypes,
811 pszAllFilesDescription,
812 dwExclude,
813 chSeparator);
814 }
815
816protected:
817 // an extension of BITMAPINFO
819 {
823 {
824 return reinterpret_cast<BITMAPINFO *>(this);
825 }
826 const BITMAPINFO *get() const
827 {
828 return reinterpret_cast<const BITMAPINFO *>(this);
829 }
830 };
831
832 // abbreviations of GDI+ basic types
833 typedef Gdiplus::GpStatus St;
834 typedef Gdiplus::GpBitmap Bm;
835 typedef Gdiplus::GpImage Im;
836
837 // The common data of atlimage
838 struct COMMON
839 {
840 // abbreviations of GDI+ basic types
841 typedef Gdiplus::ImageCodecInfo ICI;
842 typedef Gdiplus::EncoderParameters EncParams;
843 typedef Gdiplus::ARGB ARGB;
844 typedef HBITMAP HBM;
845 typedef Gdiplus::GdiplusStartupInput GSI;
846 typedef Gdiplus::GdiplusStartupOutput GSO;
847
848 // GDI+ function types
849#undef API
850#undef CST
851#define API WINGDIPAPI
852#define CST GDIPCONST
853 typedef St (WINAPI *STARTUP)(ULONG_PTR *, const GSI *, GSO *);
860 typedef St (API *CREATEBITMAPFROMHBITMAP)(HBM, HPALETTE, Bm **);
862 CST EncParams *);
863 typedef St (API *SAVEIMAGETOFILE)(Im *, CST WCHAR *, CST CLSID *,
864 CST EncParams *);
865 typedef St (API *DISPOSEIMAGE)(Im*);
866#undef API
867#undef CST
868
869 // members
870 int count;
873
874 // GDI+ functions
886
888 {
889 count = 0;
891 Startup = NULL;
892 Shutdown = NULL;
902 }
904 {
905 FreeLib();
906 }
907
909 {
910 return ++count;
911 }
913 {
914 return --count;
915 }
916
917 // get procedure address of the DLL
918 template <typename TYPE>
919 TYPE AddrOf(const char *name)
920 {
922 return reinterpret_cast<TYPE>(proc);
923 }
924
926 {
927 if (hinstGdiPlus)
928 return hinstGdiPlus;
929
930 hinstGdiPlus = ::LoadLibraryA("gdiplus.dll");
931
932 // get procedure addresses from the DLL
933 Startup = AddrOf<STARTUP>("GdiplusStartup");
934 Shutdown = AddrOf<SHUTDOWN>("GdiplusShutdown");
936 AddrOf<GETIMAGEENCODERSSIZE>("GdipGetImageEncodersSize");
937 GetImageEncoders = AddrOf<GETIMAGEENCODERS>("GdipGetImageEncoders");
939 AddrOf<CREATEBITMAPFROMFILE>("GdipCreateBitmapFromFile");
941 AddrOf<CREATEHBITMAPFROMBITMAP>("GdipCreateHBITMAPFromBitmap");
943 AddrOf<CREATEBITMAPFROMSTREAM>("GdipCreateBitmapFromStream");
945 AddrOf<CREATEBITMAPFROMHBITMAP>("GdipCreateBitmapFromHBITMAP");
947 AddrOf<SAVEIMAGETOSTREAM>("GdipSaveImageToStream");
948 SaveImageToFile = AddrOf<SAVEIMAGETOFILE>("GdipSaveImageToFile");
949 DisposeImage = AddrOf<DISPOSEIMAGE>("GdipDisposeImage");
950
951 if (hinstGdiPlus && Startup)
952 {
953 Gdiplus::GdiplusStartupInput gdiplusStartupInput;
954 Startup(&gdiplusToken, &gdiplusStartupInput, NULL);
955 }
956
957 return hinstGdiPlus;
958 }
959 void FreeLib()
960 {
961 if (hinstGdiPlus)
962 {
964
965 Startup = NULL;
966 Shutdown = NULL;
978 }
979 }
980 }; // struct COMMON
981
983 {
984 static COMMON *s_pCommon = NULL;
985 return s_pCommon;
986 }
987
989 {
990 COMMON*& pCommon = GetCommonPtr();
991 if (pCommon == NULL)
992 pCommon = new COMMON;
993 return *pCommon;
994 }
995
996protected:
999 mutable HDC m_hDC;
1004 union
1005 {
1008 };
1009
1011 {
1013 if (pch == NULL)
1014 pch = wcsrchr(pszFileName, L'/');
1015 pch = (pch ? wcsrchr(pch, L'.') : wcsrchr(pszFileName, L'.'));
1016 return (pch ? pch : (pszFileName + ::lstrlenW(pszFileName)));
1017 }
1018
1020 {
1021 RGBQUAD table[256];
1022 GetColorTable(0, 256, table);
1023 RGBQUAD& quad = table[iIndex];
1024 return RGB(quad.rgbRed, quad.rgbGreen, quad.rgbBlue);
1025 }
1026
1028 {
1031 };
1032
1034 {
1035 static const EXTENSION_ENTRY table[] =
1036 {
1037 {L".jpg", Gdiplus::ImageFormatJPEG},
1038 {L".png", Gdiplus::ImageFormatPNG},
1039 {L".bmp", Gdiplus::ImageFormatBMP},
1040 {L".gif", Gdiplus::ImageFormatGIF},
1041 {L".tif", Gdiplus::ImageFormatTIFF},
1042 {L".jpeg", Gdiplus::ImageFormatJPEG},
1043 {L".jpe", Gdiplus::ImageFormatJPEG},
1044 {L".jfif", Gdiplus::ImageFormatJPEG},
1045 {L".dib", Gdiplus::ImageFormatBMP},
1046 {L".rle", Gdiplus::ImageFormatBMP},
1047 {L".tiff", Gdiplus::ImageFormatTIFF}
1048 };
1049 const size_t count = _countof(table);
1050 for (size_t i = 0; i < count; ++i)
1051 {
1052 if (::lstrcmpiW(table[i].pszExt, pszExt) == 0)
1053 return &table[i].guid;
1054 }
1055 return NULL;
1056 }
1057
1059 {
1062 };
1063
1065 {
1066 static const FORMAT_ENTRY table[] =
1067 {
1068 {Gdiplus::ImageFormatJPEG, L"image/jpeg"},
1069 {Gdiplus::ImageFormatPNG, L"image/png"},
1070 {Gdiplus::ImageFormatBMP, L"image/bmp"},
1071 {Gdiplus::ImageFormatGIF, L"image/gif"},
1072 {Gdiplus::ImageFormatTIFF, L"image/tiff"}
1073 };
1074 const size_t count = _countof(table);
1075 for (size_t i = 0; i < count; ++i)
1076 {
1077 if (IsGuidEqual(table[i].guid, *guid))
1078 {
1080 if (num >= 0)
1081 {
1082 return true;
1083 }
1084 }
1085 }
1086 return false;
1087 }
1088
1090 {
1091 UINT count = 0, total_size = 0;
1092 GetCommon().GetImageEncodersSize(&count, &total_size);
1093 if (total_size == 0)
1094 return -1; // failure
1095
1096 Gdiplus::ImageCodecInfo *pInfo;
1097 BYTE *pb = new BYTE[total_size];
1098 ATLASSERT(pb);
1099 pInfo = reinterpret_cast<Gdiplus::ImageCodecInfo *>(pb);
1100 if (pInfo == NULL)
1101 return -1; // failure
1102
1103 GetCommon().GetImageEncoders(count, total_size, pInfo);
1104
1105 for (UINT iInfo = 0; iInfo < count; ++iInfo)
1106 {
1107 if (::lstrcmpiW(pInfo[iInfo].MimeType, mime) == 0)
1108 {
1109 *clsid = pInfo[iInfo].Clsid;
1110 delete[] pb;
1111 return iInfo; // success
1112 }
1113 }
1114
1115 delete[] pb;
1116 return -1; // failure
1117 }
1118
1119 bool IsGuidEqual(const GUID& guid1, const GUID& guid2) const
1120 {
1122 if (::UuidEqual(const_cast<GUID *>(&guid1),
1123 const_cast<GUID *>(&guid2), &status))
1124 {
1125 if (status == RPC_S_OK)
1126 return true;
1127 }
1128 return false;
1129 }
1130
1133 {
1134 Destroy();
1135
1136 const int size = sizeof(DIBSECTION);
1138
1139 bool bOK = (::GetObject(hBitmap, sizeof(BITMAP), &m_bm) != 0);
1140
1141 if (bOK)
1142 {
1143 m_hbm = hBitmap;
1144 m_eOrientation = eOrientation;
1145 m_bHasAlphaCh = (m_bm.bmBitsPixel == 32);
1147 }
1148 }
1149
1150 BOOL CreateInternal(int nWidth, int nHeight, int nBPP,
1151 DWORD eCompression, const DWORD* pdwBitmasks = NULL,
1152 DWORD dwFlags = 0) throw()
1153 {
1154 ATLASSERT(nWidth != 0);
1155 ATLASSERT(nHeight != 0);
1156
1157 // initialize BITMAPINFO extension
1158 MYBITMAPINFOEX bi;
1159 ZeroMemory(&bi, sizeof(bi));
1160 bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1161 bi.bmiHeader.biWidth = nWidth;
1162 bi.bmiHeader.biHeight = nHeight;
1163 bi.bmiHeader.biPlanes = 1;
1164 bi.bmiHeader.biBitCount = nBPP;
1165 bi.bmiHeader.biCompression = eCompression;
1166
1167 // is there alpha channel?
1168 bool bHasAlphaCh;
1169 bHasAlphaCh = (nBPP == 32 && (dwFlags & createAlphaChannel));
1170
1171 // get orientation
1172 DIBOrientation eOrientation;
1173 eOrientation = ((nHeight > 0) ? DIBOR_BOTTOMUP : DIBOR_TOPDOWN);
1174
1175 // does it have bit fields?
1176 if (eCompression == BI_BITFIELDS)
1177 {
1178 if (nBPP == 16 || nBPP == 32)
1179 {
1180 // store the mask data
1181 LPDWORD pdwMask = reinterpret_cast<LPDWORD>(bi.bmiColors);
1182 pdwMask[0] = pdwBitmasks[0];
1183 pdwMask[1] = pdwBitmasks[1];
1184 pdwMask[2] = pdwBitmasks[2];
1185 }
1186 else
1187 {
1188 return FALSE;
1189 }
1190 }
1191 else
1192 {
1193 ATLASSERT(pdwBitmasks == NULL);
1194 if (pdwBitmasks)
1195 return FALSE;
1196 }
1197
1198 // create a DIB section
1200 ATLASSERT(hDC);
1201 LPVOID pvBits;
1203 &pvBits, NULL, 0);
1204 ATLASSERT(hbm);
1205 ::DeleteDC(hDC);
1206
1207 // attach it
1208 AttachInternal(hbm, eOrientation, -1);
1209 m_bHasAlphaCh = bHasAlphaCh;
1210
1211 return hbm != NULL;
1212 }
1213
1214private:
1215 // NOTE: CImage is not copyable
1218};
1219
1220}
1221
1222#endif
1223
1224#ifndef _ATL_NO_AUTOMATIC_NAMESPACE
1225using namespace ATL;
1226#endif
static HDC hDC
Definition: 3dtext.c:33
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
static CREATEBITMAPFROMFILE CreateBitmapFromFile
Definition: CImage.cpp:83
#define CST
Definition: atlimage.h:852
#define API
Definition: atlimage.h:851
HINSTANCE hInstance
Definition: charmap.c:19
BOOL BitBlt(HDC hDestDC, const RECT &rectDest, const POINT &pointSrc, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:188
const GUID * FileTypeFromExtension(LPCWSTR pszExt) const
Definition: atlimage.h:1033
BOOL Draw(HDC hDestDC, int xDest, int yDest) const
Definition: atlimage.h:250
DIBOrientation m_eOrientation
Definition: atlimage.h:1000
HBITMAP m_hbm
Definition: atlimage.h:997
void Attach(HBITMAP hBitmap, DIBOrientation eOrientation=DIBOR_DEFAULT)
Definition: atlimage.h:79
BOOL Create(int nWidth, int nHeight, int nBPP, DWORD dwFlags=0)
Definition: atlimage.h:197
COLORREF m_rgbTransColor
Definition: atlimage.h:1003
BOOL MaskBlt(HDC hDestDC, int xDest, int yDest, HBITMAP hbmMask, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:468
BOOL MaskBlt(HDC hDestDC, const POINT &pointDest, HBITMAP hbmMask, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:474
int GetBPP() const
Definition: atlimage.h:282
void LoadFromResource(HINSTANCE hInstance, LPCTSTR pszResourceName)
Definition: atlimage.h:436
BOOL BitBlt(HDC hDestDC, int xDest, int yDest, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:177
bool m_bIsDIBSec
Definition: atlimage.h:1002
BOOL AlphaBlend(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, BYTE bSrcAlpha=0xFF, BYTE bBlendOp=AC_SRC_OVER) const
Definition: atlimage.h:123
HRESULT Load(LPCTSTR pszFileName)
Definition: atlimage.h:377
void SetPixelRGB(int x, int y, BYTE r, BYTE g, BYTE b)
Definition: atlimage.h:609
HRESULT Save(IStream *pStream, GUID *guidFileType) const
Definition: atlimage.h:523
void * GetBits()
Definition: atlimage.h:271
BOOL AlphaBlend(HDC hDestDC, const POINT &pointDest, BYTE bSrcAlpha=0xFF, BYTE bBlendOp=AC_SRC_OVER) const
Definition: atlimage.h:150
int GetPitch() const
Definition: atlimage.h:323
BOOL Draw(HDC hDestDC, const POINT &pointDest) const
Definition: atlimage.h:254
Gdiplus::GpBitmap Bm
Definition: atlimage.h:834
BOOL CreateEx(int nWidth, int nHeight, int nBPP, DWORD eCompression, const DWORD *pdwBitmasks=NULL, DWORD dwFlags=0)
Definition: atlimage.h:202
int GetMaxColorTableEntries() const
Definition: atlimage.h:303
HRESULT Save(LPCTSTR pszFileName, REFGUID guidFileType=GUID_NULL) const
Definition: atlimage.h:547
DIBSECTION m_ds
Definition: atlimage.h:1007
static HRESULT GetImporterFilterString(CSimpleString &strImporters, CSimpleArray< GUID > &aguidFileTypes, LPCTSTR pszAllFilesDescription=NULL, DWORD dwExclude=excludeDefaultLoad, TCHAR chSeparator=TEXT('|'))
Definition: atlimage.h:788
BOOL StretchBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:633
HRESULT Load(IStream *pStream)
Definition: atlimage.h:407
BOOL BitBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:167
void Destroy()
Definition: atlimage.h:208
BOOL CreateInternal(int nWidth, int nHeight, int nBPP, DWORD eCompression, const DWORD *pdwBitmasks=NULL, DWORD dwFlags=0)
Definition: atlimage.h:1150
@ DIBOR_DEFAULT
Definition: atlimage.h:44
@ DIBOR_TOPDOWN
Definition: atlimage.h:46
@ DIBOR_BOTTOMUP
Definition: atlimage.h:45
bool GetClsidFromFileType(CLSID *clsid, const GUID *guid) const
Definition: atlimage.h:1064
BOOL MaskBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, HBITMAP hbmMask, int xMask, int yMask, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:447
HDC GetDC() const
Definition: atlimage.h:96
BITMAP m_bm
Definition: atlimage.h:1006
BOOL TransparentBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, UINT crTransparent=CLR_INVALID) const
Definition: atlimage.h:672
@ createAlphaChannel
Definition: atlimage.h:38
void GetColorTable(UINT iFirstColor, UINT nColors, RGBQUAD *prgbColors) const
Definition: atlimage.h:288
HBITMAP Detach()
Definition: atlimage.h:84
void SetColorTable(UINT iFirstColor, UINT nColors, const RGBQUAD *prgbColors)
Definition: atlimage.h:585
BOOL TransparentBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, UINT crTransparent=CLR_INVALID) const
Definition: atlimage.h:658
BOOL Draw(HDC hDestDC, const RECT &rectDest) const
Definition: atlimage.h:264
BOOL Draw(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight) const
Definition: atlimage.h:258
Gdiplus::GpImage Im
Definition: atlimage.h:835
void ReleaseDC() const
Definition: atlimage.h:106
BOOL StretchBlt(HDC hDestDC, const RECT &rectDest, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:640
BOOL StretchBlt(HDC hDestDC, const RECT &rectDest, const RECT &rectSrc, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:647
BOOL PlgBlt(HDC hDestDC, const POINT *pPoints, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, HBITMAP hbmMask=NULL, int xMask=0, int yMask=0) const
Definition: atlimage.h:480
BOOL TransparentBlt(HDC hDestDC, const RECT &rectDest, UINT crTransparent=CLR_INVALID) const
Definition: atlimage.h:679
Gdiplus::GpStatus St
Definition: atlimage.h:833
CImage(const CImage &)
bool IsIndexed() const
Definition: atlimage.h:366
bool m_bHasAlphaCh
Definition: atlimage.h:1001
int GetWidth() const
Definition: atlimage.h:354
BOOL PlgBlt(HDC hDestDC, const POINT *pPoints, const RECT &rectSrc, HBITMAP hbmMask, const POINT &pointMask) const
Definition: atlimage.h:499
static HRESULT GetCommonFilterString(CSimpleString &strFilter, CSimpleArray< GUID > &aguidFileTypes, LPCTSTR pszAllFilesDescription, DWORD dwExclude, TCHAR chSeparator)
Definition: atlimage.h:725
HGDIOBJ m_hbmOld
Definition: atlimage.h:998
bool IsNull() const
Definition: atlimage.h:372
BOOL PlgBlt(HDC hDestDC, const POINT *pPoints, HBITMAP hbmMask=NULL) const
Definition: atlimage.h:493
COLORREF GetTransparentColor() const
Definition: atlimage.h:349
LPCWSTR GetFileExtension(LPCWSTR pszFileName) const
Definition: atlimage.h:1010
int GetHeight() const
Definition: atlimage.h:297
static COMMON *& GetCommonPtr()
Definition: atlimage.h:982
static HRESULT GetExporterFilterString(CSimpleString &strExporters, CSimpleArray< GUID > &aguidFileTypes, LPCTSTR pszAllFilesDescription=NULL, DWORD dwExclude=excludeDefaultSave, TCHAR chSeparator=TEXT('|'))
Definition: atlimage.h:802
static COMMON & GetCommon()
Definition: atlimage.h:988
void AttachInternal(HBITMAP hBitmap, DIBOrientation eOrientation, LONG iTransColor)
Definition: atlimage.h:1131
bool IsDIBSection() const
Definition: atlimage.h:360
int GetEncoderClsid(LPCWSTR mime, CLSID *clsid) const
Definition: atlimage.h:1089
BOOL AlphaBlend(HDC hDestDC, const RECT &rectDest, const RECT &rectSrc, BYTE bSrcAlpha=0xFF, BYTE bBlendOp=AC_SRC_OVER) const
Definition: atlimage.h:155
BOOL MaskBlt(HDC hDestDC, const RECT &rectDest, const POINT &pointSrc, HBITMAP hbmMask, const POINT &pointMask, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:460
void ReleaseGDIPlus()
Definition: atlimage.h:513
COLORREF SetTransparentColor(COLORREF rgbTransparent)
Definition: atlimage.h:614
bool IsGuidEqual(const GUID &guid1, const GUID &guid2) const
Definition: atlimage.h:1119
BOOL TransparentBlt(HDC hDestDC, const RECT &rectDest, const RECT &rectSrc, UINT crTransparent=CLR_INVALID) const
Definition: atlimage.h:686
void LoadFromResource(HINSTANCE hInstance, UINT nIDResource)
Definition: atlimage.h:442
BOOL BitBlt(HDC hDestDC, const POINT &pointDest, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:183
COLORREF RGBFromPaletteIndex(int iIndex) const
Definition: atlimage.h:1019
void SetPixel(int x, int y, COLORREF color)
Definition: atlimage.h:594
BOOL StretchBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwROP=SRCCOPY) const
Definition: atlimage.h:622
COLORREF GetPixel(int x, int y) const
Definition: atlimage.h:332
CImage & operator=(const CImage &)
BOOL PlgBlt(HDC hDestDC, const POINT *pPoints, const RECT &rectSrc, HBITMAP hbmMask=NULL) const
Definition: atlimage.h:506
BOOL Draw(HDC hDestDC, const RECT &rectDest, const RECT &rectSrc) const
Definition: atlimage.h:241
void * GetPixelAddress(int x, int y)
Definition: atlimage.h:340
static BOOL IsTransparencySupported()
Definition: atlimage.h:697
BOOL Draw(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight) const
Definition: atlimage.h:216
@ excludeDefaultLoad
Definition: atlimage.h:713
@ excludeDefaultSave
Definition: atlimage.h:714
@ excludeOther
Definition: atlimage.h:712
BOOL AlphaBlend(HDC hDestDC, int xDest, int yDest, BYTE bSrcAlpha=0xFF, BYTE bBlendOp=AC_SRC_OVER) const
Definition: atlimage.h:142
void SetPixelIndexed(int x, int y, int iIndex)
Definition: atlimage.h:601
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static HBITMAP hBitmap
Definition: timezone.c:26
int(* FARPROC)()
Definition: compat.h:36
#define wcsrchr
Definition: compat.h:16
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define lstrlenW
Definition: compat.h:750
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define BI_RGB
Definition: precomp.h:47
#define RGB(r, g, b)
Definition: precomp.h:62
ULONG RGBQUAD
Definition: precomp.h:50
#define ULONG_PTR
Definition: config.h:101
TYPE
Definition: eventcreate.c:652
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
Status
Definition: gdiplustypes.h:25
@ Ok
Definition: gdiplustypes.h:26
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
GLuint color
Definition: glext.h:6243
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean g
Definition: glext.h:6204
GLuint GLuint num
Definition: glext.h:9618
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define S_OK
Definition: intsafe.h:52
#define TEXT(s)
Definition: k32.h:26
#define GUID_NULL
Definition: ks.h:106
if(dx< 0)
Definition: linetemp.h:194
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
const GUID * guid
const WCHAR * mime
Definition: mimefilter.c:512
#define pch(ap)
Definition: match.c:418
#define BI_BITFIELDS
Definition: mmreg.h:507
#define AC_SRC_ALPHA
Definition: alphablend.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
static GUID guid2
Definition: devinst.c:42
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
REFCLSID clsid
Definition: msctf.c:82
Definition: rosdlgs.h:6
unsigned int UINT
Definition: ndis.h:50
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define L(x)
Definition: ntvdm.h:50
static HANDLE proc()
Definition: pdb.c:34
long LONG
Definition: pedump.c:60
static void quad(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLuint pv)
Definition: quads.c:63
#define RPC_S_OK
Definition: rpcnterr.h:22
int WINAPI UuidEqual(UUID *Uuid1, UUID *Uuid2, RPC_STATUS *Status)
Definition: rpcrt4_main.c:252
long RPC_STATUS
Definition: rpc.h:52
#define _countof(array)
Definition: sndvol32.h:68
TYPE AddrOf(const char *name)
Definition: atlimage.h:919
DISPOSEIMAGE DisposeImage
Definition: atlimage.h:885
Gdiplus::GdiplusStartupOutput GSO
Definition: atlimage.h:846
St(API * GETIMAGEENCODERS)(UINT, UINT, ICI *)
Definition: atlimage.h:856
HINSTANCE hinstGdiPlus
Definition: atlimage.h:871
ULONG_PTR gdiplusToken
Definition: atlimage.h:872
GETIMAGEENCODERS GetImageEncoders
Definition: atlimage.h:878
Gdiplus::GdiplusStartupInput GSI
Definition: atlimage.h:845
St(API * CREATEBITMAPFROMHBITMAP)(HBM, HPALETTE, Bm **)
Definition: atlimage.h:860
Gdiplus::ImageCodecInfo ICI
Definition: atlimage.h:841
St(API * SAVEIMAGETOFILE)(Im *, CST WCHAR *, CST CLSID *, CST EncParams *)
Definition: atlimage.h:863
SAVEIMAGETOFILE SaveImageToFile
Definition: atlimage.h:884
St(WINAPI * STARTUP)(ULONG_PTR *, const GSI *, GSO *)
Definition: atlimage.h:853
St(API * CREATEHBITMAPFROMBITMAP)(Bm *, HBM *, ARGB)
Definition: atlimage.h:858
SHUTDOWN Shutdown
Definition: atlimage.h:876
CREATEBITMAPFROMFILE CreateBitmapFromFile
Definition: atlimage.h:879
HINSTANCE LoadLib()
Definition: atlimage.h:925
St(API * CREATEBITMAPFROMFILE)(CST WCHAR *, Bm **)
Definition: atlimage.h:857
St(API * CREATEBITMAPFROMSTREAM)(IStream *, Bm **)
Definition: atlimage.h:859
void(WINAPI * SHUTDOWN)(ULONG_PTR)
Definition: atlimage.h:854
CREATEHBITMAPFROMBITMAP CreateHBITMAPFromBitmap
Definition: atlimage.h:880
SAVEIMAGETOSTREAM SaveImageToStream
Definition: atlimage.h:883
St(API * SAVEIMAGETOSTREAM)(Im *, IStream *, CST CLSID *, CST EncParams *)
Definition: atlimage.h:861
Gdiplus::ARGB ARGB
Definition: atlimage.h:843
CREATEBITMAPFROMSTREAM CreateBitmapFromStream
Definition: atlimage.h:881
GETIMAGEENCODERSSIZE GetImageEncodersSize
Definition: atlimage.h:877
St(API * DISPOSEIMAGE)(Im *)
Definition: atlimage.h:865
Gdiplus::EncoderParameters EncParams
Definition: atlimage.h:842
CREATEBITMAPFROMHBITMAP CreateBitmapFromHBITMAP
Definition: atlimage.h:882
St(API * GETIMAGEENCODERSSIZE)(UINT *, UINT *)
Definition: atlimage.h:855
Definition: atlimage.h:1028
LPCWSTR pszExt
Definition: atlimage.h:1029
GUID guid
Definition: atlimage.h:1030
const TCHAR * title
Definition: atlimage.h:719
const TCHAR * extensions
Definition: atlimage.h:720
Definition: atlimage.h:1059
GUID guid
Definition: atlimage.h:1060
LPCWSTR mime
Definition: atlimage.h:1061
BITMAPINFOHEADER bmiHeader
Definition: atlimage.h:820
const BITMAPINFO * get() const
Definition: atlimage.h:826
DWORD biCompression
Definition: amvideo.idl:35
Definition: bl.h:1331
BYTE BlendOp
Definition: wingdi.h:2759
BYTE BlendFlags
Definition: wingdi.h:2760
BYTE AlphaFormat
Definition: wingdi.h:2762
BYTE SourceConstantAlpha
Definition: wingdi.h:2761
Definition: scsiwmi.h:51
Definition: name.c:39
Definition: ps.c:97
USHORT biBitCount
Definition: precomp.h:37
ULONG biCompression
Definition: precomp.h:38
BITMAPINFOHEADER dsBmih
Definition: wingdi.h:1670
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
uint32_t * LPDWORD
Definition: typedefs.h:59
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
int ret
_In_ WDFDEVICE _In_ WDF_SPECIAL_FILE_TYPE FileType
Definition: wdfdevice.h:2741
#define TransparentBlt
Definition: misc.c:292
#define AlphaBlend
Definition: misc.c:293
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:199
UINT WINAPI GetDIBColorTable(HDC hDC, UINT iStartIndex, UINT cEntries, RGBQUAD *pColors)
Definition: palette.c:123
#define ZeroMemory
Definition: winbase.h:1670
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_ RECTL _In_ ULONG iTransColor
Definition: winddi.h:4195
_In_ ULONG _In_ ULONG rgb
Definition: winddi.h:3521
DWORD COLORREF
Definition: windef.h:300
#define WINAPI
Definition: msvc.h:6
#define PALETTEINDEX(i)
Definition: wingdi.h:2943
#define DIB_RGB_COLORS
Definition: wingdi.h:367
struct tagDIBSECTION DIBSECTION
#define AC_SRC_OVER
Definition: wingdi.h:1369
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define CLR_INVALID
Definition: wingdi.h:883
#define SRCCOPY
Definition: wingdi.h:333
UINT WINAPI SetDIBColorTable(_In_ HDC hdc, _In_ UINT iStart, _In_ UINT cEntries, _In_reads_(cEntries) const RGBQUAD *prgbq)
BOOL WINAPI SetPixelV(_In_ HDC, _In_ int, _In_ int, _In_ COLORREF)
#define GetObject
Definition: wingdi.h:4468
BOOL WINAPI DeleteDC(_In_ HDC)
#define IMAGE_BITMAP
Definition: winuser.h:211
#define LR_CREATEDIBSECTION
Definition: winuser.h:1092
#define LoadImage
Definition: winuser.h:5805
#define MAKEINTRESOURCE
Definition: winuser.h:591
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193