ReactOS  0.4.13-dev-259-g5ca9c9c
CImage.cpp File Reference
#include <atlimage.h>
#include "resource.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
Include dependency graph for CImage.cpp:

Go to the source code of this file.

Macros

#define ok(value, ...)   ok_func(__FILE__, __LINE__, value, __VA_ARGS__)
 
#define START_TEST(x)   int main(void)
 

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

void ok_func (const char *file, int line, BOOL value, const char *fmt,...)
 
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

int g_tests_executed = 0
 
int g_tests_failed = 0
 
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
 

Macro Definition Documentation

◆ ok

#define ok (   value,
  ... 
)    ok_func(__FILE__, __LINE__, value, __VA_ARGS__)

Definition at line 33 of file CImage.cpp.

◆ START_TEST

#define START_TEST (   x)    int main(void)

Definition at line 34 of file CImage.cpp.

Typedef Documentation

◆ CREATEBITMAPFROMFILE

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

Definition at line 94 of file CImage.cpp.

◆ DISPOSEIMAGE

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

Definition at line 96 of file CImage.cpp.

◆ GETPIXELFORMAT

Definition at line 95 of file CImage.cpp.

◆ SHUTDOWN

typedef void(WINAPI * SHUTDOWN) (ULONG_PTR)

Definition at line 93 of file CImage.cpp.

◆ STARTUP

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

Definition at line 92 of file CImage.cpp.

Function Documentation

◆ AddrOf()

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

Definition at line 108 of file CImage.cpp.

109 {
111  return reinterpret_cast<TYPE>(proc);
112 }
static HANDLE proc()
Definition: pdb.c:32
Definition: name.c:36
#define GetProcAddress(x, y)
Definition: compat.h:410
static HINSTANCE hinstGdiPlus
Definition: CImage.cpp:98
int(* FARPROC)()
Definition: compat.h:28

◆ determine_file_bpp()

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

Definition at line 125 of file CImage.cpp.

126 {
127  using namespace Gdiplus;
128  GpBitmap *pBitmap = NULL;
129 
130 #ifdef UNICODE
131  WCHAR* file = tfile;
132 #else
134  ::MultiByteToWideChar(CP_ACP, 0, tfile, -1, file, MAX_PATH);
135 #endif
136 
137  if (Startup == NULL)
138  init_gdip();
139 
140  Gdiplus::GdiplusStartupInput gdiplusStartupInput;
141  Startup(&gdiplusToken, &gdiplusStartupInput, NULL);
142 
143 
145  ok(status == Gdiplus::Ok, "Expected status to be %i, was: %i\n", (int)Gdiplus::Ok, (int)status);
146  ok(pBitmap != NULL, "Expected a valid bitmap\n");
147  if (pBitmap)
148  {
149  PixelFormat pf;
150  GetImagePixelFormat(pBitmap, &pf);
151  ok(pf == expect_pf, "Expected PixelFormat to be 0x%x, was: 0x%x\n", (int)expect_pf, (int)pf);
152 
153  DisposeImage(pBitmap);
154  }
156 }
Status GpStatus
#define CP_ACP
Definition: compat.h:99
static STARTUP Startup
Definition: CImage.cpp:101
smooth NULL
Definition: ftsmooth.c:416
static CREATEBITMAPFROMFILE CreateBitmapFromFile
Definition: CImage.cpp:103
static SHUTDOWN Shutdown
Definition: CImage.cpp:102
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DISPOSEIMAGE DisposeImage
Definition: CImage.cpp:105
#define MAX_PATH
Definition: compat.h:26
static ULONG_PTR gdiplusToken
Definition: CImage.cpp:99
INT PixelFormat
#define MultiByteToWideChar
Definition: compat.h:100
static void init_gdip()
Definition: CImage.cpp:114
#define ok(value,...)
Definition: CImage.cpp:33
static GETPIXELFORMAT GetImagePixelFormat
Definition: CImage.cpp:104
Definition: fci.c:126
Definition: ps.c:97

Referenced by START_TEST().

◆ file_name()

TCHAR* file_name ( const TCHAR file)

Definition at line 46 of file CImage.cpp.

47 {
48  static TCHAR buffer[MAX_PATH];
50  lstrcat(buffer, TEXT("\\"));
52  return buffer;
53 }
GLuint buffer
Definition: glext.h:5915
static TCHAR szTempPath[MAX_PATH]
Definition: CImage.cpp:45
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:3688
#define lstrcat
Definition: winbase.h:3685
Definition: fci.c:126

