0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
-/* 1x1 pixel bmp */
+/* 1bpp BI_RGB 1x1 pixel bmp */
static const unsigned char bmpimage[66] = {
0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
0x00,0x00
};
+/* 8bpp BI_RLE8 1x1 pixel bmp */
+static const unsigned char bmpimage_rle8[] = {
+0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
+0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x01,0x00,
+0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
+0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x00,0x01,
+0x00,0x00
+};
+
/* 2x2 pixel gif */
static const unsigned char gif4pixel[42] = {
0x47,0x49,0x46,0x38,0x37,0x61,0x02,0x00,0x02,0x00,0xa1,0x00,0x00,0x00,0x00,0x00,
0x14, 0x00, 0x00, 0x00
};
+static HBITMAP stock_bm;
+
+static HDC create_render_dc( void )
+{
+ HDC dc = CreateCompatibleDC( NULL );
+ BITMAPINFO info = {{sizeof(info.bmiHeader), 100, 100, 1, 32, BI_RGB }};
+ void *bits;
+ HBITMAP dib = CreateDIBSection( NULL, &info, DIB_RGB_COLORS, &bits, NULL, 0 );
+
+ stock_bm = SelectObject( dc, dib );
+ return dc;
+}
+
+static void delete_render_dc( HDC dc )
+{
+ HBITMAP dib = SelectObject( dc, stock_bm );
+ DeleteObject( dib );
+ DeleteDC( dc );
+}
typedef struct NoStatStreamImpl
{
ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
/* DISPID_PICT_RENDER */
- hdc = GetDC(0);
+ hdc = create_render_dc();
for (i = 0; i < sizeof(args)/sizeof(args[0]); i++)
V_VT(&args[i]) = VT_I4;
hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_RENDER, &GUID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
ok(hr == DISP_E_BADPARAMCOUNT, "got 0x%08x\n", hr);
- ReleaseDC(NULL, hdc);
+ delete_render_dc(hdc);
IPictureDisp_Release(picdisp);
}
OLE_XSIZE_HIMETRIC pWidth;
OLE_YSIZE_HIMETRIC pHeight;
COLORREF result, expected;
- HDC hdc = GetDC(0);
+ HDC hdc = create_render_dc();
/* test IPicture::Render return code on uninitialized picture */
OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (VOID**)&pic);
desc.u.icon.hicon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
if(!desc.u.icon.hicon){
win_skip("LoadIcon failed. Skipping...\n");
- ReleaseDC(NULL, hdc);
+ delete_render_dc(hdc);
return;
}
hres = picture_render(pic, hdc, 1, 1, 9, 9, 0, 0, pWidth, -pHeight, NULL);
ole_expect(hres, S_OK);
- if(hres != S_OK) {
- IPicture_Release(pic);
- ReleaseDC(NULL, hdc);
- return;
- }
+ if(hres != S_OK) goto done;
/* Evaluate the rendered Icon */
result = GetPixel(hdc, 0, 0);
ok(result == expected,
"Color at 0,0 should be unchanged 0x%06X, but was 0x%06X\n", expected, result);
result = GetPixel(hdc, 5, 5);
- ok(result != expected ||
- broken(result == expected), /* WinNT 4.0 and older may claim they drew */
- /* the icon, even if they didn't. */
+ ok(result != expected,
"Color at 5,5 should have changed, but still was 0x%06X\n", expected);
result = GetPixel(hdc, 10, 10);
ok(result == expected,
"Color at 10,10 should be unchanged 0x%06X, but was 0x%06X\n", expected, result);
+done:
IPicture_Release(pic);
- ReleaseDC(NULL, hdc);
+ delete_render_dc(hdc);
}
static void test_get_Attributes(void)
test_pic(gifimage, sizeof(gifimage));
test_pic(jpgimage, sizeof(jpgimage));
test_pic(bmpimage, sizeof(bmpimage));
+ test_pic(bmpimage_rle8, sizeof(bmpimage_rle8));
test_pic(gif4pixel, sizeof(gif4pixel));
/* FIXME: No PNG support in Windows... */
if (0) test_pic(pngimage, sizeof(pngimage));
NoStatStreamImpl* const This = impl_from_IStream(iface);
if (ppvObject==0) return E_INVALIDARG;
*ppvObject = 0;
- if (IsEqualIID(&IID_IUnknown, riid))
- {
- *ppvObject = This;
- }
- else if (IsEqualIID(&IID_IStream, riid))
- {
- *ppvObject = This;
- }
+
+ if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IStream, riid))
+ *ppvObject = &This->IStream_iface;
if ((*ppvObject)==0)
return E_NOINTERFACE;