From: Fabian Maurer dark.shadow4@web.de
--- dlls/gdiplus/tests/image.c | 44 +++++++++++++++++++++++++++++++ dlls/gdiplus/tests/resource.rc | 3 +++ dlls/gdiplus/tests/wine_test.ico | Bin 0 -> 4375 bytes 3 files changed, 47 insertions(+) create mode 100644 dlls/gdiplus/tests/wine_test.ico
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index df26f699e86..256aa360d47 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -486,11 +486,39 @@ static void test_GdipImageGetFrameDimensionsCount(void) GdipDisposeImage((GpImage*)bm); }
+static void _load_resource(int line, const WCHAR *filename, BYTE **data, DWORD *size) +{ + HRSRC resource = FindResourceW(NULL, filename, (const WCHAR *)RT_RCDATA); + ok_(__FILE__, line)(!!resource, "FindResourceW failed, error %lu\n", GetLastError()); + *data = LockResource(LoadResource(GetModuleHandleW(NULL), resource)); + ok_(__FILE__, line)(!!*data, "LockResource failed, error %lu\n", GetLastError()); + *size = SizeofResource(GetModuleHandleW(NULL), resource); + ok_(__FILE__, line)(*size > 0, "SizeofResource failed, error %lu\n", GetLastError()); +} + +static void create_test_resource(const WCHAR *filename, int resource) +{ + DWORD written, length; + HANDLE file; + void *ptr; + + file = CreateFileW(filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %ld\n", wine_dbgstr_w(filename), GetLastError()); + + _load_resource(__LINE__, MAKEINTRESOURCEW(resource), (BYTE **)&ptr, &length); + WriteFile(file, ptr, length, &written, NULL); + ok(written == length, "couldn't write resource\n"); + CloseHandle(file); +} + static void test_LoadingImages(void) { + static const GUID format_ico = { 0xb96b3cb5U, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} }; + static const WCHAR filename_ico[] = L"a.ico"; GpStatus stat; GpBitmap *bm; GpImage *img; + GUID format;
stat = GdipCreateBitmapFromFile(0, 0); expect(InvalidParameter, stat); @@ -530,6 +558,22 @@ static void test_LoadingImages(void) stat = GdipLoadImageFromFileICM(L"nonexistent", &img); todo_wine expect(OutOfMemory, stat); ok(!img, "returned %p\n", img); + + create_test_resource(filename_ico, 5); + + bm = NULL; + stat = GdipLoadImageFromFile(filename_ico, (GpImage**)&bm); + expect(Ok, stat); + if (stat != Ok) goto cleanup; + + stat = GdipGetImageRawFormat((GpImage*)bm, &format); + expect(Ok, stat); + expect_guid(&format_ico, &format, __LINE__, TRUE); + +cleanup: + if (bm) + GdipDisposeImage((GpImage*)bm); + ok(DeleteFileW(filename_ico), "Delete failed.\n"); }
static void test_SavingImages(void) diff --git a/dlls/gdiplus/tests/resource.rc b/dlls/gdiplus/tests/resource.rc index 4af61fef65d..b16b933fb43 100644 --- a/dlls/gdiplus/tests/resource.rc +++ b/dlls/gdiplus/tests/resource.rc @@ -31,3 +31,6 @@ /* Generated with: fonttools ttx wine_unicode_mac.ttx */ /* @makedep: wine_unicode_mac.ttf */ 4 RCDATA wine_unicode_mac.ttf + +/* Copied from shell32/blank.ico */ +5 RCDATA wine_test.ico diff --git a/dlls/gdiplus/tests/wine_test.ico b/dlls/gdiplus/tests/wine_test.ico new file mode 100644 index 0000000000000000000000000000000000000000..63b7cdda93f03885fe39c067411eb2a021f492ba GIT binary patch literal 4375 zcmZQzU}WH800Bk@1qMe(28Lxowt)c?kk80qz|6q#94Lm&7iUG~yK^uwC@4VH1J#yu zqw<&Ypz^QtGB5}TK-6yl+QrU~%HNL0PZwZd=nU|4=jD<DIh5Da!zBphS`Y@23?-aX zPXj5IbVpxD28NCO+<y{*PGnF>_6YK2V5m}KU}$JzVE6?TYIwoGP-?)y@G60U!D<Er zgLuK5U4b@038s=DzhDN2vdL#HK)fVxcNYf6yIsOdfIRjRPhVH|M;y|;;@XYZQ$GWR z1d<c|%7E%BfNlV~jsX|~3>^Aw%R+#(yr+v}NXEUl2N{9>WH_|oyMHd9`2rvl4EFIV z0`=5O&RGuRs+PD$l%yn<q*^5xr2;7iBLhPVT>}eUBl8eLLn|X=D-&aF10yQ~1Ag;Y zswf(A^HVa@DsgM5%L<wave47j&t;ucLX!rN4fHre0uV!kjiCV?dO!gnV1iJi<RA%w z|6sttFiL|$fd1hynqLM<Mj+A|qxocD@(C>5NAnAj33ZStgT>n@JuvwOlwTBp*a3*) z?J*!51_oPu43bU;jvNgy(!zc;yhsl(P)|+)h++BB0my~{YUf8tn-<irB@ct*chtSG M*ukX94Of^x0AQP$MF0Q*
literal 0 HcmV?d00001
From: Fabian Maurer dark.shadow4@web.de
Adapted from https://github.com/reactos/reactos/pull/7714 --- dlls/gdiplus/image.c | 2 +- dlls/gdiplus/tests/image.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 6e55113dbce..c2c8b112e88 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -5209,7 +5209,7 @@ static const struct image_codec codecs[NUM_CODECS] = { { { /* ICO */ /* Clsid */ { 0x557cf407, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } }, - /* FormatID */ { 0xb96b3cabU, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} }, + /* FormatID */ { 0xb96b3cb5U, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} }, /* CodecName */ ico_codecname, /* DllName */ NULL, /* FormatDescription */ ico_format, diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 256aa360d47..63b559b5cee 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -568,7 +568,7 @@ static void test_LoadingImages(void)
stat = GdipGetImageRawFormat((GpImage*)bm, &format); expect(Ok, stat); - expect_guid(&format_ico, &format, __LINE__, TRUE); + expect_guid(&format_ico, &format, __LINE__, FALSE);
cleanup: if (bm)
Those format guids have named constants defined in gdiplusimaging.h, I think we should be using that to make it both readable and prevent problems like that. The fix in principle looks fine, it was probably copied over from BMP format resulting in this typo.