1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory 4 * PURPOSE: Test for CImage and CImageDC 5 * PROGRAMMER: Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) 6 */ 7 8 #include <atlimage.h> 9 #include <strsafe.h> 10 #include "resource.h" 11 12 #ifdef HAVE_APITEST 13 #include <apitest.h> 14 #else 15 #include "atltest.h" 16 #endif 17 18 struct BITMAPINFOEX : BITMAPINFO 19 { 20 RGBQUAD bmiColorsExtra[256 - 1]; 21 }; 22 23 static void 24 Test_PixelAddress(INT iLine, const CImage &image1, const BITMAP &bm, INT x, INT y, BOOL bTopDown) 25 { 26 LPBYTE pb = (LPBYTE)bm.bmBits; 27 28 if (bTopDown) 29 pb += bm.bmWidthBytes * y; 30 else 31 pb += bm.bmWidthBytes * (bm.bmHeight - y - 1); 32 33 pb += (x * bm.bmBitsPixel) / 8; 34 35 LPCVOID addr = image1.GetPixelAddress(x, y); 36 ok(pb == addr, "Line %d: (%d, %d): %p vs %p\n", iLine, x, y, pb, addr); 37 } 38 39 static void 40 Test_BitmapEntry(INT iLine, INT bpp, INT width, INT height, BOOL bTopDown) 41 { 42 HBITMAP hBitmap = ::CreateBitmap(width, height, bpp, 1, NULL); 43 ok(hBitmap != NULL, "Line %d: hBitmap was NULL\n", iLine); 44 45 CImage image1; 46 47 ok(image1.IsNull(), "Line %d: IsNull() was TRUE\n", iLine); 48 image1.Attach(hBitmap, (bTopDown ? CImage::DIBOR_TOPDOWN : CImage::DIBOR_BOTTOMUP)); 49 50 ok(!image1.IsNull(), "Line %d: IsNull() was FALSE\n", iLine); 51 ok(!image1.IsDIBSection(), "Line %d: IsDIBSection() was TRUE\n", iLine); 52 53 ok(image1.GetWidth() == width, "Line %d: %d vs %d\n", iLine, image1.GetWidth(), width); 54 ok(image1.GetHeight() == height, "Line %d: %d vs %d\n", iLine, image1.GetHeight(), height); 55 ok(image1.GetBPP() == bpp, "Line %d: %d vs %d\n", iLine, image1.GetBPP(), 1); 56 } 57 58 static void Test_Bitmap(void) 59 { 60 Test_BitmapEntry(__LINE__, 1, 20, 30, FALSE); 61 Test_BitmapEntry(__LINE__, 1, 30, 20, TRUE); 62 Test_BitmapEntry(__LINE__, 4, 20, 30, FALSE); 63 Test_BitmapEntry(__LINE__, 4, 30, 20, TRUE); 64 Test_BitmapEntry(__LINE__, 8, 20, 30, FALSE); 65 Test_BitmapEntry(__LINE__, 8, 30, 20, TRUE); 66 Test_BitmapEntry(__LINE__, 24, 20, 30, FALSE); 67 Test_BitmapEntry(__LINE__, 24, 30, 20, TRUE); 68 Test_BitmapEntry(__LINE__, 32, 20, 30, FALSE); 69 Test_BitmapEntry(__LINE__, 32, 30, 20, TRUE); 70 } 71 72 static void Test_CompatBitmapEntry(INT iLine, HDC hdc, INT width, INT height) 73 { 74 HBITMAP hBitmap = ::CreateCompatibleBitmap(hdc, width, height); 75 ok(hBitmap != NULL, "Line %d: hBitmap was NULL\n", iLine); 76 77 CImage image1; 78 79 ok(image1.IsNull(), "Line %d: IsNull() was TRUE\n", iLine); 80 image1.Attach(hBitmap); 81 82 ok(!image1.IsNull(), "Line %d: IsNull() was FALSE\n", iLine); 83 ok(!image1.IsDIBSection(), "Line %d: IsDIBSection() was TRUE\n", iLine); 84 85 ok(image1.GetWidth() == width, "Line %d: %d vs %d\n", iLine, image1.GetWidth(), width); 86 ok(image1.GetHeight() == height, "Line %d: %d vs %d\n", iLine, image1.GetHeight(), height); 87 } 88 89 static void Test_CompatBitmap(void) 90 { 91 HDC hdc = ::CreateCompatibleDC(NULL); 92 93 Test_CompatBitmapEntry(__LINE__, hdc, 20, 30); 94 Test_CompatBitmapEntry(__LINE__, hdc, 20, 30); 95 Test_CompatBitmapEntry(__LINE__, hdc, 20, 30); 96 Test_CompatBitmapEntry(__LINE__, hdc, 20, 30); 97 Test_CompatBitmapEntry(__LINE__, hdc, 20, 30); 98 99 ::DeleteDC(hdc); 100 101 hdc = ::GetDC(NULL); 102 103 Test_CompatBitmapEntry(__LINE__, hdc, 20, 30); 104 Test_CompatBitmapEntry(__LINE__, hdc, 20, 30); 105 Test_CompatBitmapEntry(__LINE__, hdc, 20, 30); 106 Test_CompatBitmapEntry(__LINE__, hdc, 20, 30); 107 Test_CompatBitmapEntry(__LINE__, hdc, 20, 30); 108 109 ::ReleaseDC(NULL, hdc); 110 } 111 112 static void 113 Test_DIBSectionEntry(INT iLine, HDC hdc, INT bpp, INT width, INT height, BOOL bTopDown) 114 { 115 // Initialize BITMAPINFOEX 116 BITMAPINFOEX bmi; 117 ZeroMemory(&bmi, sizeof(bmi)); 118 bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); 119 bmi.bmiHeader.biWidth = width; 120 bmi.bmiHeader.biHeight = (bTopDown ? -height : height); 121 bmi.bmiHeader.biPlanes = 1; 122 bmi.bmiHeader.biBitCount = bpp; 123 switch (bpp) 124 { 125 case 1: 126 bmi.bmiHeader.biClrUsed = 2; 127 bmi.bmiColorsExtra[0].rgbBlue = 0xFF; 128 bmi.bmiColorsExtra[0].rgbGreen = 0xFF; 129 bmi.bmiColorsExtra[0].rgbRed = 0xFF; 130 break; 131 case 4: 132 case 8: 133 bmi.bmiHeader.biClrUsed = 3; 134 bmi.bmiColorsExtra[0].rgbBlue = 0xFF; 135 bmi.bmiColorsExtra[0].rgbGreen = 0xFF; 136 bmi.bmiColorsExtra[0].rgbRed = 0xFF; 137 bmi.bmiColorsExtra[1].rgbBlue = 0; 138 bmi.bmiColorsExtra[1].rgbGreen = 0; 139 bmi.bmiColorsExtra[1].rgbRed = 0xFF; 140 break; 141 default: 142 break; 143 } 144 145 // Create a DIB bitmap 146 HBITMAP hBitmap = ::CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, NULL, NULL, 0); 147 ok(hBitmap != NULL, "Line %d: hBitmap was NULL\n", iLine); 148 149 BITMAP bm; 150 ::GetObject(hBitmap, sizeof(bm), &bm); 151 INT pitch = (bTopDown ? bm.bmWidthBytes : -bm.bmWidthBytes); 152 153 CImage image1; 154 155 ok(image1.IsNull(), "Line %d: IsNull() was FALSE\n", iLine); 156 157 image1.Attach(hBitmap, (bTopDown ? CImage::DIBOR_TOPDOWN : CImage::DIBOR_BOTTOMUP)); 158 159 ok(!image1.IsNull(), "Line %d: IsNull() was FALSE\n", iLine); 160 ok(image1.IsDIBSection(), "Line %d: IsDIBSection() was FALSE\n", iLine); 161 if (bpp == 4 || bpp == 8) 162 { 163 ok(image1.GetTransparentColor() == 0xFFFFFFFF, "Line %d: 0x%08lX\n", iLine, 164 image1.GetTransparentColor()); 165 } 166 167 switch (bpp) 168 { 169 case 1: 170 ok(image1.GetMaxColorTableEntries() == 2, 171 "Line %d: %d\n", iLine, image1.GetMaxColorTableEntries()); 172 break; 173 case 4: 174 ok(image1.GetMaxColorTableEntries() == 16, 175 "Line %d: %d\n", iLine, image1.GetMaxColorTableEntries()); 176 break; 177 case 8: 178 ok(image1.GetMaxColorTableEntries() == 256, 179 "Line %d: %d\n", iLine, image1.GetMaxColorTableEntries()); 180 break; 181 case 24: 182 case 32: 183 ok(image1.GetMaxColorTableEntries() == 0, 184 "Line %d: %d\n", iLine, image1.GetMaxColorTableEntries()); 185 break; 186 } 187 188 ok(image1.GetWidth() == width, "Line %d: %d vs %d\n", iLine, image1.GetWidth(), width); 189 ok(image1.GetHeight() == height, "Line %d: %d vs %d\n", iLine, image1.GetHeight(), height); 190 ok(image1.GetBPP() == bpp, "Line %d: %d vs %d\n", iLine, image1.GetBPP(), bpp); 191 ok(image1.GetPitch() == pitch, "Line %d: %d vs %d\n", iLine, image1.GetPitch(), pitch); 192 193 LPBYTE pbBits = (LPBYTE)bm.bmBits; 194 if (!bTopDown) 195 pbBits += bm.bmWidthBytes * (height - 1); 196 ok(image1.GetBits() == pbBits, "Line %d: %p vs %p\n", iLine, image1.GetBits(), pbBits); 197 198 // Test Color Table 199 if (bpp <= 8) 200 { 201 DWORD Colors[3]; 202 C_ASSERT(sizeof(DWORD) == sizeof(RGBQUAD)); 203 FillMemory(Colors, sizeof(Colors), 0xCC); 204 image1.GetColorTable(0, _countof(Colors), (RGBQUAD *)Colors); 205 ok(Colors[0] == 0, "Line %d: 0x%08lX\n", iLine, Colors[0]); 206 ok(Colors[1] == 0xFFFFFF, "Line %d: 0x%08lX\n", iLine, Colors[1]); 207 if (bpp >= 4) 208 ok(Colors[2] == 0xFF0000, "Line %d: 0x%08lX\n", iLine, Colors[2]); 209 } 210 211 // Test SetPixel/GetPixel 212 COLORREF color; 213 image1.SetPixel(0, 0, RGB(255, 255, 255)); 214 color = image1.GetPixel(0, 0); 215 ok(color == RGB(255, 255, 255), "Line %d: color was 0x%08lX\n", iLine, color); 216 image1.SetPixel(0, 0, RGB(0, 0, 0)); 217 color = image1.GetPixel(0, 0); 218 ok(color == RGB(0, 0, 0), "Line %d: color was 0x%08lX\n", iLine, color); 219 220 // Test GetDC/ReleaseDC 221 { 222 HDC hdc1 = image1.GetDC(); 223 ok(hdc1 != NULL, "Line %d: hdc1 was NULL\n", iLine); 224 ::SetPixelV(hdc1, 2, 2, RGB(255, 255, 255)); 225 { 226 HDC hdc2 = image1.GetDC(); 227 ok(hdc2 != NULL, "Line %d: hdc2 was NULL\n", iLine); 228 color = ::GetPixel(hdc2, 2, 2); 229 ok(color == RGB(255, 255, 255), "Line %d: color was 0x%08lX\n", iLine, color); 230 image1.ReleaseDC(); 231 } 232 image1.ReleaseDC(); 233 } 234 235 // Test CImageDC 236 { 237 CImageDC hdc1(image1); 238 ok(hdc1 != NULL, "Line %d: hdc1 was NULL\n", iLine); 239 ::SetPixelV(hdc1, 1, 0, RGB(255, 255, 255)); 240 { 241 CImageDC hdc2(image1); 242 ok(hdc2 != NULL, "Line %d: hdc2 was NULL\n", iLine); 243 color = ::GetPixel(hdc2, 1, 0); 244 ok(color == RGB(255, 255, 255), "Line %d: color was 0x%08lX\n", iLine, color); 245 } 246 } 247 248 HRESULT hr; 249 TCHAR szFileName[MAX_PATH]; 250 LPCTSTR dotexts[] = 251 { 252 TEXT(".bmp"), TEXT(".jpg"), TEXT(".png"), TEXT(".gif"), TEXT(".tif") 253 }; 254 255 // Test Save/Load 256 for (UINT iDotExt = 0; iDotExt < _countof(dotexts); ++iDotExt) 257 { 258 ::ExpandEnvironmentStrings(TEXT("%TEMP%\\CImage"), szFileName, _countof(szFileName)); 259 StringCchCat(szFileName, _countof(szFileName), dotexts[iDotExt]); 260 hr = image1.Save(szFileName); 261 ok(hr == S_OK, "Line %d: %d: hr was 0x%08lX\n", iLine, iDotExt, hr); 262 263 CImage image2; 264 hr = image2.Load(szFileName); 265 ok(hr == S_OK, "Line %d: %d: hr was 0x%08lX\n", iLine, iDotExt, hr); 266 ::DeleteFile(szFileName); 267 268 CImageDC hdc2(image2); 269 ok(hdc2 != NULL, "Line %d: %d: hdc2 was NULL\n", iLine, iDotExt); 270 color = ::GetPixel(hdc2, 0, 0); 271 ok(color == RGB(0, 0, 0), "Line %d: %d: color was 0x%08lX\n", iLine, iDotExt, color); 272 color = ::GetPixel(hdc2, 1, 0); 273 ok(color == RGB(255, 255, 255), "Line %d: %d: color was 0x%08lX\n", iLine, iDotExt, color); 274 } 275 276 // Test GetPixelAddress 277 Test_PixelAddress(iLine, image1, bm, 0, 0, bTopDown); 278 Test_PixelAddress(iLine, image1, bm, 10, 0, bTopDown); 279 Test_PixelAddress(iLine, image1, bm, 0, 10, bTopDown); 280 Test_PixelAddress(iLine, image1, bm, 4, 6, bTopDown); 281 Test_PixelAddress(iLine, image1, bm, 6, 2, bTopDown); 282 } 283 284 static void Test_DIBSection(void) 285 { 286 HDC hdc = ::CreateCompatibleDC(NULL); 287 288 Test_DIBSectionEntry(__LINE__, hdc, 1, 30, 20, FALSE); 289 Test_DIBSectionEntry(__LINE__, hdc, 1, 20, 30, TRUE); 290 Test_DIBSectionEntry(__LINE__, hdc, 4, 30, 20, FALSE); 291 Test_DIBSectionEntry(__LINE__, hdc, 4, 20, 30, TRUE); 292 Test_DIBSectionEntry(__LINE__, hdc, 8, 30, 20, FALSE); 293 Test_DIBSectionEntry(__LINE__, hdc, 8, 20, 30, TRUE); 294 Test_DIBSectionEntry(__LINE__, hdc, 24, 30, 20, FALSE); 295 Test_DIBSectionEntry(__LINE__, hdc, 24, 20, 30, TRUE); 296 Test_DIBSectionEntry(__LINE__, hdc, 32, 30, 20, FALSE); 297 Test_DIBSectionEntry(__LINE__, hdc, 32, 20, 30, TRUE); 298 299 ::DeleteDC(hdc); 300 } 301 302 static void Test_ResBitmap(void) 303 { 304 HINSTANCE hInst = GetModuleHandle(NULL); 305 306 CImage image1; 307 ok_int(image1.IsNull(), TRUE); 308 image1.LoadFromResource(hInst, IDB_ANT); 309 ok_int(image1.IsNull(), FALSE); 310 311 ok_int(image1.GetWidth(), 48); 312 ok_int(image1.GetHeight(), 48); 313 ok_int(image1.GetBPP(), 8); 314 ok_int(image1.GetPitch(), -48); 315 316 CImage image2; 317 ok_int(image2.IsNull(), TRUE); 318 image2.LoadFromResource(hInst, IDB_CROSS); 319 ok_int(image2.IsNull(), FALSE); 320 321 ok_int(image2.GetWidth(), 32); 322 ok_int(image2.GetHeight(), 32); 323 ok_int(image2.GetBPP(), 8); 324 ok_int(image2.GetPitch(), -32); 325 } 326 327 static INT FindGUID(REFGUID rguid, const CSimpleArray<GUID>& guids) 328 { 329 for (INT i = 0; i < guids.GetSize(); ++i) 330 { 331 if (memcmp(&rguid, &guids[i], sizeof(GUID)) == 0) 332 return i; 333 } 334 return -1; 335 } 336 337 static INT FindFilterItem(const TCHAR *filter, const TCHAR *item) 338 { 339 INT iFilter = 0; 340 DWORD cbItem = lstrlen(item) * sizeof(TCHAR); 341 BOOL bSep = TRUE; 342 343 for (; *filter; ++filter) 344 { 345 if (bSep && memcmp(item, filter, cbItem) == 0) 346 return (iFilter + 1) / 2; 347 348 bSep = (*filter == TEXT('|')); 349 if (bSep) 350 ++iFilter; 351 } 352 353 return -1; 354 } 355 356 static void Test_Importer(void) 357 { 358 HRESULT hr; 359 ATL::IAtlStringMgr *mgr = CAtlStringMgr::GetInstance(); 360 CSimpleArray<GUID> aguidFileTypes; 361 INT iNULL, iBMP, iJPEG, iGIF, iPNG, iTIFF, iEMF, iWMF; 362 363 // Try importer with "All Image Files" 364 CSimpleString strImporters(mgr); 365 aguidFileTypes.RemoveAll(); 366 hr = CImage::GetImporterFilterString(strImporters, aguidFileTypes, TEXT("All Image Files"), 0); 367 ok(hr == S_OK, "Expected hr to be S_OK, was: %ld\n", hr); 368 ok(aguidFileTypes.GetSize() >= 8, 369 "Expected aguidFileTypes.GetSize() to be >= 8, was %d.", aguidFileTypes.GetSize()); 370 371 iNULL = FindGUID(GUID_NULL, aguidFileTypes); 372 iBMP = FindGUID(Gdiplus::ImageFormatBMP, aguidFileTypes); 373 iJPEG = FindGUID(Gdiplus::ImageFormatJPEG, aguidFileTypes); 374 iGIF = FindGUID(Gdiplus::ImageFormatGIF, aguidFileTypes); 375 iPNG = FindGUID(Gdiplus::ImageFormatPNG, aguidFileTypes); 376 iTIFF = FindGUID(Gdiplus::ImageFormatTIFF, aguidFileTypes); 377 iEMF = FindGUID(Gdiplus::ImageFormatEMF, aguidFileTypes); 378 iWMF = FindGUID(Gdiplus::ImageFormatWMF, aguidFileTypes); 379 380 ok_int(iNULL, 0); 381 ok(iBMP > 0, "iBMP was %d\n", iBMP); 382 ok(iJPEG > 0, "iJPEG was %d\n", iJPEG); 383 ok(iGIF > 0, "iGIF was %d\n", iGIF); 384 ok(iPNG > 0, "iPNG was %d\n", iPNG); 385 ok(iTIFF > 0, "iTIFF was %d\n", iTIFF); 386 ok(iEMF > 0, "iEMF was %d\n", iEMF); 387 ok(iWMF > 0, "iWMF was %d\n", iWMF); 388 389 ok_int(memcmp(strImporters, TEXT("All Image Files|"), sizeof(TEXT("All Image Files|")) - sizeof(TCHAR)), 0); 390 ok_int(iBMP, FindFilterItem(strImporters, TEXT("BMP (*.BMP;*.DIB;*.RLE)|*.BMP;*.DIB;*.RLE|"))); 391 ok_int(iJPEG, FindFilterItem(strImporters, TEXT("JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|"))); 392 ok_int(iGIF, FindFilterItem(strImporters, TEXT("GIF (*.GIF)|*.GIF|"))); 393 ok_int(iPNG, FindFilterItem(strImporters, TEXT("PNG (*.PNG)|*.PNG|"))); 394 ok_int(iTIFF, FindFilterItem(strImporters, TEXT("TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF|"))); 395 396 // Try importer without "All Image Files" 397 aguidFileTypes.RemoveAll(); 398 strImporters.Empty(); 399 hr = CImage::GetImporterFilterString(strImporters, aguidFileTypes, NULL, 0); 400 ok(hr == S_OK, "Expected hr to be S_OK, was: %ld\n", hr); 401 ok(aguidFileTypes.GetSize() >= 7, 402 "Expected aguidFileTypes.GetSize() to be >= 7, was %d.", aguidFileTypes.GetSize()); 403 404 iNULL = FindGUID(GUID_NULL, aguidFileTypes); 405 iBMP = FindGUID(Gdiplus::ImageFormatBMP, aguidFileTypes); 406 iJPEG = FindGUID(Gdiplus::ImageFormatJPEG, aguidFileTypes); 407 iGIF = FindGUID(Gdiplus::ImageFormatGIF, aguidFileTypes); 408 iPNG = FindGUID(Gdiplus::ImageFormatPNG, aguidFileTypes); 409 iTIFF = FindGUID(Gdiplus::ImageFormatTIFF, aguidFileTypes); 410 iEMF = FindGUID(Gdiplus::ImageFormatEMF, aguidFileTypes); 411 iWMF = FindGUID(Gdiplus::ImageFormatWMF, aguidFileTypes); 412 413 ok_int(iNULL, -1); 414 ok_int(iBMP, 0); 415 ok(iJPEG > 0, "iJPEG was %d\n", iJPEG); 416 ok(iGIF > 0, "iGIF was %d\n", iGIF); 417 ok(iPNG > 0, "iPNG was %d\n", iPNG); 418 ok(iTIFF > 0, "iTIFF was %d\n", iTIFF); 419 ok(iEMF > 0, "iEMF was %d\n", iEMF); 420 ok(iWMF > 0, "iWMF was %d\n", iWMF); 421 422 ok_int(iBMP, FindFilterItem(strImporters, TEXT("BMP (*.BMP;*.DIB;*.RLE)|*.BMP;*.DIB;*.RLE|"))); 423 ok_int(iJPEG, FindFilterItem(strImporters, TEXT("JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|"))); 424 ok_int(iGIF, FindFilterItem(strImporters, TEXT("GIF (*.GIF)|*.GIF|"))); 425 ok_int(iPNG, FindFilterItem(strImporters, TEXT("PNG (*.PNG)|*.PNG|"))); 426 ok_int(iTIFF, FindFilterItem(strImporters, TEXT("TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF|"))); 427 } 428 429 static void Test_Exporter(void) 430 { 431 HRESULT hr; 432 ATL::IAtlStringMgr *mgr = CAtlStringMgr::GetInstance(); 433 CSimpleArray<GUID> aguidFileTypes; 434 INT iNULL, iBMP, iJPEG, iGIF, iPNG, iTIFF; 435 436 // Try exporter with "All Image Files" 437 CSimpleString strExporters(mgr); 438 aguidFileTypes.RemoveAll(); 439 hr = CImage::GetExporterFilterString(strExporters, aguidFileTypes, TEXT("All Image Files"), 0); 440 ok(hr == S_OK, "Expected hr to be S_OK, was: %ld\n", hr); 441 ok(aguidFileTypes.GetSize() >= 6, 442 "Expected aguidFileTypes.GetSize() to be >= 6, was %d.", aguidFileTypes.GetSize()); 443 444 iNULL = FindGUID(GUID_NULL, aguidFileTypes); 445 iBMP = FindGUID(Gdiplus::ImageFormatBMP, aguidFileTypes); 446 iJPEG = FindGUID(Gdiplus::ImageFormatJPEG, aguidFileTypes); 447 iGIF = FindGUID(Gdiplus::ImageFormatGIF, aguidFileTypes); 448 iPNG = FindGUID(Gdiplus::ImageFormatPNG, aguidFileTypes); 449 iTIFF = FindGUID(Gdiplus::ImageFormatTIFF, aguidFileTypes); 450 451 ok_int(iNULL, 0); 452 ok(iBMP > 0, "iBMP was %d\n", iBMP); 453 ok(iJPEG > 0, "iJPEG was %d\n", iJPEG); 454 ok(iGIF > 0, "iGIF was %d\n", iGIF); 455 ok(iPNG > 0, "iPNG was %d\n", iPNG); 456 ok(iTIFF > 0, "iTIFF was %d\n", iTIFF); 457 458 ok_int(iBMP, FindFilterItem(strExporters, TEXT("BMP (*.BMP;*.DIB;*.RLE)|*.BMP;*.DIB;*.RLE|"))); 459 ok_int(iJPEG, FindFilterItem(strExporters, TEXT("JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|"))); 460 ok_int(iGIF, FindFilterItem(strExporters, TEXT("GIF (*.GIF)|*.GIF|"))); 461 ok_int(iPNG, FindFilterItem(strExporters, TEXT("PNG (*.PNG)|*.PNG|"))); 462 ok_int(iTIFF, FindFilterItem(strExporters, TEXT("TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF|"))); 463 464 // Try exporter without "All Image Files" 465 strExporters.Empty(); 466 aguidFileTypes.RemoveAll(); 467 hr = CImage::GetExporterFilterString(strExporters, aguidFileTypes, NULL, 0); 468 ok(hr == S_OK, "Expected hr to be S_OK, was: %ld\n", hr); 469 ok(aguidFileTypes.GetSize() >= 5, 470 "Expected aguidFileTypes.GetSize() to be >= 5, was %d.", aguidFileTypes.GetSize()); 471 472 iNULL = FindGUID(GUID_NULL, aguidFileTypes); 473 iBMP = FindGUID(Gdiplus::ImageFormatBMP, aguidFileTypes); 474 iJPEG = FindGUID(Gdiplus::ImageFormatJPEG, aguidFileTypes); 475 iGIF = FindGUID(Gdiplus::ImageFormatGIF, aguidFileTypes); 476 iPNG = FindGUID(Gdiplus::ImageFormatPNG, aguidFileTypes); 477 iTIFF = FindGUID(Gdiplus::ImageFormatTIFF, aguidFileTypes); 478 479 ok_int(iNULL, -1); 480 ok_int(iBMP, 0); 481 ok(iJPEG > 0, "iJPEG was %d\n", iJPEG); 482 ok(iGIF > 0, "iGIF was %d\n", iGIF); 483 ok(iPNG > 0, "iPNG was %d\n", iPNG); 484 ok(iTIFF > 0, "iTIFF was %d\n", iTIFF); 485 486 ok_int(iBMP, FindFilterItem(strExporters, TEXT("BMP (*.BMP;*.DIB;*.RLE)|*.BMP;*.DIB;*.RLE|"))); 487 ok_int(iJPEG, FindFilterItem(strExporters, TEXT("JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|"))); 488 ok_int(iGIF, FindFilterItem(strExporters, TEXT("GIF (*.GIF)|*.GIF|"))); 489 ok_int(iPNG, FindFilterItem(strExporters, TEXT("PNG (*.PNG)|*.PNG|"))); 490 ok_int(iTIFF, FindFilterItem(strExporters, TEXT("TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF|"))); 491 } 492 493 START_TEST(CImage) 494 { 495 Test_Bitmap(); 496 Test_CompatBitmap(); 497 Test_DIBSection(); 498 Test_ResBitmap(); 499 Test_Importer(); 500 Test_Exporter(); 501 } 502