Referenced by START_TEST().

◆ init_gdip()

static void init_gdip ( )
static

Definition at line 114 of file CImage.cpp.

115 {
116  hinstGdiPlus = ::LoadLibraryA("gdiplus.dll");
117  Startup = AddrOf<STARTUP>("GdiplusStartup");
118  Shutdown = AddrOf<SHUTDOWN>("GdiplusShutdown");
119  CreateBitmapFromFile = AddrOf<CREATEBITMAPFROMFILE>("GdipCreateBitmapFromFile");
120  GetImagePixelFormat = AddrOf<GETPIXELFORMAT>("GdipGetImagePixelFormat");
121  DisposeImage = AddrOf<DISPOSEIMAGE>("GdipDisposeImage");
122 }
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static STARTUP Startup
Definition: CImage.cpp:101
static CREATEBITMAPFROMFILE CreateBitmapFromFile
Definition: CImage.cpp:103
static SHUTDOWN Shutdown
Definition: CImage.cpp:102
static DISPOSEIMAGE DisposeImage
Definition: CImage.cpp:105
static HINSTANCE hinstGdiPlus
Definition: CImage.cpp:98
static GETPIXELFORMAT GetImagePixelFormat
Definition: CImage.cpp:104

Referenced by determine_file_bpp(), and START_TEST().

◆ ok_func()

void ok_func ( const char file,
int  line,
BOOL  value,
const char fmt,
  ... 
)

Definition at line 19 of file CImage.cpp.

20  {
21  va_list va;
22  va_start(va, fmt);
23  if (!value)
24  {
25  printf("%s (%d): ", file, line);
26  vprintf(fmt, va);
28  }
30  va_end(va);
31  }
#define va_end(ap)
Definition: acmsvcex.h:90
Definition: parser.c:48
char * va_list
Definition: acmsvcex.h:78
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
int g_tests_executed
Definition: CImage.cpp:17
#define va_start(ap, A)
Definition: acmsvcex.h:91
int g_tests_failed
Definition: CImage.cpp:18
Definition: dsound.c:943
#define printf
Definition: config.h:203
Definition: fci.c:126

◆ START_TEST()

START_TEST ( CImage  )

Definition at line 159 of file CImage.cpp.

