ReactOS  0.4.14-dev-608-gd495a4f
CImage.cpp File Reference
#include <atlimage.h>
#include "resource.h"
#include "atltest.h"
Include dependency graph for CImage.cpp:

Go to the source code of this file.

Typedefs

typedef Gdiplus::GpStatus(WINAPISTARTUP) (ULONG_PTR *, const Gdiplus::GdiplusStartupInput *, Gdiplus::GdiplusStartupOutput *)
 
typedef void(WINAPISHUTDOWN) (ULONG_PTR)
 
typedef Gdiplus::GpStatus(WINGDIPAPICREATEBITMAPFROMFILE) (GDIPCONST WCHAR *, Gdiplus::GpBitmap **)
 
typedef Gdiplus::GpStatus(WINGDIPAPIGETPIXELFORMAT) (Gdiplus::GpImage *image, Gdiplus::PixelFormat *format)
 
typedef Gdiplus::GpStatus(WINGDIPAPIDISPOSEIMAGE) (Gdiplus::GpImage *)
 

Functions

TCHARfile_name (const TCHAR *file)
 
static void write_bitmap (HINSTANCE hInst, int id, TCHAR *file)
 
template<typename TYPE >
TYPE AddrOf (const char *name)
 
static void init_gdip ()
 
static void determine_file_bpp (TCHAR *tfile, Gdiplus::PixelFormat expect_pf)
 
 START_TEST (CImage)
 

Variables

const TCHARszFiles []
 
static TCHAR szTempPath [MAX_PATH]
 
static HINSTANCE hinstGdiPlus
 
static ULONG_PTR gdiplusToken
 
static STARTUP Startup
 
static SHUTDOWN Shutdown
 
static CREATEBITMAPFROMFILE CreateBitmapFromFile
 
static GETPIXELFORMAT GetImagePixelFormat
 
static DISPOSEIMAGE DisposeImage
 

Typedef Documentation

◆ CREATEBITMAPFROMFILE

typedef Gdiplus::GpStatus(WINGDIPAPI * CREATEBITMAPFROMFILE) (GDIPCONST WCHAR *, Gdiplus::GpBitmap **)

Definition at line 74 of file CImage.cpp.

◆ DISPOSEIMAGE

typedef Gdiplus::GpStatus(WINGDIPAPI * DISPOSEIMAGE) (Gdiplus::GpImage *)

Definition at line 76 of file CImage.cpp.

◆ GETPIXELFORMAT

Definition at line 75 of file CImage.cpp.

◆ SHUTDOWN

typedef void(WINAPI * SHUTDOWN) (ULONG_PTR)

Definition at line 73 of file CImage.cpp.

◆ STARTUP

typedef Gdiplus::GpStatus(WINAPI * STARTUP) (ULONG_PTR *, const Gdiplus::GdiplusStartupInput *, Gdiplus::GdiplusStartupOutput *)

Definition at line 72 of file CImage.cpp.

Function Documentation

◆ AddrOf()

template<typename TYPE >
TYPE AddrOf ( const char name)

Definition at line 88 of file CImage.cpp.

89 {
91  return reinterpret_cast<TYPE>(proc);
92 }
static HANDLE proc()
Definition: pdb.c:32
Definition: name.c:38
#define GetProcAddress(x, y)
Definition: compat.h:418
static HINSTANCE hinstGdiPlus
Definition: CImage.cpp:78
int(* FARPROC)()
Definition: compat.h:28

◆ determine_file_bpp()

static void determine_file_bpp ( TCHAR tfile,
Gdiplus::PixelFormat  expect_pf 
)
static

Definition at line 105 of file CImage.cpp.