160 {
161  HRESULT hr;
162  TCHAR* file;
163  BOOL bOK;
164  int width, height, bpp;
165  size_t n;
166  CImage image1, image2;
167  COLORREF color;
168  HDC hDC;
169 
170 #if 0
171  width = image1.GetWidth();
172  height = image1.GetHeight();
173  bpp = image1.GetBPP();
174 #endif
175 
178 
179  image1.LoadFromResource(hInst, IDB_ANT);
180  ok(!image1.IsNull(), "Expected image1 is not null\n");
181 
182  width = image1.GetWidth();
183  ok(width == 48, "Expected width to be 48, was: %d\n", width);
184  height = image1.GetHeight();
185  ok(height == 48, "Expected height to be 48, was: %d\n", height);
186  bpp = image1.GetBPP();
187  ok(bpp == 8, "Expected bpp to be 8, was: %d\n", bpp);
188 
189 
191  ok(!image2.IsNull(), "Expected image2 is not null\n");
192  image2.SetTransparentColor(RGB(255, 255, 255));
193 
194  width = image2.GetWidth();
195  ok(width == 32, "Expected width to be 32, was: %d\n", width);
196  height = image2.GetHeight();
197  ok(height == 32, "Expected height to be 32, was: %d\n", height);
198  bpp = image2.GetBPP();
199  ok(bpp == 8, "Expected bpp to be 8, was: %d\n", bpp);
200 
201  color = image1.GetPixel(5, 5);
202  ok(color == RGB(166, 202, 240), "Expected color to be 166, 202, 240; was: %i, %i, %i\n", GetRValue(color), GetGValue(color), GetBValue(color));
203 
204  hDC = image1.GetDC();
205  bOK = image2.Draw(hDC, 0, 0);
206  image1.ReleaseDC();
207  ok(bOK != FALSE, "Expected bDraw to be TRUE, was: %d\n", bOK);
208  image2.Destroy();
209 
210  color = image1.GetPixel(5, 5);
211  ok(color == RGB(255, 0,0), "Expected color to be 255, 0, 0; was: %i, %i, %i\n", GetRValue(color), GetGValue(color), GetBValue(color));
212 
213  file = file_name(TEXT("ant.bmp"));
215 
216  init_gdip();
217 
219 
220  hr = image2.Load(file);
221  ok(hr == S_OK, "Expected hr to be S_OK, was: %08lx\n", hr);
222  ok(!image2.IsNull(), "Expected image1 is not null\n");
223  bOK = DeleteFile(file);
224  ok(bOK, "Expected bOK to be TRUE, was: %d\n", bOK);
225 
226  width = image2.GetWidth();
227  ok(width == 48, "Expected width to be 48, was: %d\n", width);
228  height = image2.GetHeight();
229  ok(height == 48, "Expected height to be 48, was: %d\n", height);
230  bpp = image2.GetBPP();
231  ok(bpp == 8, "Expected bpp to be 8, was: %d\n", bpp);
232 
233  for (n = 0; n < _countof(szFiles); ++n)
234  {
235  file = file_name(szFiles[n]);
236  image2.Destroy();
237 
238  if (n == 0)
239  hr = image1.Save(file, Gdiplus::ImageFormatPNG);
240  else
241  hr = image1.Save(file);
242  ok(hr == S_OK, "Expected hr to be S_OK, was: %08lx (for %i)\n", hr, n);
243 
244  bOK = (GetFileAttributes(file) != 0xFFFFFFFF);
245  ok(bOK, "Expected bOK to be TRUE, was: %d (for %i)\n", bOK, n);
246 
247  hr = image2.Load(file);
248  ok(hr == S_OK, "Expected hr to be S_OK, was: %08lx (for %i)\n", hr, n);
249 
250  width = image2.GetWidth();
251  ok(width == 48, "Expected width to be 48, was: %d (for %i)\n", width, n);
252  height = image2.GetHeight();
253  ok(height == 48, "Expected height to be 48, was: %d (for %i)\n", height, n);
254  bpp = image2.GetBPP();
255  if (n == 3)
256  {
257  ok(bpp == 24, "Expected bpp to be 24, was: %d (for %i)\n", bpp, n);
259  }
260  else
261  {
262  ok(bpp == 8, "Expected bpp to be 8, was: %d (for %i)\n", bpp, n);
264  }
265  color = image1.GetPixel(5, 5);
266  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);
267 
268  bOK = DeleteFile(file);
269  ok(bOK, "Expected bOK to be TRUE, was: %d (for %i)\n", bOK, n);
270  }
271 
273  CSimpleArray<GUID> aguidFileTypes;
274 #ifdef UNICODE
275  CHAR szBuff[512];
276  const WCHAR *psz;
277 #else
278  const CHAR *psz;
279 #endif
280 
281  CSimpleString strImporters(mgr);
282  aguidFileTypes.RemoveAll();
283  hr = CImage::GetImporterFilterString(strImporters,
284  aguidFileTypes,
285  TEXT("All Image Files"), 0);
286  ok(hr == S_OK, "Expected hr to be S_OK, was: %ld\n", hr);
287  ok(aguidFileTypes.GetSize() == 9, "Expected aguidFileTypes.GetSize() to be 8, was %d.", aguidFileTypes.GetSize());
288  ok(IsEqualGUID(aguidFileTypes[0], GUID_NULL), "Expected aguidFileTypes[0] to be GUID_NULL.\n");
289  ok(IsEqualGUID(aguidFileTypes[1], Gdiplus::ImageFormatBMP), "Expected aguidFileTypes[1] to be Gdiplus::ImageFormatBMP.\n");
290  ok(IsEqualGUID(aguidFileTypes[2], Gdiplus::ImageFormatJPEG), "Expected aguidFileTypes[2] to be Gdiplus::ImageFormatJPEG.\n");
291  ok(IsEqualGUID(aguidFileTypes[3], Gdiplus::ImageFormatGIF), "Expected aguidFileTypes[3] to be Gdiplus::ImageFormatGIF.\n");
292  ok(IsEqualGUID(aguidFileTypes[4], Gdiplus::ImageFormatEMF), "Expected aguidFileTypes[4] to be Gdiplus::ImageFormatEMF.\n");
293  ok(IsEqualGUID(aguidFileTypes[5], Gdiplus::ImageFormatWMF), "Expected aguidFileTypes[5] to be Gdiplus::ImageFormatWMF.\n");
294  ok(IsEqualGUID(aguidFileTypes[6], Gdiplus::ImageFormatTIFF), "Expected aguidFileTypes[6] to be Gdiplus::ImageFormatTIFF.\n");
295  ok(IsEqualGUID(aguidFileTypes[7], Gdiplus::ImageFormatPNG), "Expected aguidFileTypes[7] to be Gdiplus::ImageFormatPNG.\n");
296  ok(IsEqualGUID(aguidFileTypes[8], Gdiplus::ImageFormatIcon), "Expected aguidFileTypes[8] to be Gdiplus::ImageFormatIcon.\n");
297 
298  psz = strImporters.GetString();
299 #ifdef UNICODE
300  WideCharToMultiByte(CP_ACP, 0, psz, -1, szBuff, 512, NULL, NULL);
301  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,
302  "The importer filter string is bad, was: %s\n", szBuff);
303 #else
304  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,
305  "The importer filter string is bad, was: %s\n", psz);
306 #endif
307 
308  CSimpleString strExporters(mgr);
309  aguidFileTypes.RemoveAll();
310  hr = CImage::GetExporterFilterString(strExporters,
311  aguidFileTypes,
312  TEXT("All Image Files"), 0);
313  ok(hr == S_OK, "Expected hr to be S_OK, was: %ld\n", hr);
314  ok(aguidFileTypes.GetSize() == 9, "Expected aguidFileTypes.GetSize() to be 8, was %d.", aguidFileTypes.GetSize());
315  ok(IsEqualGUID(aguidFileTypes[0], GUID_NULL), "Expected aguidFileTypes[0] to be GUID_NULL.\n");
316  ok(IsEqualGUID(aguidFileTypes[1], Gdiplus::ImageFormatBMP), "Expected aguidFileTypes[1] to be Gdiplus::ImageFormatBMP.\n");
317  ok(IsEqualGUID(aguidFileTypes[2], Gdiplus::ImageFormatJPEG), "Expected aguidFileTypes[2] to be Gdiplus::ImageFormatJPEG.\n");
318  ok(IsEqualGUID(aguidFileTypes[3], Gdiplus::ImageFormatGIF), "Expected aguidFileTypes[3] to be Gdiplus::ImageFormatGIF.\n");
319  ok(IsEqualGUID(aguidFileTypes[4], Gdiplus::ImageFormatEMF), "Expected aguidFileTypes[4] to be Gdiplus::ImageFormatEMF.\n");
320  ok(IsEqualGUID(aguidFileTypes[5], Gdiplus::ImageFormatWMF), "Expected aguidFileTypes[5] to be Gdiplus::ImageFormatWMF.\n");
321  ok(IsEqualGUID(aguidFileTypes[6], Gdiplus::ImageFormatTIFF), "Expected aguidFileTypes[6] to be Gdiplus::ImageFormatTIFF.\n");
322  ok(IsEqualGUID(aguidFileTypes[7], Gdiplus::ImageFormatPNG), "Expected aguidFileTypes[7] to be Gdiplus::ImageFormatPNG.\n");
323  ok(IsEqualGUID(aguidFileTypes[8], Gdiplus::ImageFormatIcon), "Expected aguidFileTypes[8] to be Gdiplus::ImageFormatIcon.\n");
324 
325  psz = strExporters.GetString();
326 #ifdef UNICODE
327  WideCharToMultiByte(CP_ACP, 0, psz, -1, szBuff, 512, NULL, NULL);
328  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,
329  "The exporter filter string is bad, was: %s\n", szBuff);
330 #else
331  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,
332  "The exporter filter string is bad, was: %s\n", psz);
333 #endif
334 
335 #ifndef HAVE_APITEST
336  printf("CImage: %i tests executed (0 marked as todo, %i failures), 0 skipped.\n", g_tests_executed, g_tests_failed);
337  return g_tests_failed;
338 #endif
339 }
TCHAR * file_name(const TCHAR *file)
Definition: CImage.cpp:46
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:2913
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:37
void LoadFromResource(HINSTANCE hInstance, LPCTSTR pszResourceName)
Definition: atlimage.h:439
HRESULT Load(LPCTSTR pszFileName)
Definition: atlimage.h:377
#define DeleteFile
Definition: winbase.h:3578
static void determine_file_bpp(TCHAR *tfile, Gdiplus::PixelFormat expect_pf)
Definition: CImage.cpp:125
#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:2914
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:3664
#define PixelFormat8bppIndexed
static TCHAR szTempPath[MAX_PATH]
Definition: CImage.cpp:45
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:55
DWORD COLORREF
Definition: windef.h:285
#define RGB(r, g, b)
Definition: wingdi.h:2918
#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:3629
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:3641
int g_tests_executed
Definition: CImage.cpp:17
#define PixelFormat24bppRGB
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
static void init_gdip()
Definition: CImage.cpp:114
int GetBPP() const
Definition: atlimage.h:282
COLORREF GetPixel(int x, int y) const
Definition: atlimage.h:332
int g_tests_failed
Definition: CImage.cpp:18
#define GetBValue(rgb)
Definition: wingdi.h:2915
int GetHeight() const
Definition: atlimage.h:297
#define ok(value,...)
Definition: CImage.cpp:33
DWORD bpp
Definition: surface.c:181
#define IDB_CROSS
Definition: resource.h:6
void Destroy()
Definition: atlimage.h:208
#define printf
Definition: config.h:203
Definition: fci.c:126

◆ write_bitmap()

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

Definition at line 55 of file CImage.cpp.

56 {
57  HRSRC rsrc;
58 
60  ok(rsrc != NULL, "Expected to find an image resource\n");
61  if (rsrc)
62  {
63  void *rsrc_data;
64  HANDLE hfile;
65  BOOL ret;
66  HGLOBAL glob = LoadResource(hInst, rsrc);
67  DWORD rsrc_size = SizeofResource(hInst, rsrc);
68 
69  rsrc_data = LockResource(glob);
70 
72  ok(hfile != INVALID_HANDLE_VALUE, "Unable to open temp file: %lu\n", GetLastError());
73  if (hfile != INVALID_HANDLE_VALUE)
74  {
75  BITMAPFILEHEADER bfh = { 0 };
76  DWORD dwWritten;
77 
78  bfh.bfType = 'MB';
79  bfh.bfSize = rsrc_size + sizeof(BITMAPFILEHEADER);
80  bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
81  bfh.bfReserved1 = bfh.bfReserved2 = 0;
82  ret = WriteFile(hfile, &bfh, sizeof(bfh), &dwWritten, NULL);
83  ok(ret, "Unable to write temp file: %lu\n", GetLastError());
84  ret = WriteFile(hfile, rsrc_data, rsrc_size, &dwWritten, NULL);
85  ok(ret, "Unable to write temp file: %lu\n", GetLastError());
86  CloseHandle(hfile);
87  }
88  UnlockResource(rsrc_data);
89  }
90 }
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:398
#define FindResource
Definition: winbase.h:3607
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
#define UnlockResource(h)
Definition: winbase.h:3189
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
char ** glob(const char *v)
Definition: fake.c:36
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
#define ok(value,...)
Definition: CImage.cpp:33
#define RT_BITMAP
Definition: pedump.c:364
Definition: fci.c:126