106 {
107  using namespace Gdiplus;
108  GpBitmap *pBitmap = NULL;
109 
110 #ifdef UNICODE
111  WCHAR* file = tfile;
112 #else
114  ::MultiByteToWideChar(CP_ACP, 0, tfile, -1, file, MAX_PATH);
115 #endif
116 
117  if (Startup == NULL)
118  init_gdip();
119 
120  Gdiplus::GdiplusStartupInput gdiplusStartupInput;
121  Startup(&gdiplusToken, &gdiplusStartupInput, NULL);
122 
123 
125  ok(status == Gdiplus::Ok, "Expected status to be %i, was: %i\n", (int)Gdiplus::Ok, (int)status);
126  ok(pBitmap != NULL, "Expected a valid bitmap\n");
127  if (pBitmap)
128  {
129  PixelFormat pf;
130  GetImagePixelFormat(pBitmap, &pf);
131  ok(pf == expect_pf, "Expected PixelFormat to be 0x%x, was: 0x%x\n", (int)expect_pf, (int)pf);
132 
133  DisposeImage(pBitmap);
134  }
136 }
Status GpStatus
#define CP_ACP
Definition: compat.h:99
static STARTUP Startup
Definition: CImage.cpp:81
smooth NULL
Definition: ftsmooth.c:416
static CREATEBITMAPFROMFILE CreateBitmapFromFile
Definition: CImage.cpp:83
static SHUTDOWN Shutdown
Definition: CImage.cpp:82
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DISPOSEIMAGE DisposeImage
Definition: CImage.cpp:85
#define MAX_PATH
Definition: compat.h:26
static ULONG_PTR gdiplusToken
Definition: CImage.cpp:79
INT PixelFormat
#define ok(value,...)
Definition: atltest.h:57
#define MultiByteToWideChar
Definition: compat.h:100
static void init_gdip()
Definition: CImage.cpp:94
static GETPIXELFORMAT GetImagePixelFormat
Definition: CImage.cpp:84
Definition: fci.c:126
Definition: ps.c:97

Referenced by START_TEST().

◆ file_name()

TCHAR* file_name ( const TCHAR file)

Definition at line 26 of file CImage.cpp.

27 {
28  static TCHAR buffer[MAX_PATH];
30  lstrcat(buffer, TEXT("\\"));
32  return buffer;
33 }
GLuint buffer
Definition: glext.h:5915
static TCHAR szTempPath[MAX_PATH]
Definition: CImage.cpp:25
char TCHAR
Definition: xmlstorage.h:189
#define MAX_PATH
Definition: compat.h:26
#define TEXT(s)
Definition: k32.h:26
#define lstrcpy
Definition: winbase.h:3708
#define lstrcat
Definition: winbase.h:3705
Definition: fci.c:126

Referenced by START_TEST().

◆ init_gdip()

static void init_gdip ( )
static

Definition at line 94 of file CImage.cpp.

95 {
96  hinstGdiPlus = ::LoadLibraryA("gdiplus.dll");
97  Startup = AddrOf<STARTUP>("GdiplusStartup");
98  Shutdown = AddrOf<SHUTDOWN>("GdiplusShutdown");
99  CreateBitmapFromFile = AddrOf<CREATEBITMAPFROMFILE>("GdipCreateBitmapFromFile");
100  GetImagePixelFormat = AddrOf<GETPIXELFORMAT>("GdipGetImagePixelFormat");
101  DisposeImage = AddrOf<DISPOSEIMAGE>("GdipDisposeImage");
102 }
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static STARTUP Startup
Definition: CImage.cpp:81
static CREATEBITMAPFROMFILE CreateBitmapFromFile
Definition: CImage.cpp:83
static SHUTDOWN Shutdown
Definition: CImage.cpp:82
static DISPOSEIMAGE DisposeImage
Definition: CImage.cpp:85
static HINSTANCE hinstGdiPlus
Definition: CImage.cpp:78
static GETPIXELFORMAT GetImagePixelFormat
Definition: CImage.cpp:84

Referenced by determine_file_bpp(), and START_TEST().

◆ START_TEST()

START_TEST ( CImage  )

Definition at line 139 of file CImage.cpp.

140 {
141  HRESULT hr;
142  TCHAR* file;
143  BOOL bOK;
144  int width, height, bpp;
145  size_t n;
146  CImage image1, image2;
147  COLORREF color;
148  HDC hDC;
149 
150 #if 0
151  width = image1.GetWidth();
152  height = image1.GetHeight();
153  bpp = image1.GetBPP();
154 #endif
155 
158 
159  image1.LoadFromResource(hInst, IDB_ANT);
160  ok(!image1.IsNull(), "Expected image1 is not null\n");
161 
162  width = image1.GetWidth();
163  ok(width == 48, "Expected width to be 48, was: %d\n", width);
164  height = image1.GetHeight();
165  ok(height == 48, "Expected height to be 48, was: %d\n", height);
166  bpp = image1.GetBPP();
167  ok(bpp == 8, "Expected bpp to be 8, was: %d\n", bpp);
168 
169 
171  ok(!image2.IsNull(), "Expected image2 is not null\n");
172  image2.SetTransparentColor(RGB(255, 255, 255));
173 
174  width = image2.GetWidth();
175  ok(width == 32, "Expected width to be 32, was: %d\n", width);
176  height = image2.GetHeight();
177  ok(height == 32, "Expected height to be 32, was: %d\n", height);
178  bpp = image2.GetBPP();
179  ok(bpp == 8, "Expected bpp to be 8, was: %d\n", bpp);
180 
181  color = image1.GetPixel(5, 5);
182  ok(color == RGB(166, 202, 240), "Expected color to be 166, 202, 240; was: %i, %i, %i\n", GetRValue(color), GetGValue(color), GetBValue(color));
183 
184  hDC = image1.GetDC();
185  bOK = image2.Draw(hDC, 0, 0);
186  image1.ReleaseDC();
187  ok(bOK != FALSE, "Expected bDraw to be TRUE, was: %d\n", bOK);
188  image2.Destroy();
189 
190  color = image1.GetPixel(5, 5);
191  ok(color == RGB(255, 0,0), "Expected color to be 255, 0, 0; was: %i, %i, %i\n", GetRValue(color), GetGValue(color), GetBValue(color));
192 
193  file = file_name(TEXT("ant.bmp"));
195 
196  init_gdip();
197 
199 
200  hr = image2.Load(file);
201  ok(hr == S_OK, "Expected hr to be S_OK, was: %08lx\n", hr);
202  ok(!image2.IsNull(), "Expected image1 is not null\n");
203  bOK = DeleteFile(file);
204  ok(bOK, "Expected bOK to be TRUE, was: %d\n", bOK);
205 
206  width = image2.GetWidth();
207  ok(width == 48, "Expected width to be 48, was: %d\n", width);
208  height = image2.GetHeight();
209  ok(height == 48, "Expected height to be 48, was: %d\n", height);
210  bpp = image2.GetBPP();
211  ok(bpp == 8, "Expected bpp to be 8, was: %d\n", bpp);
212 
213  for (n = 0; n < _countof(szFiles); ++n)
214  {
215  file = file_name(szFiles[n]);
216  image2.Destroy();
217 
218  if (n == 0)
219  hr = image1.Save(file, Gdiplus::ImageFormatPNG);
220  else
221  hr = image1.Save(file);
222  ok(hr == S_OK, "Expected hr to be S_OK, was: %08lx (for %i)\n", hr, n);
223 
224  bOK = (GetFileAttributes(file) != 0xFFFFFFFF);
225  ok(bOK, "Expected bOK to be TRUE, was: %d (for %i)\n", bOK, n);
226 
227  hr = image2.Load(file);
228  ok(hr == S_OK, "Expected hr to be S_OK, was: %08lx (for %i)\n", hr, n);
229 
230  width = image2.GetWidth();
231  ok(width == 48, "Expected width to be 48, was: %d (for %i)\n", width, n);
232  height = image2.GetHeight();
233  ok(height == 48, "Expected height to be 48, was: %d (for %i)\n", height, n);
234  bpp = image2.GetBPP();
235  if (n == 3)
236  {
237  ok(bpp == 24, "Expected bpp to be 24, was: %d (for %i)\n", bpp, n);
239  }
240  else
241  {
242  ok(bpp == 8, "Expected bpp to be 8, was: %d (for %i)\n", bpp, n);
244  }
245  color = image1.GetPixel(5, 5);
246  ok(color == RGB(255, 0,0), "Expected color to be 255, 0, 0; was: %i, %i, %i (for %i)\n", GetRValue(color), GetGValue(color), GetBValue(color), n);
247 
248  bOK = DeleteFile(file);
249  ok(bOK, "Expected bOK to be TRUE, was: %d (for %i)\n", bOK, n);
250  }
251 
253  CSimpleArray<GUID> aguidFileTypes;
254 #ifdef UNICODE
255  CHAR szBuff[512];
256  const WCHAR *psz;
257 #else
258  const CHAR *psz;
259 #endif
260 
261  CSimpleString strImporters(mgr);
262  aguidFileTypes.RemoveAll();
263  hr = CImage::GetImporterFilterString(strImporters,
264  aguidFileTypes,
265  TEXT("All Image Files"), 0);
266  ok(hr == S_OK, "Expected hr to be S_OK, was: %ld\n", hr);
267  ok(aguidFileTypes.GetSize() == 9, "Expected aguidFileTypes.GetSize() to be 8, was %d.", aguidFileTypes.GetSize());
268  ok(IsEqualGUID(aguidFileTypes[0], GUID_NULL), "Expected aguidFileTypes[0] to be GUID_NULL.\n");
269  ok(IsEqualGUID(aguidFileTypes[1], Gdiplus::ImageFormatBMP), "Expected aguidFileTypes[1] to be Gdiplus::ImageFormatBMP.\n");
270  ok(IsEqualGUID(aguidFileTypes[2], Gdiplus::ImageFormatJPEG), "Expected aguidFileTypes[2] to be Gdiplus::ImageFormatJPEG.\n");
271  ok(IsEqualGUID(aguidFileTypes[3], Gdiplus::ImageFormatGIF), "Expected aguidFileTypes[3] to be Gdiplus::ImageFormatGIF.\n");
272  ok(IsEqualGUID(aguidFileTypes[4], Gdiplus::ImageFormatEMF), "Expected aguidFileTypes[4] to be Gdiplus::ImageFormatEMF.\n");
273  ok(IsEqualGUID(aguidFileTypes[5], Gdiplus::ImageFormatWMF), "Expected aguidFileTypes[5] to be Gdiplus::ImageFormatWMF.\n");
274  ok(IsEqualGUID(aguidFileTypes[6], Gdiplus::ImageFormatTIFF), "Expected aguidFileTypes[6] to be Gdiplus::ImageFormatTIFF.\n");
275  ok(IsEqualGUID(aguidFileTypes[7], Gdiplus::ImageFormatPNG), "Expected aguidFileTypes[7] to be Gdiplus::ImageFormatPNG.\n");
276  ok(IsEqualGUID(aguidFileTypes[8], Gdiplus::ImageFormatIcon), "Expected aguidFileTypes[8] to be Gdiplus::ImageFormatIcon.\n");
277 
278  psz = strImporters.GetString();
279 #ifdef UNICODE
280  WideCharToMultiByte(CP_ACP, 0, psz, -1, szBuff, 512, NULL, NULL);
281  ok(lstrcmpA(szBuff, "All Image Files|*.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.EMF;*.WMF;*.TIF;*.TIFF;*.PNG;*.ICO|BMP (*.BMP;*.DIB;*.RLE)|*.BMP;*.DIB;*.RLE|JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|GIF (*.GIF)|*.GIF|EMF (*.EMF)|*.EMF|WMF (*.WMF)|*.WMF|TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF|PNG (*.PNG)|*.PNG|ICO (*.ICO)|*.ICO||") == 0,
282  "The importer filter string is bad, was: %s\n", szBuff);
283 #else
284  ok(lstrcmpA(psz, "All Image Files|*.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.EMF;*.WMF;*.TIF;*.TIFF;*.PNG;*.ICO|BMP (*.BMP;*.DIB;*.RLE)|*.BMP;*.DIB;*.RLE|JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|GIF (*.GIF)|*.GIF|EMF (*.EMF)|*.EMF|WMF (*.WMF)|*.WMF|TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF|PNG (*.PNG)|*.PNG|ICO (*.ICO)|*.ICO||") == 0,
285  "The importer filter string is bad, was: %s\n", psz);
286 #endif
287 
288  CSimpleString strExporters(mgr);
289  aguidFileTypes.RemoveAll();
290  hr = CImage::GetExporterFilterString(strExporters,
291  aguidFileTypes,
292  TEXT("All Image Files"), 0);
293  ok(hr == S_OK, "Expected hr to be S_OK, was: %ld\n", hr);
294  ok(aguidFileTypes.GetSize() == 9, "Expected aguidFileTypes.GetSize() to be 8, was %d.", aguidFileTypes.GetSize());
295  ok(IsEqualGUID(aguidFileTypes[0], GUID_NULL), "Expected aguidFileTypes[0] to be GUID_NULL.\n");
296  ok(IsEqualGUID(aguidFileTypes[1], Gdiplus::ImageFormatBMP), "Expected aguidFileTypes[1] to be Gdiplus::ImageFormatBMP.\n");
297  ok(IsEqualGUID(aguidFileTypes[2], Gdiplus::ImageFormatJPEG), "Expected aguidFileTypes[2] to be Gdiplus::ImageFormatJPEG.\n");
298  ok(IsEqualGUID(aguidFileTypes[3], Gdiplus::ImageFormatGIF), "Expected aguidFileTypes[3] to be Gdiplus::ImageFormatGIF.\n");
299  ok(IsEqualGUID(aguidFileTypes[4], Gdiplus::ImageFormatEMF), "Expected aguidFileTypes[4] to be Gdiplus::ImageFormatEMF.\n");
300  ok(IsEqualGUID(aguidFileTypes[5], Gdiplus::ImageFormatWMF), "Expected aguidFileTypes[5] to be Gdiplus::ImageFormatWMF.\n");
301  ok(IsEqualGUID(aguidFileTypes[6], Gdiplus::ImageFormatTIFF), "Expected aguidFileTypes[6] to be Gdiplus::ImageFormatTIFF.\n");
302  ok(IsEqualGUID(aguidFileTypes[7], Gdiplus::ImageFormatPNG), "Expected aguidFileTypes[7] to be Gdiplus::ImageFormatPNG.\n");
303  ok(IsEqualGUID(aguidFileTypes[8], Gdiplus::ImageFormatIcon), "Expected aguidFileTypes[8] to be Gdiplus::ImageFormatIcon.\n");
304 
305  psz = strExporters.GetString();
306 #ifdef UNICODE
307  WideCharToMultiByte(CP_ACP, 0, psz, -1, szBuff, 512, NULL, NULL);
308  ok(lstrcmpA(szBuff, "All Image Files|*.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.EMF;*.WMF;*.TIF;*.TIFF;*.PNG;*.ICO|BMP (*.BMP;*.DIB;*.RLE)|*.BMP;*.DIB;*.RLE|JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|GIF (*.GIF)|*.GIF|EMF (*.EMF)|*.EMF|WMF (*.WMF)|*.WMF|TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF|PNG (*.PNG)|*.PNG|ICO (*.ICO)|*.ICO||") == 0,
309  "The exporter filter string is bad, was: %s\n", szBuff);
310 #else
311  ok(lstrcmpA(psz, "All Image Files|*.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.EMF;*.WMF;*.TIF;*.TIFF;*.PNG;*.ICO|BMP (*.BMP;*.DIB;*.RLE)|*.BMP;*.DIB;*.RLE|JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|GIF (*.GIF)|*.GIF|EMF (*.EMF)|*.EMF|WMF (*.WMF)|*.WMF|TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF|PNG (*.PNG)|*.PNG|ICO (*.ICO)|*.ICO||") == 0,
312  "The exporter filter string is bad, was: %s\n", psz);
313 #endif
314 }
TCHAR * file_name(const TCHAR *file)
Definition: CImage.cpp:26
GLint GLint GLsizei width
Definition: gl.h:1546
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
#define _countof(array)
Definition: fontsub.cpp:30
char CHAR
Definition: xmlstorage.h:175
static HDC
Definition: imagelist.c:92
#define GetRValue(rgb)
Definition: wingdi.h:2934
GLdouble n
Definition: glext.h:7729
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
VOID WINAPI GetInstance(LPSPropValue, LPSPropValue, ULONG)
const TCHAR * szFiles[]
Definition: CImage.cpp:17
void LoadFromResource(HINSTANCE hInstance, LPCTSTR pszResourceName)
Definition: atlimage.h:439
HRESULT Load(LPCTSTR pszFileName)
Definition: atlimage.h:377
#define DeleteFile
Definition: winbase.h:3598
static void determine_file_bpp(TCHAR *tfile, Gdiplus::PixelFormat expect_pf)
Definition: CImage.cpp:105
#define IDB_ANT
Definition: resource.h:5
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
#define GetGValue(rgb)
Definition: wingdi.h:2935
void ReleaseDC() const
Definition: atlimage.h:106
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint color
Definition: glext.h:6243
smooth NULL
Definition: ftsmooth.c:416
#define GetTempPath
Definition: winbase.h:3684
#define PixelFormat8bppIndexed
static TCHAR szTempPath[MAX_PATH]
Definition: CImage.cpp:25
bool IsNull() const
Definition: atlimage.h:372
char TCHAR
Definition: xmlstorage.h:189
COLORREF SetTransparentColor(COLORREF rgbTransparent)
Definition: atlimage.h:623
HRESULT Save(IStream *pStream, GUID *guidFileType) const
Definition: atlimage.h:526
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static void write_bitmap(HINSTANCE hInst, int id, TCHAR *file)
Definition: CImage.cpp:35
DWORD COLORREF
Definition: windef.h:300
#define RGB(r, g, b)
Definition: wingdi.h:2939
#define MAX_PATH
Definition: compat.h:26
const char file[]
Definition: icontest.c:11
int GetWidth() const
Definition: atlimage.h:354
#define GUID_NULL
Definition: ks.h:106
#define GetFileAttributes
Definition: winbase.h:3649
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
HDC GetDC() const
Definition: atlimage.h:96
static HDC hDC
Definition: 3dtext.c:33
#define S_OK
Definition: intsafe.h:59
HINSTANCE hInst
Definition: dxdiag.c:13
#define TEXT(s)
Definition: k32.h:26
#define GetModuleHandle
Definition: winbase.h:3661
#define ok(value,...)
Definition: atltest.h:57
#define PixelFormat24bppRGB
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static void init_gdip()
Definition: CImage.cpp:94
int GetBPP() const
Definition: atlimage.h:282
COLORREF GetPixel(int x, int y) const
Definition: atlimage.h:332
#define GetBValue(rgb)
Definition: wingdi.h:2936
int GetHeight() const
Definition: atlimage.h:297
DWORD bpp
Definition: surface.c:181
#define IDB_CROSS
Definition: resource.h:6
void Destroy()
Definition: atlimage.h:208
Definition: fci.c:126