Referenced by START_TEST().

Variable Documentation

◆ CreateBitmapFromFile

CREATEBITMAPFROMFILE CreateBitmapFromFile
static

Definition at line 103 of file CImage.cpp.

Referenced by determine_file_bpp(), and init_gdip().

◆ DisposeImage

DISPOSEIMAGE DisposeImage
static

Definition at line 105 of file CImage.cpp.

Referenced by determine_file_bpp(), and init_gdip().

◆ g_tests_executed

int g_tests_executed = 0

Definition at line 17 of file CImage.cpp.

Referenced by ok_func(), and START_TEST().

◆ g_tests_failed

int g_tests_failed = 0

Definition at line 18 of file CImage.cpp.

Referenced by ok_func(), and START_TEST().

◆ gdiplusToken

ULONG_PTR gdiplusToken
static

Definition at line 99 of file CImage.cpp.

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

◆ GetImagePixelFormat

GETPIXELFORMAT GetImagePixelFormat
static

Definition at line 104 of file CImage.cpp.

Referenced by determine_file_bpp(), and init_gdip().

◆ hinstGdiPlus

HINSTANCE hinstGdiPlus
static

Definition at line 98 of file CImage.cpp.

Referenced by AddrOf(), and init_gdip().

◆ Shutdown

SHUTDOWN Shutdown
static

Definition at line 102 of file CImage.cpp.

Referenced by determine_file_bpp(), and init_gdip().

◆ Startup

STARTUP Startup
static

Definition at line 101 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 37 of file CImage.cpp.

Referenced by parse_file_list(), and START_TEST().

◆ szTempPath

TCHAR szTempPath[MAX_PATH]
static