◆ write_bitmap()

static void write_bitmap ( HINSTANCE  hInst,
int  id,
TCHAR file 
)
static

Definition at line 35 of file CImage.cpp.

36 {
37  HRSRC rsrc;
38 
40  ok(rsrc != NULL, "Expected to find an image resource\n");
41  if (rsrc)
42  {
43  void *rsrc_data;
44  HANDLE hfile;
45  BOOL ret;
46  HGLOBAL glob = LoadResource(hInst, rsrc);
47  DWORD rsrc_size = SizeofResource(hInst, rsrc);
48 
49  rsrc_data = LockResource(glob);
50 
52  ok(hfile != INVALID_HANDLE_VALUE, "Unable to open temp file: %lu\n", GetLastError());
53  if (hfile != INVALID_HANDLE_VALUE)
54  {
55  BITMAPFILEHEADER bfh = { 0 };
56  DWORD dwWritten;
57 
58  bfh.bfType = 'MB';
59  bfh.bfSize = rsrc_size + sizeof(BITMAPFILEHEADER);
60  bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
61  bfh.bfReserved1 = bfh.bfReserved2 = 0;
62  ret = WriteFile(hfile, &bfh, sizeof(bfh), &dwWritten, NULL);
63  ok(ret, "Unable to write temp file: %lu\n", GetLastError());
64  ret = WriteFile(hfile, rsrc_data, rsrc_size, &dwWritten, NULL);
65  ok(ret, "Unable to write temp file: %lu\n", GetLastError());
66  CloseHandle(hfile);
67  }
68  UnlockResource(rsrc_data);
69  }
70 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define CloseHandle
Definition: compat.h:406
#define FindResource
Definition: winbase.h:3627
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
#define UnlockResource(h)
Definition: winbase.h:3206
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define CREATE_ALWAYS
Definition: disk.h:72
HINSTANCE hInst
Definition: dxdiag.c:13
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
struct tagBITMAPFILEHEADER BITMAPFILEHEADER
#define ok(value,...)
Definition: atltest.h:57
char ** glob(const char *v)
Definition: fake.c:36
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
#define RT_BITMAP
Definition: pedump.c:364
Definition: fci.c:126

Referenced by START_TEST().

Variable Documentation

◆ CreateBitmapFromFile

CREATEBITMAPFROMFILE CreateBitmapFromFile
static

Definition at line 83 of file CImage.cpp.

Referenced by determine_file_bpp(), and init_gdip().

◆ DisposeImage

DISPOSEIMAGE DisposeImage
static

Definition at line 85 of file CImage.cpp.

Referenced by determine_file_bpp(), and init_gdip().

◆ gdiplusToken

ULONG_PTR gdiplusToken
static

Definition at line 79 of file CImage.cpp.

Referenced by determine_file_bpp(), ImageView_CreateWindow(), START_TEST(), and test_startup().

◆ GetImagePixelFormat

GETPIXELFORMAT GetImagePixelFormat
static

Definition at line 84 of file CImage.cpp.

Referenced by determine_file_bpp(), and init_gdip().

◆ hinstGdiPlus

HINSTANCE hinstGdiPlus
static

Definition at line 78 of file CImage.cpp.

Referenced by AddrOf(), and init_gdip().

◆ Shutdown

SHUTDOWN Shutdown
static

Definition at line 82 of file CImage.cpp.

Referenced by determine_file_bpp(), and init_gdip().

◆ Startup

STARTUP Startup
static

Definition at line 81 of file CImage.cpp.

Referenced by determine_file_bpp(), and init_gdip().

◆ szFiles

const TCHAR* szFiles[]
Initial value:
= {
TEXT("ant.png"),
TEXT("ant.tif"),
TEXT("ant.gif"),
TEXT("ant.jpg"),
TEXT("ant.bmp"),
}
#define TEXT(s)
Definition: k32.h:26

Definition at line 17 of file CImage.cpp.

Referenced by parse_file_list(), and START_TEST().

◆ szTempPath

TCHAR szTempPath[MAX_PATH]
static