ReactOS 0.4.16-dev-297-gc569aee
olepicture.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <math.h>
#include <float.h>
#include "wine/test.h"
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <wingdi.h>
#include <winnls.h>
#include <winerror.h>
#include <winnt.h>
#include <urlmon.h>
#include <wtypes.h>
#include <olectl.h>
#include <objidl.h>
Include dependency graph for olepicture.c:

Go to the source code of this file.

Classes

struct  NoStatStreamImpl
 

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 
#define NONAMELESSUNION
 
#define expect_eq(expr, value, type, format)   { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
 
#define ole_expect(expr, expect)
 
#define ole_check(expr)   ole_expect(expr, S_OK);
 
#define ok_ole_success(hr, func)   ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
 

Typedefs

typedef struct NoStatStreamImpl NoStatStreamImpl
 

Functions

static HRESULT (WINAPI *pOleLoadPicture)(LPSTREAM
 
static HDC create_render_dc (void)
 
static void delete_render_dc (HDC dc)
 
static IStreamNoStatStream_Construct (HGLOBAL hGlobal)
 
static void test_pic_with_stream (LPSTREAM stream, unsigned int imgsize)
 
static void test_pic (const unsigned char *imgdata, unsigned int imgsize)
 
static void test_empty_image (void)
 
static void test_empty_image_2 (void)
 
static void test_Invoke (void)
 
static HRESULT create_picture (short type, IPicture **pict)
 
static void test_OleCreatePictureIndirect (void)
 
static void test_apm (void)
 
static void test_metafile (void)
 
static void test_enhmetafile (void)
 
static HRESULT picture_render (IPicture *iface, HDC hdc, LONG x, LONG y, LONG cx, LONG cy, OLE_XPOS_HIMETRIC xSrc, OLE_YPOS_HIMETRIC ySrc, OLE_XSIZE_HIMETRIC cxSrc, OLE_YSIZE_HIMETRIC cySrc, const RECT *bounds)
 
static void test_Render (void)
 
static void test_get_Attributes (void)
 
static void test_get_Handle (void)
 
static void test_get_Type (void)
 
static void test_OleLoadPicturePath (void)
 
static void test_himetric (void)
 
static void test_load_save_bmp (void)
 
static void test_load_save_icon (void)
 
static void test_load_save_empty_picture (void)
 
static void test_load_save_emf (void)
 
 START_TEST (olepicture)
 
static NoStatStreamImplimpl_from_IStream (IStream *iface)
 
static void NoStatStreamImpl_Destroy (NoStatStreamImpl *This)
 
static ULONG WINAPI NoStatStreamImpl_AddRef (IStream *iface)
 
static HRESULT WINAPI NoStatStreamImpl_QueryInterface (IStream *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI NoStatStreamImpl_Release (IStream *iface)
 
static HRESULT WINAPI NoStatStreamImpl_Read (IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI NoStatStreamImpl_Write (IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
 
static HRESULT WINAPI NoStatStreamImpl_Seek (IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI NoStatStreamImpl_SetSize (IStream *iface, ULARGE_INTEGER libNewSize)
 
static HRESULT WINAPI NoStatStreamImpl_CopyTo (IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 
static HRESULT WINAPI NoStatStreamImpl_Commit (IStream *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI NoStatStreamImpl_Revert (IStream *iface)
 
static HRESULT WINAPI NoStatStreamImpl_LockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI NoStatStreamImpl_UnlockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI NoStatStreamImpl_Stat (IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
static HRESULT WINAPI NoStatStreamImpl_Clone (IStream *iface, IStream **ppstm)
 

Variables

static HMODULE hOleaut32
 
static LONG
 
static BOOL
 
static REFIID
 
static LPVOID *static DWORD
 
static const unsigned char gifimage [35]
 
static const unsigned char jpgimage [285]
 
static const unsigned char pngimage [285]
 
static const unsigned char bmpimage [66]
 
static const unsigned char bmpimage_rle8 []
 
static const unsigned char gif4pixel [42]
 
static const unsigned char apmdata []
 
static const unsigned char metafile []
 
static const unsigned char enhmetafile []
 
static HBITMAP stock_bm
 
static const IStreamVtbl NoStatStreamImpl_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 27 of file olepicture.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 28 of file olepicture.c.

◆ expect_eq

#define expect_eq (   expr,
  value,
  type,
  format 
)    { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }

Definition at line 47 of file olepicture.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 30 of file olepicture.c.

◆ ok_ole_success

#define ok_ole_success (   hr,
  func 
)    ok(hr == S_OK, func " failed with error 0x%08x\n", hr)

Definition at line 61 of file olepicture.c.

◆ ole_check

#define ole_check (   expr)    ole_expect(expr, S_OK);

Definition at line 54 of file olepicture.c.

◆ ole_expect

#define ole_expect (   expr,
  expect 
)
Value:
{ \
HRESULT r = expr; \
ok(r == (expect), #expr " returned %x, expected %s (%x)\n", r, #expect, expect); \
}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
Definition: query.h:86

Definition at line 49 of file olepicture.c.

Typedef Documentation

◆ NoStatStreamImpl

Function Documentation

◆ create_picture()

static HRESULT create_picture ( short  type,
IPicture **  pict 
)
static

Definition at line 553 of file olepicture.c.

554{
556
557 desc.cbSizeofstruct = sizeof(desc);
558 desc.picType = type;
559
560 switch (type)
561 {
563 return OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (void **)pict);
564
565 case PICTYPE_NONE:
566 break;
567
568 case PICTYPE_BITMAP:
569 desc.bmp.hbitmap = CreateBitmap(1, 1, 1, 1, NULL);
570 desc.bmp.hpal = (HPALETTE)0xbeefdead;
571 break;
572
573 case PICTYPE_ICON:
574 desc.icon.hicon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
575 break;
576
577 case PICTYPE_METAFILE:
578 {
580 desc.wmf.hmeta = CloseMetaFile(hdc);
581 desc.wmf.xExt = 1;
582 desc.wmf.yExt = 1;
583 break;
584 }
585
587 {
589 desc.emf.hemf = CloseEnhMetaFile(hdc);
590 break;
591 }
592
593 default:
594 ok(0, "picture type %d is not supported\n", type);
595 return E_NOTIMPL;
596 }
597
598 return OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (void **)pict);
599}
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
HRESULT WINAPI OleCreatePictureIndirect(LPPICTDESC lpPictDesc, REFIID riid, BOOL Own, void **ppvObj)
Definition: olepicture.c:2313
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static const WCHAR desc[]
Definition: protectdata.c:36
#define PICTYPE_UNINITIALIZED
Definition: olectl.h:131
#define PICTYPE_BITMAP
Definition: olectl.h:133
#define PICTYPE_ENHMETAFILE
Definition: olectl.h:136
#define PICTYPE_NONE
Definition: olectl.h:132
#define PICTYPE_METAFILE
Definition: olectl.h:134
#define PICTYPE_ICON
Definition: olectl.h:135
const GUID IID_IPicture
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HDC WINAPI CreateMetaFileA(_In_opt_ LPCSTR)
HMETAFILE WINAPI CloseMetaFile(_In_ HDC hdc)
HDC WINAPI CreateEnhMetaFileA(_In_opt_ HDC, _In_opt_ LPCSTR, _In_opt_ LPCRECT, _In_opt_ LPCSTR)
HENHMETAFILE WINAPI CloseEnhMetaFile(_In_ HDC hdc)
#define IDI_APPLICATION
Definition: winuser.h:704
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2112
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by test_OleCreatePictureIndirect().

◆ create_render_dc()

static HDC create_render_dc ( void  )
static

Definition at line 185 of file olepicture.c.

186{
188 BITMAPINFO info = {{sizeof(info.bmiHeader), 100, 100, 1, 32, BI_RGB }};
189 void *bits;
191
193 return dc;
194}
#define BI_RGB
Definition: precomp.h:56
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
static const WCHAR dc[]
static HBITMAP
Definition: button.c:44
static const BYTE dib[]
Definition: ole2.c:201
static HBITMAP stock_bm
Definition: olepicture.c:183
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)

Referenced by test_Invoke(), and test_Render().

◆ delete_render_dc()

static void delete_render_dc ( HDC  dc)
static

Definition at line 196 of file olepicture.c.

197{
199 DeleteObject( dib );
200 DeleteDC( dc );
201}
pKey DeleteObject()
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by test_Invoke(), and test_Render().

◆ HRESULT()

static HRESULT ( WINAPI pOleLoadPicture)
static

◆ impl_from_IStream()

static NoStatStreamImpl * impl_from_IStream ( IStream iface)
inlinestatic

◆ NoStatStream_Construct()

static IStream * NoStatStream_Construct ( HGLOBAL  hGlobal)
static

Definition at line 1839 of file olepicture.c.

1840{
1841 NoStatStreamImpl* newStream;
1842
1843 newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(NoStatStreamImpl));
1844 if (newStream!=0)
1845 {
1846 newStream->IStream_iface.lpVtbl = &NoStatStreamImpl_Vtbl;
1847 newStream->ref = 1;
1848 newStream->supportHandle = hGlobal;
1849
1850 if (!newStream->supportHandle)
1852 GMEM_SHARE, 0);
1853 newStream->currentPosition.u.HighPart = 0;
1854 newStream->currentPosition.u.LowPart = 0;
1855 newStream->streamSize.u.HighPart = 0;
1856 newStream->streamSize.u.LowPart = GlobalSize(newStream->supportHandle);
1857 }
1858 return &newStream->IStream_iface;
1859}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
static const IStreamVtbl NoStatStreamImpl_Vtbl
Definition: olepicture.c:1830
IStream IStream_iface
Definition: olepicture.c:205
ULARGE_INTEGER streamSize
Definition: olepicture.c:209
HGLOBAL supportHandle
Definition: olepicture.c:208
ULARGE_INTEGER currentPosition
Definition: olepicture.c:210
struct _ULARGE_INTEGER::@4140 u
#define GMEM_NODISCARD
Definition: winbase.h:328
#define GMEM_MOVEABLE
Definition: winbase.h:320
#define GMEM_SHARE
Definition: winbase.h:331

Referenced by test_load_save_empty_picture(), and test_pic().

◆ NoStatStreamImpl_AddRef()

static ULONG WINAPI NoStatStreamImpl_AddRef ( IStream iface)
static

Definition at line 1604 of file olepicture.c.

1606{
1607 NoStatStreamImpl* const This = impl_from_IStream(iface);
1608 return InterlockedIncrement(&This->ref);
1609}
#define InterlockedIncrement
Definition: armddk.h:53
static NoStatStreamImpl * impl_from_IStream(IStream *iface)
Definition: olepicture.c:1592

Referenced by NoStatStreamImpl_QueryInterface().

◆ NoStatStreamImpl_Clone()

static HRESULT WINAPI NoStatStreamImpl_Clone ( IStream iface,
IStream **  ppstm 
)
static

Definition at line 1824 of file olepicture.c.

1827{
1828 return E_NOTIMPL;
1829}

◆ NoStatStreamImpl_Commit()

static HRESULT WINAPI NoStatStreamImpl_Commit ( IStream iface,
DWORD  grfCommitFlags 
)
static

Definition at line 1792 of file olepicture.c.

1793{
1794 return S_OK;
1795}
#define S_OK
Definition: intsafe.h:52

◆ NoStatStreamImpl_CopyTo()

static HRESULT WINAPI NoStatStreamImpl_CopyTo ( IStream iface,
IStream pstm,
ULARGE_INTEGER  cb,
ULARGE_INTEGER pcbRead,
ULARGE_INTEGER pcbWritten 
)
static

Definition at line 1740 of file olepicture.c.

1746{
1747 HRESULT hr = S_OK;
1748 BYTE tmpBuffer[128];
1749 ULONG bytesRead, bytesWritten, copySize;
1750 ULARGE_INTEGER totalBytesRead;
1751 ULARGE_INTEGER totalBytesWritten;
1752
1753 if ( pstm == 0 )
1754 return STG_E_INVALIDPOINTER;
1755 totalBytesRead.u.LowPart = totalBytesRead.u.HighPart = 0;
1756 totalBytesWritten.u.LowPart = totalBytesWritten.u.HighPart = 0;
1757
1758 while ( cb.u.LowPart > 0 )
1759 {
1760 if ( cb.u.LowPart >= 128 )
1761 copySize = 128;
1762 else
1763 copySize = cb.u.LowPart;
1764 IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
1765 totalBytesRead.u.LowPart += bytesRead;
1766 IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
1767 totalBytesWritten.u.LowPart += bytesWritten;
1768 if (bytesRead != bytesWritten)
1769 {
1771 break;
1772 }
1773 if (bytesRead!=copySize)
1774 cb.u.LowPart = 0;
1775 else
1776 cb.u.LowPart -= bytesRead;
1777 }
1778 if (pcbRead)
1779 {
1780 pcbRead->u.LowPart = totalBytesRead.u.LowPart;
1781 pcbRead->u.HighPart = totalBytesRead.u.HighPart;
1782 }
1783
1784 if (pcbWritten)
1785 {
1786 pcbWritten->u.LowPart = totalBytesWritten.u.LowPart;
1787 pcbWritten->u.HighPart = totalBytesWritten.u.HighPart;
1788 }
1789 return hr;
1790}
GLenum GLsizei GLuint GLint * bytesWritten
Definition: glext.h:11123
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
HRESULT hr
Definition: shlfolder.c:183
uint32_t ULONG
Definition: typedefs.h:59
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571
#define STG_E_MEDIUMFULL
Definition: winerror.h:2581
unsigned char BYTE
Definition: xxhash.c:193

◆ NoStatStreamImpl_Destroy()

static void NoStatStreamImpl_Destroy ( NoStatStreamImpl This)
static

Definition at line 1597 of file olepicture.c.

1598{
1599 GlobalFree(This->supportHandle);
1600 This->supportHandle=0;
1602}
#define HeapFree(x, y, z)
Definition: compat.h:735
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611

Referenced by NoStatStreamImpl_Release().

◆ NoStatStreamImpl_LockRegion()

static HRESULT WINAPI NoStatStreamImpl_LockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 1798 of file olepicture.c.

1803{
1804 return S_OK;
1805}

◆ NoStatStreamImpl_QueryInterface()

static HRESULT WINAPI NoStatStreamImpl_QueryInterface ( IStream iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1611 of file olepicture.c.

1615{
1616 NoStatStreamImpl* const This = impl_from_IStream(iface);
1617 if (ppvObject==0) return E_INVALIDARG;
1618 *ppvObject = 0;
1619
1620 if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IStream, riid))
1621 *ppvObject = &This->IStream_iface;
1622
1623 if ((*ppvObject)==0)
1624 return E_NOINTERFACE;
1626 return S_OK;
1627}
const GUID IID_IUnknown
#define E_INVALIDARG
Definition: ddrawi.h:101
REFIID riid
Definition: atlbase.h:39
static ULONG WINAPI NoStatStreamImpl_AddRef(IStream *iface)
Definition: olepicture.c:1604
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ NoStatStreamImpl_Read()

static HRESULT WINAPI NoStatStreamImpl_Read ( IStream iface,
void pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 1639 of file olepicture.c.

1644{
1645 NoStatStreamImpl* const This = impl_from_IStream(iface);
1646 void* supportBuffer;
1647 ULONG bytesReadBuffer;
1648 ULONG bytesToReadFromBuffer;
1649
1650 if (pcbRead==0)
1651 pcbRead = &bytesReadBuffer;
1652 bytesToReadFromBuffer = min( This->streamSize.u.LowPart - This->currentPosition.u.LowPart, cb);
1653 supportBuffer = GlobalLock(This->supportHandle);
1654 memcpy(pv, (char *) supportBuffer+This->currentPosition.u.LowPart, bytesToReadFromBuffer);
1655 This->currentPosition.u.LowPart+=bytesToReadFromBuffer;
1656 *pcbRead = bytesToReadFromBuffer;
1657 GlobalUnlock(This->supportHandle);
1658 if(*pcbRead == cb)
1659 return S_OK;
1660 return S_FALSE;
1661}
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
#define S_FALSE
Definition: winerror.h:2357

◆ NoStatStreamImpl_Release()

static ULONG WINAPI NoStatStreamImpl_Release ( IStream iface)
static

Definition at line 1629 of file olepicture.c.

1631{
1632 NoStatStreamImpl* const This = impl_from_IStream(iface);
1633 ULONG newRef = InterlockedDecrement(&This->ref);
1634 if (newRef==0)
1636 return newRef;
1637}
#define InterlockedDecrement
Definition: armddk.h:52
static void NoStatStreamImpl_Destroy(NoStatStreamImpl *This)
Definition: olepicture.c:1597

◆ NoStatStreamImpl_Revert()

static HRESULT WINAPI NoStatStreamImpl_Revert ( IStream iface)
static

Definition at line 1796 of file olepicture.c.

1796{ return S_OK; }

◆ NoStatStreamImpl_Seek()

static HRESULT WINAPI NoStatStreamImpl_Seek ( IStream iface,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER plibNewPosition 
)
static

Definition at line 1691 of file olepicture.c.

1696{
1697 NoStatStreamImpl* const This = impl_from_IStream(iface);
1698 ULARGE_INTEGER newPosition;
1699 switch (dwOrigin)
1700 {
1701 case STREAM_SEEK_SET:
1702 newPosition.u.HighPart = 0;
1703 newPosition.u.LowPart = 0;
1704 break;
1705 case STREAM_SEEK_CUR:
1706 newPosition = This->currentPosition;
1707 break;
1708 case STREAM_SEEK_END:
1709 newPosition = This->streamSize;
1710 break;
1711 default:
1712 return STG_E_INVALIDFUNCTION;
1713 }
1714 if (dlibMove.QuadPart < 0 && newPosition.QuadPart < -dlibMove.QuadPart)
1715 return STG_E_INVALIDFUNCTION;
1716 newPosition.QuadPart += dlibMove.QuadPart;
1717 if (plibNewPosition) *plibNewPosition = newPosition;
1718 This->currentPosition = newPosition;
1719 return S_OK;
1720}
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
LONGLONG QuadPart
Definition: typedefs.h:114
#define STG_E_INVALIDFUNCTION
Definition: winerror.h:2564

◆ NoStatStreamImpl_SetSize()

static HRESULT WINAPI NoStatStreamImpl_SetSize ( IStream iface,
ULARGE_INTEGER  libNewSize 
)
static

Definition at line 1722 of file olepicture.c.

1725{
1726 NoStatStreamImpl* const This = impl_from_IStream(iface);
1727 HGLOBAL supportHandle;
1728 if (libNewSize.u.HighPart != 0)
1729 return STG_E_INVALIDFUNCTION;
1730 if (This->streamSize.u.LowPart == libNewSize.u.LowPart)
1731 return S_OK;
1732 supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.u.LowPart, 0);
1733 if (supportHandle == 0)
1734 return STG_E_MEDIUMFULL;
1735 This->supportHandle = supportHandle;
1736 This->streamSize.u.LowPart = libNewSize.u.LowPart;
1737 return S_OK;
1738}
HGLOBAL NTAPI GlobalReAlloc(HGLOBAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:825

◆ NoStatStreamImpl_Stat()

static HRESULT WINAPI NoStatStreamImpl_Stat ( IStream iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 1816 of file olepicture.c.

1820{
1821 return E_NOTIMPL;
1822}

◆ NoStatStreamImpl_UnlockRegion()

static HRESULT WINAPI NoStatStreamImpl_UnlockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 1807 of file olepicture.c.

1812{
1813 return S_OK;
1814}

◆ NoStatStreamImpl_Write()

static HRESULT WINAPI NoStatStreamImpl_Write ( IStream iface,
const void pv,
ULONG  cb,
ULONG pcbWritten 
)
static

Definition at line 1663 of file olepicture.c.

1668{
1669 NoStatStreamImpl* const This = impl_from_IStream(iface);
1670 void* supportBuffer;
1671 ULARGE_INTEGER newSize;
1672 ULONG bytesWritten = 0;
1673
1674 if (pcbWritten == 0)
1675 pcbWritten = &bytesWritten;
1676 if (cb == 0)
1677 return S_OK;
1678 newSize.u.HighPart = 0;
1679 newSize.u.LowPart = This->currentPosition.u.LowPart + cb;
1680 if (newSize.u.LowPart > This->streamSize.u.LowPart)
1681 IStream_SetSize(iface, newSize);
1682
1683 supportBuffer = GlobalLock(This->supportHandle);
1684 memcpy((char *) supportBuffer+This->currentPosition.u.LowPart, pv, cb);
1685 This->currentPosition.u.LowPart+=cb;
1686 *pcbWritten = cb;
1687 GlobalUnlock(This->supportHandle);
1688 return S_OK;
1689}

◆ picture_render()

static HRESULT picture_render ( IPicture iface,
HDC  hdc,
LONG  x,
LONG  y,
LONG  cx,
LONG  cy,
OLE_XPOS_HIMETRIC  xSrc,
OLE_YPOS_HIMETRIC  ySrc,
OLE_XSIZE_HIMETRIC  cxSrc,
OLE_YSIZE_HIMETRIC  cySrc,
const RECT bounds 
)
static

Definition at line 756 of file olepicture.c.

762{
763 VARIANT ret, args[10];
764 HRESULT hr, hr_disp;
766 IDispatch *disp;
767 int i;
768
769 hr = IPicture_Render(iface, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, bounds);
770
771 IPicture_QueryInterface(iface, &IID_IDispatch, (void**)&disp);
772
773 /* This is broken on 64 bits - accepted pointer argument type is still VT_I4 */
774 for (i = 0; i < ARRAY_SIZE(args); i++)
775 V_VT(&args[i]) = VT_I4;
776
777 /* pack arguments and call */
778 V_INT_PTR(&args[0]) = (INT_PTR)bounds;
779 V_I4(&args[1]) = cySrc;
780 V_I4(&args[2]) = cxSrc;
781 V_I4(&args[3]) = ySrc;
782 V_I4(&args[4]) = xSrc;
783 V_I4(&args[5]) = cy;
784 V_I4(&args[6]) = cx;
785 V_I4(&args[7]) = y;
786 V_I4(&args[8]) = x;
787 V_I4(&args[9]) = HandleToLong(hdc);
788
789 params.rgvarg = args;
790 params.rgdispidNamedArgs = NULL;
791 params.cArgs = 10;
792 params.cNamedArgs = 0;
793
794 V_VT(&ret) = VT_EMPTY;
795 hr_disp = IDispatch_Invoke(disp, DISPID_PICT_RENDER, &GUID_NULL, 0, DISPATCH_METHOD,
796 &params, &ret, NULL, NULL);
797 ok(hr == hr_disp, "DISPID_PICT_RENDER returned wrong code, 0x%08x, expected 0x%08x\n",
798 hr_disp, hr);
799
800 IDispatch_Release(disp);
801
802 return hr;
803}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define HandleToLong(h)
Definition: basetsd.h:80
@ VT_I4
Definition: compat.h:2298
@ VT_EMPTY
Definition: compat.h:2295
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLenum const GLfloat * params
Definition: glext.h:5645
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GUID_NULL
Definition: ks.h:106
struct stdole::DISPPARAMS DISPPARAMS
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define V_VT(A)
Definition: oleauto.h:211
#define V_INT_PTR(A)
Definition: oleauto.h:257
#define V_I4(A)
Definition: oleauto.h:247
#define DISPID_PICT_RENDER
Definition: olectl.h:443
const GUID IID_IDispatch
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define args
Definition: format.c:66
Definition: match.c:390
int32_t INT_PTR
Definition: typedefs.h:64
int ret

Referenced by test_Render().

◆ START_TEST()

START_TEST ( olepicture  )

Definition at line 1545 of file olepicture.c.

1546{
1547 hOleaut32 = GetModuleHandleA("oleaut32.dll");
1548 pOleLoadPicture = (void*)GetProcAddress(hOleaut32, "OleLoadPicture");
1549 pOleLoadPictureEx = (void*)GetProcAddress(hOleaut32, "OleLoadPictureEx");
1550 if (!pOleLoadPicture)
1551 {
1552 win_skip("OleLoadPicture is not available\n");
1553 return;
1554 }
1555
1556 /* Test regular 1x1 pixel images of gif, jpg, bmp type */
1557 test_pic(gifimage, sizeof(gifimage));
1558 test_pic(jpgimage, sizeof(jpgimage));
1559 test_pic(bmpimage, sizeof(bmpimage));
1561 test_pic(gif4pixel, sizeof(gif4pixel));
1562 /* FIXME: No PNG support in Windows... */
1563 if (0) test_pic(pngimage, sizeof(pngimage));
1566 if (pOleLoadPictureEx)
1567 {
1568 test_apm();
1569 test_metafile();
1571 }
1572 else
1573 win_skip("OleLoadPictureEx is not available\n");
1574 test_Invoke();
1576 test_Render();
1579 test_get_Type();
1581 test_himetric();
1586}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_metafile(void)
Definition: olepicture.c:701
static void test_himetric(void)
Definition: olepicture.c:1136
static void test_load_save_empty_picture(void)
Definition: olepicture.c:1353
static HMODULE hOleaut32
Definition: olepicture.c:56
static void test_Render(void)
Definition: olepicture.c:805
static void test_empty_image_2(void)
Definition: olepicture.c:402
static const unsigned char gifimage[35]
Definition: olepicture.c:64
static void test_get_Attributes(void)
Definition: olepicture.c:899
static void test_Invoke(void)
Definition: olepicture.c:441
static void test_load_save_icon(void)
Definition: olepicture.c:1280
static const unsigned char bmpimage[66]
Definition: olepicture.c:104
static const unsigned char bmpimage_rle8[]
Definition: olepicture.c:113
static void test_get_Handle(void)
Definition: olepicture.c:923
static void test_get_Type(void)
Definition: olepicture.c:936
static void test_load_save_bmp(void)
Definition: olepicture.c:1208
static void test_OleLoadPicturePath(void)
Definition: olepicture.c:950
static void test_OleCreatePictureIndirect(void)
Definition: olepicture.c:601
static const unsigned char pngimage[285]
Definition: olepicture.c:93
static void test_enhmetafile(void)
Definition: olepicture.c:719
static const unsigned char jpgimage[285]
Definition: olepicture.c:71
static void test_load_save_emf(void)
Definition: olepicture.c:1462
static void test_empty_image(void)
Definition: olepicture.c:355
static void test_apm(void)
Definition: olepicture.c:663
static const unsigned char gif4pixel[42]
Definition: olepicture.c:122
static void test_pic(const unsigned char *imgdata, unsigned int imgsize)
Definition: olepicture.c:288
#define win_skip
Definition: test.h:163

◆ test_apm()

static void test_apm ( void  )
static

Definition at line 663 of file olepicture.c.

664{
667 IPicture *pict;
668 HGLOBAL hglob;
669 LPBYTE *data;
670 LONG cxy;
671 BOOL keep;
672 short type;
673
674 hglob = GlobalAlloc (0, sizeof(apmdata));
675 data = GlobalLock(hglob);
676 memcpy(data, apmdata, sizeof(apmdata));
677
679 ole_check(pOleLoadPictureEx(stream, sizeof(apmdata), TRUE, &IID_IPicture, 100, 100, 0, (LPVOID *)&pict));
680
681 ole_check(IPicture_get_Handle(pict, &handle));
682 ok(handle != 0, "handle is null\n");
683
684 ole_check(IPicture_get_Type(pict, &type));
685 expect_eq(type, PICTYPE_METAFILE, short, "%d");
686
687 ole_check(IPicture_get_Height(pict, &cxy));
688 expect_eq(cxy, 1667, LONG, "%d");
689
690 ole_check(IPicture_get_Width(pict, &cxy));
691 expect_eq(cxy, 1323, LONG, "%d");
692
693 ole_check(IPicture_get_KeepOriginalFormat(pict, &keep));
694 todo_wine expect_eq(keep, FALSE, LONG, "%d");
695
696 ole_expect(IPicture_get_hPal(pict, &handle), E_FAIL);
697 IPicture_Release(pict);
698 IStream_Release(stream);
699}
#define E_FAIL
Definition: ddrawi.h:102
#define FALSE
Definition: types.h:117
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define todo_wine
Definition: custom.c:89
static const unsigned char apmdata[]
Definition: olepicture.c:130
#define expect_eq(expr, value, type, format)
Definition: olepicture.c:47
#define ole_expect(expr, expect)
Definition: olepicture.c:49
#define ole_check(expr)
Definition: olepicture.c:54
int OLE_HANDLE
Definition: olepro.idl:76
interface IStream * LPSTREAM
Definition: objfwd.h:10
long LONG
Definition: pedump.c:60
Definition: parse.h:23
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by START_TEST().

◆ test_empty_image()

static void test_empty_image ( void  )
static

Definition at line 355 of file olepicture.c.

355 {
356 LPBYTE data;
358 IPicture* pic = NULL;
360 LPVOID pvObj = NULL;
361 HGLOBAL hglob;
363 ULARGE_INTEGER newpos1;
365 short type;
366 DWORD attr;
367
368 /* Empty image. Happens occasionally in VB programs. */
369 hglob = GlobalAlloc (0, 8);
370 data = GlobalLock (hglob);
371 memcpy(data,"lt\0\0",4);
372 ((DWORD*)data)[1] = 0;
374 ok (hres == S_OK, "CreatestreamOnHGlobal failed? doubt it... hres 0x%08x\n", hres);
375
376 memset(&seekto,0,sizeof(seekto));
377 hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1);
378 ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08x\n", hres);
379
380 pvObj = NULL;
381 hres = pOleLoadPicture(stream, 8, TRUE, &IID_IPicture, &pvObj);
382 pic = pvObj;
383 ok(hres == S_OK,"empty picture not loaded, hres 0x%08x\n", hres);
384 ok(pic != NULL,"empty picture not loaded, pic is NULL\n");
385
386 hres = IPicture_get_Type (pic, &type);
387 ok (hres == S_OK,"empty picture get type failed with hres 0x%08x\n", hres);
388 ok (type == PICTYPE_NONE,"type is %d, but should be PICTYPE_NONE(0)\n", type);
389
390 attr = 0xdeadbeef;
391 hres = IPicture_get_Attributes (pic, &attr);
392 ok (hres == S_OK,"empty picture get attributes failed with hres 0x%08x\n", hres);
393 ok (attr == 0,"attr is %d, but should be 0\n", attr);
394
395 hres = IPicture_get_Handle (pic, &handle);
396 ok (hres == S_OK,"empty picture get handle failed with hres 0x%08x\n", hres);
397 ok (handle == 0, "empty picture get handle did not return 0, but 0x%08x\n", handle);
398 IPicture_Release (pic);
399 IStream_Release (stream);
400}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define seekto(pos, errstr)
Definition: mkdosfs.c:1613
#define SEEK_CUR
Definition: util.h:63
HRESULT hres
Definition: protocol.c:465
#define memset(x, y, z)
Definition: compat.h:39
Definition: cookie.c:202

Referenced by START_TEST().

◆ test_empty_image_2()

static void test_empty_image_2 ( void  )
static

Definition at line 402 of file olepicture.c.

402 {
403 LPBYTE data;
405 IPicture* pic = NULL;
407 LPVOID pvObj = NULL;
408 HGLOBAL hglob;
409 ULARGE_INTEGER newpos1;
411 short type;
412
413 /* Empty image at random stream position. */
414 hglob = GlobalAlloc (0, 200);
415 data = GlobalLock (hglob);
416 data += 42;
417 memcpy(data,"lt\0\0",4);
418 ((DWORD*)data)[1] = 0;
420 ok (hres == S_OK, "CreatestreamOnHGlobal failed? doubt it... hres 0x%08x\n", hres);
421
422 memset(&seekto,0,sizeof(seekto));
423 seekto.u.LowPart = 42;
424 hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1);
425 ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08x\n", hres);
426
427 pvObj = NULL;
428 hres = pOleLoadPicture(stream, 8, TRUE, &IID_IPicture, &pvObj);
429 pic = pvObj;
430 ok(hres == S_OK,"empty picture not loaded, hres 0x%08x\n", hres);
431 ok(pic != NULL,"empty picture not loaded, pic is NULL\n");
432
433 hres = IPicture_get_Type (pic, &type);
434 ok (hres == S_OK,"empty picture get type failed with hres 0x%08x\n", hres);
435 ok (type == PICTYPE_NONE,"type is %d, but should be PICTYPE_NONE(0)\n", type);
436
437 IPicture_Release (pic);
438 IStream_Release (stream);
439}

Referenced by START_TEST().

◆ test_enhmetafile()

static void test_enhmetafile ( void  )
static

Definition at line 719 of file olepicture.c.

720{
723 IPicture *pict;
724 HGLOBAL hglob;
725 LPBYTE *data;
726 LONG cxy;
727 BOOL keep;
728 short type;
729
730 hglob = GlobalAlloc (0, sizeof(enhmetafile));
731 data = GlobalLock(hglob);
733
735 ole_check(pOleLoadPictureEx(stream, sizeof(enhmetafile), TRUE, &IID_IPicture, 10, 10, 0, (LPVOID *)&pict));
736
737 ole_check(IPicture_get_Handle(pict, &handle));
738 ok(handle != 0, "handle is null\n");
739
740 ole_check(IPicture_get_Type(pict, &type));
741 expect_eq(type, PICTYPE_ENHMETAFILE, short, "%d");
742
743 ole_check(IPicture_get_Height(pict, &cxy));
744 expect_eq(cxy, -23, LONG, "%d");
745
746 ole_check(IPicture_get_Width(pict, &cxy));
747 expect_eq(cxy, -25, LONG, "%d");
748
749 ole_check(IPicture_get_KeepOriginalFormat(pict, &keep));
750 todo_wine expect_eq(keep, FALSE, LONG, "%d");
751
752 IPicture_Release(pict);
753 IStream_Release(stream);
754}
static const unsigned char enhmetafile[]
Definition: olepicture.c:149

Referenced by START_TEST().

◆ test_get_Attributes()

static void test_get_Attributes ( void  )
static

Definition at line 899 of file olepicture.c.

900{
901 IPicture *pic;
903 short type;
904 DWORD attr;
905
907 ok(hres == S_OK, "Failed to create a picture, hr %#x.\n", hres);
908 hres = IPicture_get_Type(pic, &type);
909 ok(hres == S_OK, "IPicture_get_Type does not return S_OK, but 0x%08x\n", hres);
910 ok(type == PICTYPE_UNINITIALIZED, "Expected type = PICTYPE_UNINITIALIZED, got = %d\n", type);
911
912 hres = IPicture_get_Attributes(pic, NULL);
914
915 attr = 0xdeadbeef;
916 hres = IPicture_get_Attributes(pic, &attr);
918 ok(attr == 0, "IPicture_get_Attributes does not reset attr to zero, got %d\n", attr);
919
920 IPicture_Release(pic);
921}
#define E_POINTER
Definition: winerror.h:2365

Referenced by START_TEST().

◆ test_get_Handle()

static void test_get_Handle ( void  )
static

Definition at line 923 of file olepicture.c.

924{
925 IPicture *pic;
927
929 ok(hres == S_OK, "Failed to create a picture, hr %#x.\n", hres);
930 hres = IPicture_get_Handle(pic, NULL);
932
933 IPicture_Release(pic);
934}

Referenced by START_TEST().

◆ test_get_Type()

static void test_get_Type ( void  )
static

Definition at line 936 of file olepicture.c.

937{
938 IPicture *pic;
940
942 ok(hres == S_OK, "Failed to create a picture, hr %#x.\n", hres);
943
944 hres = IPicture_get_Type(pic, NULL);
946
947 IPicture_Release(pic);
948}

Referenced by START_TEST().

◆ test_himetric()

static void test_himetric ( void  )
static

Definition at line 1136 of file olepicture.c.

1137{
1138 static const BYTE bmp_bits[1024];
1141 IPicture *pic;
1142 PICTDESC desc;
1143 HBITMAP bmp;
1144 HRESULT hr;
1145 HICON icon;
1146 HDC hdc;
1147 INT d;
1148
1149 desc.cbSizeofstruct = sizeof(desc);
1150 desc.picType = PICTYPE_BITMAP;
1151 desc.bmp.hpal = NULL;
1152
1154
1156 1.9 * GetDeviceCaps(hdc, LOGPIXELSY), 1, 1, NULL);
1157
1158 desc.bmp.hbitmap = bmp;
1159
1160 /* size in himetric units reported rounded up to next integer value */
1161 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic);
1162 ok(hr == S_OK, "got 0x%08x\n", hr);
1163
1164 cx = 0;
1166 hr = IPicture_get_Width(pic, &cx);
1167 ok(hr == S_OK, "got 0x%08x\n", hr);
1168 ok(cx == d, "got %d, expected %d\n", cx, d);
1169
1170 cy = 0;
1172 hr = IPicture_get_Height(pic, &cy);
1173 ok(hr == S_OK, "got 0x%08x\n", hr);
1174 ok(cy == d, "got %d, expected %d\n", cy, d);
1175
1177 IPicture_Release(pic);
1178
1179 /* same thing with icon */
1181 1, 1, bmp_bits, bmp_bits);
1182 ok(icon != NULL, "failed to create icon\n");
1183
1184 desc.picType = PICTYPE_ICON;
1185 desc.icon.hicon = icon;
1186
1187 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic);
1188 ok(hr == S_OK, "got 0x%08x\n", hr);
1189
1190 cx = 0;
1192 hr = IPicture_get_Width(pic, &cx);
1193 ok(hr == S_OK, "got 0x%08x\n", hr);
1194 ok(cx == d, "got %d, expected %d\n", cx, d);
1195
1196 cy = 0;
1198 hr = IPicture_get_Height(pic, &cy);
1199 ok(hr == S_OK, "got 0x%08x\n", hr);
1200 ok(cy == d, "got %d, expected %d\n", cy, d);
1201
1202 IPicture_Release(pic);
1203 DestroyIcon(icon);
1204
1205 DeleteDC(hdc);
1206}
#define d
Definition: ke_i.h:81
BITMAP bmp
Definition: alphablend.c:62
static HICON
Definition: imagelist.c:80
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
long OLE_XSIZE_HIMETRIC
Definition: olepro.idl:58
long OLE_YSIZE_HIMETRIC
Definition: olepro.idl:61
int32_t INT
Definition: typedefs.h:58
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719
#define LOGPIXELSX
Definition: wingdi.h:718
HICON WINAPI CreateIcon(_In_opt_ HINSTANCE, _In_ int, _In_ int, _In_ BYTE, _In_ BYTE, _In_ const BYTE *, _In_ const BYTE *)
Definition: cursoricon.c:2447
#define SM_CYICON
Definition: winuser.h:976
#define SM_CXICON
Definition: winuser.h:975
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2105

Referenced by START_TEST().

◆ test_Invoke()

static void test_Invoke ( void  )
static

Definition at line 441 of file olepicture.c.

442{
443 IPictureDisp *picdisp;
444 HRESULT hr;
445 VARIANTARG vararg, args[10];
446 DISPPARAMS dispparams;
447 VARIANT varresult;
449 HGLOBAL hglob;
450 void *data;
451 HDC hdc;
452 int i;
453
454 hglob = GlobalAlloc (0, sizeof(gifimage));
455 data = GlobalLock(hglob);
456 memcpy(data, gifimage, sizeof(gifimage));
457 GlobalUnlock(hglob);
458
460 ok_ole_success(hr, "CreateStreamOnHGlobal");
461
462 hr = pOleLoadPicture(stream, sizeof(gifimage), TRUE, &IID_IPictureDisp, (void **)&picdisp);
463 IStream_Release(stream);
464 GlobalFree(hglob);
465 ok_ole_success(hr, "OleLoadPicture");
466
467 V_VT(&vararg) = VT_BOOL;
468 V_BOOL(&vararg) = VARIANT_FALSE;
469 dispparams.cNamedArgs = 0;
470 dispparams.rgdispidNamedArgs = NULL;
471 dispparams.cArgs = 1;
472 dispparams.rgvarg = &vararg;
473 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_IPictureDisp, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
474 ok(hr == DISP_E_UNKNOWNNAME, "IPictureDisp_Invoke should have returned DISP_E_UNKNOWNNAME instead of 0x%08x\n", hr);
475 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_IUnknown, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
476 ok(hr == DISP_E_UNKNOWNNAME, "IPictureDisp_Invoke should have returned DISP_E_UNKNOWNNAME instead of 0x%08x\n", hr);
477
478 dispparams.cArgs = 0;
479 dispparams.rgvarg = NULL;
480 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
481 ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
482
483 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, NULL, NULL, NULL);
484 ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08x\n", hr);
485
486 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
487 ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08x\n", hr);
488
489 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, &varresult, NULL, NULL);
490 ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08x\n", hr);
491
492 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL);
493 ok_ole_success(hr, "IPictureDisp_Invoke");
494 ok(V_VT(&varresult) == VT_I4, "V_VT(&varresult) should have been VT_UINT instead of %d\n", V_VT(&varresult));
495
496 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
497 ok(hr == DISP_E_MEMBERNOTFOUND, "IPictureDisp_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
498
499 hr = IPictureDisp_Invoke(picdisp, 0xdeadbeef, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL);
500 ok(hr == DISP_E_MEMBERNOTFOUND, "IPictureDisp_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
501
502 dispparams.cArgs = 1;
503 dispparams.rgvarg = &vararg;
504 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL);
505 ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
506
507 dispparams.cArgs = 1;
508 dispparams.rgvarg = &vararg;
509 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL);
510 ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
511
512 /* DISPID_PICT_RENDER */
514
515 for (i = 0; i < ARRAY_SIZE(args); i++)
516 V_VT(&args[i]) = VT_I4;
517
518 V_I4(&args[0]) = 0;
519 V_I4(&args[1]) = 10;
520 V_I4(&args[2]) = 10;
521 V_I4(&args[3]) = 0;
522 V_I4(&args[4]) = 0;
523 V_I4(&args[5]) = 10;
524 V_I4(&args[6]) = 10;
525 V_I4(&args[7]) = 0;
526 V_I4(&args[8]) = 0;
527 V_I4(&args[9]) = HandleToLong(hdc);
528
529 dispparams.rgvarg = args;
530 dispparams.rgdispidNamedArgs = NULL;
531 dispparams.cArgs = 10;
532 dispparams.cNamedArgs = 0;
533
534 V_VT(&varresult) = VT_EMPTY;
535 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_RENDER, &GUID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
536 ok(hr == S_OK, "got 0x%08x\n", hr);
537
538 /* Try with one argument set to VT_I2, it'd still work if coerced. */
539 V_VT(&args[3]) = VT_I2;
540 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_RENDER, &GUID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
541 ok(hr == DISP_E_TYPEMISMATCH, "got 0x%08x\n", hr);
542 V_VT(&args[3]) = VT_I4;
543
544 /* Wrong argument count */
545 dispparams.cArgs = 9;
546 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_RENDER, &GUID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
547 ok(hr == DISP_E_BADPARAMCOUNT, "got 0x%08x\n", hr);
548
550 IPictureDisp_Release(picdisp);
551}
@ VT_BOOL
Definition: compat.h:2306
@ VT_I2
Definition: compat.h:2297
#define ok_ole_success(hr, func)
Definition: olepicture.c:61
static void delete_render_dc(HDC dc)
Definition: olepicture.c:196
static HDC create_render_dc(void)
Definition: olepicture.c:185
#define V_BOOL(A)
Definition: oleauto.h:224
#define DISPATCH_PROPERTYPUT
Definition: oleauto.h:1008
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define DISPID_PICT_HPAL
Definition: olectl.h:439
const GUID IID_IPictureDisp
#define IID_NULL
Definition: guiddef.h:98
#define DISP_E_BADPARAMCOUNT
Definition: winerror.h:2523
#define DISP_E_MEMBERNOTFOUND
Definition: winerror.h:2512
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
#define DISP_E_PARAMNOTOPTIONAL
Definition: winerror.h:2524
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515

Referenced by START_TEST().

◆ test_load_save_bmp()

static void test_load_save_bmp ( void  )
static

Definition at line 1208 of file olepicture.c.

1209{
1210 IPicture *pic;
1211 PICTDESC desc;
1212 short type;
1214 HGLOBAL hmem;
1215 DWORD *mem;
1216 IPersistStream *src_stream;
1217 IStream *dst_stream;
1219 HRESULT hr;
1220 LONG size;
1221
1222 desc.cbSizeofstruct = sizeof(desc);
1223 desc.picType = PICTYPE_BITMAP;
1224 desc.bmp.hpal = 0;
1225 desc.bmp.hbitmap = CreateBitmap(1, 1, 1, 1, NULL);
1226 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic);
1227 ok(hr == S_OK, "OleCreatePictureIndirect error %#x\n", hr);
1228
1229 type = -1;
1230 hr = IPicture_get_Type(pic, &type);
1231 ok(hr == S_OK,"get_Type error %#8x\n", hr);
1232 ok(type == PICTYPE_BITMAP,"expected picture type PICTYPE_BITMAP, got %d\n", type);
1233
1234 hr = IPicture_get_Handle(pic, &handle);
1235 ok(hr == S_OK,"get_Handle error %#8x\n", hr);
1236 ok(IntToPtr(handle) == desc.bmp.hbitmap, "get_Handle returned wrong handle %#x\n", handle);
1237
1238 hmem = GlobalAlloc(GMEM_ZEROINIT, 4096);
1239 hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream);
1240 ok(hr == S_OK, "createstreamonhglobal error %#x\n", hr);
1241
1242 size = -1;
1243 hr = IPicture_SaveAsFile(pic, dst_stream, TRUE, &size);
1244 ok(hr == S_OK, "IPicture_SaveasFile error %#x\n", hr);
1245 ok(size == 66, "expected 66, got %d\n", size);
1246 mem = GlobalLock(hmem);
1247 ok(!memcmp(&mem[0], "BM", 2), "got wrong bmp header %04x\n", mem[0]);
1248 GlobalUnlock(hmem);
1249
1250 size = -1;
1251 hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
1252 ok(hr == E_FAIL, "expected E_FAIL, got %#x\n", hr);
1253 ok(size == -1, "expected -1, got %d\n", size);
1254
1255 offset.QuadPart = 0;
1256 hr = IStream_Seek(dst_stream, offset, SEEK_SET, NULL);
1257 ok(hr == S_OK, "IStream_Seek %#x\n", hr);
1258
1259 hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream);
1260 ok(hr == S_OK, "QueryInterface error %#x\n", hr);
1261
1262 hr = IPersistStream_Save(src_stream, dst_stream, TRUE);
1263 ok(hr == S_OK, "Save error %#x\n", hr);
1264
1265 IPersistStream_Release(src_stream);
1266 IStream_Release(dst_stream);
1267
1268 mem = GlobalLock(hmem);
1269 ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04x\n", mem[0]);
1270 ok(mem[1] == 66, "expected stream size 66, got %u\n", mem[1]);
1271 ok(!memcmp(&mem[2], "BM", 2), "got wrong bmp header %04x\n", mem[2]);
1272
1273 GlobalUnlock(hmem);
1274 GlobalFree(hmem);
1275
1276 DeleteObject(desc.bmp.hbitmap);
1277 IPicture_Release(pic);
1278}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define IntToPtr(i)
Definition: basetsd.h:89
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
#define SEEK_SET
Definition: jmemansi.c:26
const GUID IID_IPersistStream
Definition: proxy.cpp:13
Definition: mem.c:349
#define GMEM_ZEROINIT
Definition: winbase.h:332

Referenced by START_TEST().

◆ test_load_save_emf()

static void test_load_save_emf ( void  )
static

Definition at line 1462 of file olepicture.c.

1463{
1464 HDC hdc;
1465 IPicture *pic;
1466 PICTDESC desc;
1467 short type;
1469 HGLOBAL hmem;
1470 DWORD *mem;
1471 ENHMETAHEADER *emh;
1472 IPersistStream *src_stream;
1473 IStream *dst_stream;
1475 HRESULT hr;
1476 LONG size;
1477
1479 ok(hdc != 0, "CreateEnhMetaFileA failed\n");
1480
1481 desc.cbSizeofstruct = sizeof(desc);
1482 desc.picType = PICTYPE_ENHMETAFILE;
1483 desc.emf.hemf = CloseEnhMetaFile(hdc);
1484 ok(desc.emf.hemf != 0, "CloseEnhMetaFile failed\n");
1485 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic);
1486 ok(hr == S_OK, "OleCreatePictureIndirect error %#x\n", hr);
1487
1488 type = -1;
1489 hr = IPicture_get_Type(pic, &type);
1490 ok(hr == S_OK,"get_Type error %#8x\n", hr);
1491 ok(type == PICTYPE_ENHMETAFILE,"expected PICTYPE_ENHMETAFILE, got %d\n", type);
1492
1493 hr = IPicture_get_Handle(pic, &handle);
1494 ok(hr == S_OK,"get_Handle error %#8x\n", hr);
1495 ok(IntToPtr(handle) == desc.emf.hemf, "get_Handle returned wrong handle %#x\n", handle);
1496
1497 hmem = GlobalAlloc(GMEM_MOVEABLE, 0);
1498 hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream);
1499 ok(hr == S_OK, "createstreamonhglobal error %#x\n", hr);
1500
1501 size = -1;
1502 hr = IPicture_SaveAsFile(pic, dst_stream, TRUE, &size);
1503 ok(hr == S_OK, "IPicture_SaveasFile error %#x\n", hr);
1504 ok(size == 128, "expected 128, got %d\n", size);
1505 emh = GlobalLock(hmem);
1506if (size)
1507{
1508 ok(emh->iType == EMR_HEADER, "wrong iType %04x\n", emh->iType);
1509 ok(emh->dSignature == ENHMETA_SIGNATURE, "wrong dSignature %08x\n", emh->dSignature);
1510}
1511 GlobalUnlock(hmem);
1512
1513 size = -1;
1514 hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
1515 ok(hr == E_FAIL, "expected E_FAIL, got %#x\n", hr);
1516 ok(size == -1, "expected -1, got %d\n", size);
1517
1518 offset.QuadPart = 0;
1519 hr = IStream_Seek(dst_stream, offset, SEEK_SET, NULL);
1520 ok(hr == S_OK, "IStream_Seek %#x\n", hr);
1521
1522 hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream);
1523 ok(hr == S_OK, "QueryInterface error %#x\n", hr);
1524
1525 hr = IPersistStream_Save(src_stream, dst_stream, TRUE);
1526 ok(hr == S_OK, "Save error %#x\n", hr);
1527
1528 IPersistStream_Release(src_stream);
1529 IStream_Release(dst_stream);
1530
1531 mem = GlobalLock(hmem);
1532 ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04x\n", mem[0]);
1533 ok(mem[1] == 128, "expected 128, got %u\n", mem[1]);
1534 emh = (ENHMETAHEADER *)(mem + 2);
1535 ok(emh->iType == EMR_HEADER, "wrong iType %04x\n", emh->iType);
1536 ok(emh->dSignature == ENHMETA_SIGNATURE, "wrong dSignature %08x\n", emh->dSignature);
1537
1538 GlobalUnlock(hmem);
1539 GlobalFree(hmem);
1540
1541 DeleteEnhMetaFile(desc.emf.hemf);
1542 IPicture_Release(pic);
1543}
DWORD dSignature
Definition: wingdi.h:2324
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
#define ENHMETA_SIGNATURE
Definition: wingdi.h:204
#define EMR_HEADER
Definition: wingdi.h:75

Referenced by START_TEST().

◆ test_load_save_empty_picture()

static void test_load_save_empty_picture ( void  )
static

Definition at line 1353 of file olepicture.c.

1354{
1355 IPicture *pic;
1356 PICTDESC desc;
1357 short type;
1359 HGLOBAL hmem;
1360 DWORD *mem;
1361 IPersistStream *src_stream;
1362 IStream *dst_stream, *stream;
1364 HRESULT hr;
1365 LONG size;
1366
1367 memset(&pic, 0, sizeof(pic));
1368 desc.cbSizeofstruct = sizeof(desc);
1369 desc.picType = PICTYPE_NONE;
1370 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void **)&pic);
1371 ok(hr == S_OK, "OleCreatePictureIndirect error %#x\n", hr);
1372
1373 type = -1;
1374 hr = IPicture_get_Type(pic, &type);
1375 ok(hr == S_OK, "get_Type error %#x\n", hr);
1376 ok(type == PICTYPE_NONE,"expected picture type PICTYPE_NONE, got %d\n", type);
1377
1378 handle = (OLE_HANDLE)0xdeadbeef;
1379 hr = IPicture_get_Handle(pic, &handle);
1380 ok(hr == S_OK,"get_Handle error %#8x\n", hr);
1381 ok(!handle, "get_Handle returned wrong handle %#x\n", handle);
1382
1383 hmem = GlobalAlloc(GMEM_ZEROINIT, 4096);
1384 hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream);
1385 ok(hr == S_OK, "createstreamonhglobal error %#x\n", hr);
1386
1387 size = -1;
1388 hr = IPicture_SaveAsFile(pic, dst_stream, TRUE, &size);
1389 ok(hr == S_OK, "IPicture_SaveasFile error %#x\n", hr);
1390 ok(size == -1, "expected -1, got %d\n", size);
1391
1392 size = -1;
1393 hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
1394 ok(hr == S_OK, "IPicture_SaveasFile error %#x\n", hr);
1395 ok(size == -1, "expected -1, got %d\n", size);
1396
1397 hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream);
1398 ok(hr == S_OK, "QueryInterface error %#x\n", hr);
1399
1400 hr = IPersistStream_Save(src_stream, dst_stream, TRUE);
1401 ok(hr == S_OK, "Save error %#x\n", hr);
1402
1403 mem = GlobalLock(hmem);
1404 ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04x\n", mem[0]);
1405 ok(mem[1] == 0, "expected stream size 0, got %u\n", mem[1]);
1406 GlobalUnlock(hmem);
1407
1408 IPersistStream_Release(src_stream);
1409 IPicture_Release(pic);
1410
1411 /* first with statable and seekable stream */
1412 offset.QuadPart = 0;
1413 hr = IStream_Seek(dst_stream, offset, SEEK_SET, NULL);
1414 ok(hr == S_OK, "IStream_Seek %#x\n", hr);
1415
1416 pic = NULL;
1417 hr = pOleLoadPicture(dst_stream, 0, FALSE, &IID_IPicture, (void **)&pic);
1418 ok(hr == S_OK, "OleLoadPicture error %#x\n", hr);
1419 ok(pic != NULL,"picture should not be not NULL\n");
1420 if (pic != NULL)
1421 {
1422 type = -1;
1423 hr = IPicture_get_Type(pic, &type);
1424 ok(hr == S_OK,"get_Type error %#8x\n", hr);
1425 ok(type == PICTYPE_NONE,"expected picture type PICTYPE_NONE, got %d\n", type);
1426
1427 handle = (OLE_HANDLE)0xdeadbeef;
1428 hr = IPicture_get_Handle(pic, &handle);
1429 ok(hr == S_OK,"get_Handle error %#8x\n", hr);
1430 ok(!handle, "get_Handle returned wrong handle %#x\n", handle);
1431
1432 IPicture_Release(pic);
1433 }
1434 IStream_Release(dst_stream);
1435
1436 /* again with non-statable and non-seekable stream */
1438 ok(stream != NULL, "failed to create empty image stream\n");
1439
1440 pic = NULL;
1441 hr = pOleLoadPicture(stream, 0, FALSE, &IID_IPicture, (void **)&pic);
1442 ok(hr == S_OK, "OleLoadPicture error %#x\n", hr);
1443 ok(pic != NULL,"picture should not be not NULL\n");
1444 if (pic != NULL)
1445 {
1446 type = -1;
1447 hr = IPicture_get_Type(pic, &type);
1448 ok(hr == S_OK,"get_Type error %#8x\n", hr);
1449 ok(type == PICTYPE_NONE,"expected picture type PICTYPE_NONE, got %d\n", type);
1450
1451 handle = (OLE_HANDLE)0xdeadbeef;
1452 hr = IPicture_get_Handle(pic, &handle);
1453 ok(hr == S_OK,"get_Handle error %#8x\n", hr);
1454 ok(!handle, "get_Handle returned wrong handle %#x\n", handle);
1455
1456 IPicture_Release(pic);
1457 }
1458 /* Non-statable impl always deletes on release */
1459 IStream_Release(stream);
1460}
static IStream * NoStatStream_Construct(HGLOBAL hGlobal)
Definition: olepicture.c:1839

Referenced by START_TEST().

◆ test_load_save_icon()

static void test_load_save_icon ( void  )
static

Definition at line 1280 of file olepicture.c.

1281{
1282 IPicture *pic;
1283 PICTDESC desc;
1284 short type;
1286 HGLOBAL hmem;
1287 DWORD *mem;
1288 IPersistStream *src_stream;
1289 IStream *dst_stream;
1291 HRESULT hr;
1292 LONG size;
1293
1294 desc.cbSizeofstruct = sizeof(desc);
1295 desc.picType = PICTYPE_ICON;
1296 desc.icon.hicon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
1297 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic);
1298 ok(hr == S_OK, "OleCreatePictureIndirect error %#x\n", hr);
1299
1300 type = -1;
1301 hr = IPicture_get_Type(pic, &type);
1302 ok(hr == S_OK,"get_Type error %#8x\n", hr);
1303 ok(type == PICTYPE_ICON,"expected picture type PICTYPE_ICON, got %d\n", type);
1304
1305 hr = IPicture_get_Handle(pic, &handle);
1306 ok(hr == S_OK,"get_Handle error %#8x\n", hr);
1307 ok(IntToPtr(handle) == desc.icon.hicon, "get_Handle returned wrong handle %#x\n", handle);
1308
1309 hmem = GlobalAlloc(GMEM_ZEROINIT, 8192);
1310 hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream);
1311 ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr);
1312
1313 size = -1;
1314 hr = IPicture_SaveAsFile(pic, dst_stream, TRUE, &size);
1315 ok(hr == S_OK, "IPicture_SaveasFile error %#x\n", hr);
1317 ok(size == 766, "expected 766, got %d\n", size);
1318 mem = GlobalLock(hmem);
1319 ok(mem[0] == 0x00010000, "got wrong icon header %04x\n", mem[0]);
1320 GlobalUnlock(hmem);
1321
1322 size = -1;
1323 hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
1324 ok(hr == E_FAIL, "expected E_FAIL, got %#x\n", hr);
1325 ok(size == -1, "expected -1, got %d\n", size);
1326
1327 offset.QuadPart = 0;
1328 hr = IStream_Seek(dst_stream, offset, SEEK_SET, NULL);
1329 ok(hr == S_OK, "IStream_Seek %#x\n", hr);
1330
1331 hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream);
1332 ok(hr == S_OK, "QueryInterface error %#x\n", hr);
1333
1334 hr = IPersistStream_Save(src_stream, dst_stream, TRUE);
1335 ok(hr == S_OK, "Saveerror %#x\n", hr);
1336
1337 IPersistStream_Release(src_stream);
1338 IStream_Release(dst_stream);
1339
1340 mem = GlobalLock(hmem);
1341 ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04x\n", mem[0]);
1343 ok(mem[1] == 766, "expected stream size 766, got %u\n", mem[1]);
1344 ok(mem[2] == 0x00010000, "got wrong icon header %04x\n", mem[2]);
1345
1346 GlobalUnlock(hmem);
1347 GlobalFree(hmem);
1348
1349 DestroyIcon(desc.icon.hicon);
1350 IPicture_Release(pic);
1351}

Referenced by START_TEST().

◆ test_metafile()

static void test_metafile ( void  )
static

Definition at line 701 of file olepicture.c.

702{
704 IPicture *pict;
705 HGLOBAL hglob;
706 LPBYTE *data;
707
708 hglob = GlobalAlloc (0, sizeof(metafile));
709 data = GlobalLock(hglob);
710 memcpy(data, metafile, sizeof(metafile));
711
713 /* Windows does not load simple metafiles */
714 ole_expect(pOleLoadPictureEx(stream, sizeof(metafile), TRUE, &IID_IPicture, 100, 100, 0, (LPVOID *)&pict), E_FAIL);
715
716 IStream_Release(stream);
717}
static const unsigned char metafile[]
Definition: olepicture.c:138

Referenced by START_TEST().

◆ test_OleCreatePictureIndirect()

static void test_OleCreatePictureIndirect ( void  )
static

Definition at line 601 of file olepicture.c.

602{
605 IPicture *pict;
606 HRESULT hr;
607 short type, i;
608
609if (0)
610{
611 /* crashes on native */
613}
614
615 desc.cbSizeofstruct = sizeof(desc);
616 desc.picType = PICTYPE_UNINITIALIZED;
617 pict = (void *)0xdeadbeef;
618 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (void **)&pict);
619 ok(hr == E_UNEXPECTED, "got %#x\n", hr);
620 ok(pict == NULL, "got %p\n", pict);
621
623 {
624 hr = create_picture(i, &pict);
625 ok(hr == S_OK, "%d: got %#x\n", i, hr);
626
627 type = 0xdead;
628 hr = IPicture_get_Type(pict, &type);
629 ok(hr == S_OK, "%d: got %#x\n", i, hr);
630 ok(type == i, "%d: got %d\n", i, type);
631
632 handle = 0xdeadbeef;
633 hr = IPicture_get_Handle(pict, &handle);
634 ok(hr == S_OK, "%d: got %#x\n", i, hr);
636 ok(handle == 0, "%d: got %#x\n", i, handle);
637 else
638 ok(handle != 0 && handle != 0xdeadbeef, "%d: got %#x\n", i, handle);
639
640 handle = 0xdeadbeef;
641 hr = IPicture_get_hPal(pict, &handle);
642 if (type == PICTYPE_BITMAP)
643 {
644 ok(hr == S_OK, "%d: got %#x\n", i, hr);
645 ok(handle == 0xbeefdead, "%d: got %#x\n", i, handle);
646 }
647 else
648 {
649 ok(hr == E_FAIL, "%d: got %#x\n", i, hr);
650 ok(handle == 0xdeadbeef || handle == 0 /* win64 */, "%d: got %#x\n", i, handle);
651 }
652
653 hr = IPicture_set_hPal(pict, HandleToUlong(GetStockObject(DEFAULT_PALETTE)));
654 if (type == PICTYPE_BITMAP)
655 ok(hr == S_OK, "%d: got %#x\n", i, hr);
656 else
657 ok(hr == E_FAIL, "%d: got %#x\n", i, hr);
658
659 IPicture_Release(pict);
660 }
661}
#define HandleToUlong(h)
Definition: basetsd.h:79
static HRESULT create_picture(short type, IPicture **pict)
Definition: olepicture.c:553
#define E_UNEXPECTED
Definition: winerror.h:2456
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DEFAULT_PALETTE
Definition: wingdi.h:913

Referenced by START_TEST().

◆ test_OleLoadPicturePath()

static void test_OleLoadPicturePath ( void  )
static

Definition at line 950 of file olepicture.c.

951{
952 static WCHAR emptyW[] = {0};
953
954 IPicture *pic;
956 int i;
957 char temp_path[MAX_PATH];
958 char temp_file[MAX_PATH];
959 WCHAR temp_fileW[MAX_PATH + 5] = {'f','i','l','e',':','/','/','/'};
960 HANDLE file;
961 DWORD size;
962 WCHAR *ptr;
963 VARIANT var;
964
965 const struct
966 {
967 LPOLESTR szURLorPath;
968 REFIID riid;
969 IPicture **pic;
970 } invalid_parameters[] =
971 {
972 {NULL, NULL, NULL},
973 {NULL, NULL, &pic},
975 {NULL, &IID_IPicture, &pic},
976 {emptyW, NULL, NULL},
978 };
979
980 for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
981 {
982 pic = (IPicture *)0xdeadbeef;
983 hres = OleLoadPicturePath(invalid_parameters[i].szURLorPath, NULL, 0, 0,
984 invalid_parameters[i].riid,
985 (void **)invalid_parameters[i].pic);
987 "[%d] Expected OleLoadPicturePath to return E_INVALIDARG, got 0x%08x\n", i, hres);
988 ok(pic == (IPicture *)0xdeadbeef,
989 "[%d] Expected output pointer to be 0xdeadbeef, got %p\n", i, pic);
990 }
991
992 pic = (IPicture *)0xdeadbeef;
993 hres = OleLoadPicturePath(emptyW, NULL, 0, 0, NULL, (void **)&pic);
995 ok(hres == INET_E_UNKNOWN_PROTOCOL || /* XP/Vista+ */
996 broken(hres == E_UNEXPECTED) || /* NT4 */
997 broken(hres == E_OUTOFMEMORY), /* Win2k/Win2k3 */
998 "Expected OleLoadPicturePath to return INET_E_UNKNOWN_PROTOCOL, got 0x%08x\n", hres);
999 ok(pic == NULL,
1000 "Expected the output interface pointer to be NULL, got %p\n", pic);
1001
1002 pic = (IPicture *)0xdeadbeef;
1003 hres = OleLoadPicturePath(emptyW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1004 todo_wine
1005 ok(hres == INET_E_UNKNOWN_PROTOCOL || /* XP/Vista+ */
1006 broken(hres == E_UNEXPECTED) || /* NT4 */
1007 broken(hres == E_OUTOFMEMORY), /* Win2k/Win2k3 */
1008 "Expected OleLoadPicturePath to return INET_E_UNKNOWN_PROTOCOL, got 0x%08x\n", hres);
1009 ok(pic == NULL,
1010 "Expected the output interface pointer to be NULL, got %p\n", pic);
1011
1012 /* Create a local temporary image file for testing. */
1017 WriteFile(file, bmpimage, sizeof(bmpimage), &size, NULL);
1019
1020 MultiByteToWideChar(CP_ACP, 0, temp_file, -1, temp_fileW + 8, ARRAY_SIZE(temp_fileW) - 8);
1021
1022 /* Try a normal DOS path. */
1023 hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1024 ok(hres == S_OK ||
1025 broken(hres == E_UNEXPECTED), /* NT4 */
1026 "Expected OleLoadPicturePath to return S_OK, got 0x%08x\n", hres);
1027 if (pic)
1028 IPicture_Release(pic);
1029
1030 VariantInit(&var);
1031 V_VT(&var) = VT_BSTR;
1032 V_BSTR(&var) = SysAllocString(temp_fileW + 8);
1033 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1034 ok(hres == S_OK, "OleLoadPictureFile error %#x\n", hres);
1035 IPicture_Release(pic);
1036 VariantClear(&var);
1037
1038 /* Try a DOS path with tacked on "file:". */
1039 hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1040 ok(hres == S_OK ||
1041 broken(hres == E_UNEXPECTED), /* NT4 */
1042 "Expected OleLoadPicturePath to return S_OK, got 0x%08x\n", hres);
1043 if (pic)
1044 IPicture_Release(pic);
1045
1046 VariantInit(&var);
1047 V_VT(&var) = VT_BSTR;
1048 V_BSTR(&var) = SysAllocString(temp_fileW);
1049 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1050 ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#x\n", hres);
1051 VariantClear(&var);
1052
1054
1055 /* Try with a nonexistent file. */
1056 hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1057 ok(hres == INET_E_RESOURCE_NOT_FOUND || /* XP+ */
1058 broken(hres == E_UNEXPECTED) || /* NT4 */
1059 broken(hres == E_FAIL), /*Win2k */
1060 "Expected OleLoadPicturePath to return INET_E_RESOURCE_NOT_FOUND, got 0x%08x\n", hres);
1061
1062 VariantInit(&var);
1063 V_VT(&var) = VT_BSTR;
1064 V_BSTR(&var) = SysAllocString(temp_fileW + 8);
1065 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1066 ok(hres == CTL_E_FILENOTFOUND, "wrong error %#x\n", hres);
1067 VariantClear(&var);
1068
1069 hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1070 ok(hres == INET_E_RESOURCE_NOT_FOUND || /* XP+ */
1071 broken(hres == E_UNEXPECTED) || /* NT4 */
1072 broken(hres == E_FAIL), /* Win2k */
1073 "Expected OleLoadPicturePath to return INET_E_RESOURCE_NOT_FOUND, got 0x%08x\n", hres);
1074
1075 VariantInit(&var);
1076 V_VT(&var) = VT_BSTR;
1077 V_BSTR(&var) = SysAllocString(temp_fileW);
1078 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1079 ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#x\n", hres);
1080 VariantClear(&var);
1081
1084 WriteFile(file, bmpimage, sizeof(bmpimage), &size, NULL);
1086
1087 /* Try a "file:" URL with slash separators. */
1088 ptr = temp_fileW + 8;
1089 while (*ptr)
1090 {
1091 if (*ptr == '\\')
1092 *ptr = '/';
1093 ptr++;
1094 }
1095
1096 hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1097 ok(hres == S_OK ||
1098 broken(hres == E_UNEXPECTED), /* NT4 */
1099 "Expected OleLoadPicturePath to return S_OK, got 0x%08x\n", hres);
1100 if (pic)
1101 IPicture_Release(pic);
1102
1103 VariantInit(&var);
1104 V_VT(&var) = VT_BSTR;
1105 V_BSTR(&var) = SysAllocString(temp_fileW);
1106 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1107 ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#x\n", hres);
1108 VariantClear(&var);
1109
1111
1112 /* Try with a nonexistent file. */
1113 hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1114 ok(hres == INET_E_RESOURCE_NOT_FOUND || /* XP+ */
1115 broken(hres == E_UNEXPECTED) || /* NT4 */
1116 broken(hres == E_FAIL), /* Win2k */
1117 "Expected OleLoadPicturePath to return INET_E_RESOURCE_NOT_FOUND, got 0x%08x\n", hres);
1118
1119 VariantInit(&var);
1120 V_VT(&var) = VT_BSTR;
1121 V_BSTR(&var) = SysAllocString(temp_fileW);
1122 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1123 ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#x\n", hres);
1124 VariantClear(&var);
1125
1126 VariantInit(&var);
1127 V_VT(&var) = VT_INT;
1128 V_INT(&var) = 762;
1129 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1130 ok(hres == CTL_E_FILENOTFOUND, "wrong error %#x\n", hres);
1131
1132if (0) /* crashes under Windows */
1134}
#define broken(x)
Definition: atltest.h:178
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define MultiByteToWideChar
Definition: compat.h:110
@ VT_BSTR
Definition: compat.h:2303
@ VT_INT
Definition: compat.h:2316
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
HRESULT WINAPI OleLoadPicturePath(LPOLESTR szURLorPath, LPUNKNOWN punkCaller, DWORD dwReserved, OLE_COLOR clrReserved, REFIID riid, LPVOID *ppvRet)
Definition: olepicture.c:2497
HRESULT WINAPI OleLoadPictureFile(VARIANT filename, IDispatch **picture)
Definition: olepicture.c:2461
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
static const WCHAR emptyW[]
Definition: navigate.c:40
#define CREATE_ALWAYS
Definition: disk.h:72
static PVOID ptr
Definition: dispmode.c:27
const char * var
Definition: shader.c:5666
static LPOLESTR
Definition: stg_prop.c:27
static REFIID
Definition: olepicture.c:58
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
#define GENERIC_WRITE
Definition: nt_native.h:90
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
#define V_BSTR(A)
Definition: oleauto.h:226
#define CTL_E_PATHFILEACCESSERROR
Definition: olectl.h:287
#define CTL_E_FILENOTFOUND
Definition: olectl.h:274
Definition: fci.c:127
Definition: fci.c:110
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
#define V_INT(x)
Definition: webchild.h:78
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_pic()

static void test_pic ( const unsigned char imgdata,
unsigned int  imgsize 
)
static

Definition at line 288 of file olepicture.c.

289{
291 HGLOBAL hglob;
292 LPBYTE data;
295 ULARGE_INTEGER newpos1;
296 DWORD * header;
297 unsigned int i,j;
298
299 /* Let the fun begin */
300 hglob = GlobalAlloc (0, imgsize);
301 data = GlobalLock (hglob);
302 memcpy(data, imgdata, imgsize);
303 GlobalUnlock(hglob); data = NULL;
304
306 ok (hres == S_OK, "createstreamonhglobal failed? doubt it... hres 0x%08x\n", hres);
307
308 memset(&seekto,0,sizeof(seekto));
309 hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1);
310 ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08x\n", hres);
312
313 IStream_Release(stream);
314
315 /* again with Non Statable and Non Seekable stream */
317 hglob = 0; /* Non-statable impl always deletes on release */
319
320 IStream_Release(stream);
321 for (i = 1; i <= 8; i++) {
322 /* more fun!!! */
323 hglob = GlobalAlloc (0, imgsize + i * (2 * sizeof(DWORD)));
324 data = GlobalLock (hglob);
325 header = (DWORD *)data;
326
327 /* multiple copies of header */
328 memcpy(data,"lt\0\0",4);
329 header[1] = imgsize;
330 for (j = 2; j <= i; j++) {
331 memcpy(&(header[2 * (j - 1)]), header, 2 * sizeof(DWORD));
332 }
333 memcpy(data + i * (2 * sizeof(DWORD)), imgdata, imgsize);
334 GlobalUnlock(hglob); data = NULL;
335
337 ok (hres == S_OK, "createstreamonhglobal failed? doubt it... hres 0x%08x\n", hres);
338
339 memset(&seekto,0,sizeof(seekto));
340 hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1);
341 ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08x\n", hres);
343
344 IStream_Release(stream);
345
346 /* again with Non Statable and Non Seekable stream */
348 hglob = 0; /* Non-statable impl always deletes on release */
350
351 IStream_Release(stream);
352 }
353}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static void test_pic_with_stream(LPSTREAM stream, unsigned int imgsize)
Definition: olepicture.c:216

Referenced by START_TEST().

◆ test_pic_with_stream()

static void test_pic_with_stream ( LPSTREAM  stream,
unsigned int  imgsize 
)
static

Definition at line 216 of file olepicture.c.

217{
218 IPicture* pic = NULL;
220 LPVOID pvObj = NULL;
221 OLE_HANDLE handle, hPal;
224 short type;
225 DWORD attr;
226 ULONG res;
227
228 pvObj = NULL;
229 hres = pOleLoadPicture(stream, imgsize, TRUE, &IID_IPicture, &pvObj);
230 pic = pvObj;
231
232 ok(hres == S_OK,"OLP (NULL,..) does not return 0, but 0x%08x\n",hres);
233 ok(pic != NULL,"OLP (NULL,..) returns NULL, instead of !NULL\n");
234 if (pic == NULL)
235 return;
236
237 pvObj = NULL;
238 hres = IPicture_QueryInterface (pic, &IID_IPicture, &pvObj);
239
240 ok(hres == S_OK,"IPicture_QI does not return S_OK, but 0x%08x\n", hres);
241 ok(pvObj != NULL,"IPicture_QI does return NULL, instead of a ptr\n");
242
243 IPicture_Release ((IPicture*)pvObj);
244
245 handle = 0;
246 hres = IPicture_get_Handle (pic, &handle);
247 ok(hres == S_OK,"IPicture_get_Handle does not return S_OK, but 0x%08x\n", hres);
248 ok(handle != 0, "IPicture_get_Handle returns a NULL handle, but it should be non NULL\n");
249
250 if (handle)
251 {
252 BITMAP bmp;
254 ok(bmp.bmBits != 0, "not a dib\n");
255 }
256
257 width = 0;
258 hres = IPicture_get_Width (pic, &width);
259 ok(hres == S_OK,"IPicture_get_Width does not return S_OK, but 0x%08x\n", hres);
260 ok(width != 0, "IPicture_get_Width returns 0, but it should not be 0.\n");
261
262 height = 0;
263 hres = IPicture_get_Height (pic, &height);
264 ok(hres == S_OK,"IPicture_get_Height does not return S_OK, but 0x%08x\n", hres);
265 ok(height != 0, "IPicture_get_Height returns 0, but it should not be 0.\n");
266
267 type = 0;
268 hres = IPicture_get_Type (pic, &type);
269 ok(hres == S_OK,"IPicture_get_Type does not return S_OK, but 0x%08x\n", hres);
270 ok(type == PICTYPE_BITMAP, "IPicture_get_Type returns %d, but it should be PICTYPE_BITMAP(%d).\n", type, PICTYPE_BITMAP);
271
272 attr = 0;
273 hres = IPicture_get_Attributes (pic, &attr);
274 ok(hres == S_OK,"IPicture_get_Attributes does not return S_OK, but 0x%08x\n", hres);
275 ok(attr == 0, "IPicture_get_Attributes returns %d, but it should be 0.\n", attr);
276
277 hPal = 0;
278 hres = IPicture_get_hPal (pic, &hPal);
279 ok(hres == S_OK,"IPicture_get_hPal does not return S_OK, but 0x%08x\n", hres);
280 /* a single pixel b/w image has no palette */
281 ok(hPal == 0, "IPicture_get_hPal returns %d, but it should be 0.\n", hPal);
282
283 res = IPicture_Release (pic);
284 ok (res == 0, "refcount after release is %d, but should be 0?\n", res);
285}
#define UlongToHandle(ul)
Definition: basetsd.h:97
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint res
Definition: glext.h:9613
Definition: bl.h:1331
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)

Referenced by test_pic().

◆ test_Render()

static void test_Render ( void  )
static

Definition at line 805 of file olepicture.c.

806{
807 IPicture *pic;
809 short type;
811 OLE_XSIZE_HIMETRIC pWidth;
812 OLE_YSIZE_HIMETRIC pHeight;
815
816 /* test IPicture::Render return code on uninitialized picture */
818 ok(hres == S_OK, "Failed to create a picture, hr %#x.\n", hres);
819 hres = IPicture_get_Type(pic, &type);
820 ok(hres == S_OK, "IPicture_get_Type does not return S_OK, but 0x%08x\n", hres);
821 ok(type == PICTYPE_UNINITIALIZED, "Expected type = PICTYPE_UNINITIALIZED, got = %d\n", type);
822 /* zero dimensions */
823 hres = picture_render(pic, hdc, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
825 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 0, NULL);
827 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 10, NULL);
829 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 0, NULL);
831 hres = picture_render(pic, hdc, 0, 0, 0, 10, 0, 0, 10, 10, NULL);
833 hres = picture_render(pic, hdc, 0, 0, 10, 0, 0, 0, 10, 10, NULL);
835 hres = picture_render(pic, hdc, 0, 0, 0, 0, 0, 0, 10, 10, NULL);
837 /* nonzero dimensions, PICTYPE_UNINITIALIZED */
838 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 10, NULL);
840 IPicture_Release(pic);
841
842 desc.cbSizeofstruct = sizeof(PICTDESC);
843 desc.picType = PICTYPE_ICON;
844 desc.icon.hicon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
845 if(!desc.icon.hicon){
846 win_skip("LoadIcon failed. Skipping...\n");
848 return;
849 }
850
851 hres = OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (void **)&pic);
852 ok(hres == S_OK, "Failed to create a picture, hr %#x.\n", hres);
853 /* zero dimensions, PICTYPE_ICON */
854 hres = picture_render(pic, hdc, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
856 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 0, NULL);
858 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 10, NULL);
860 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 0, NULL);
862 hres = picture_render(pic, hdc, 0, 0, 0, 10, 0, 0, 10, 10, NULL);
864 hres = picture_render(pic, hdc, 0, 0, 10, 0, 0, 0, 10, 10, NULL);
866 hres = picture_render(pic, hdc, 0, 0, 0, 0, 0, 0, 10, 10, NULL);
868
869 /* Check if target size and position is respected */
870 IPicture_get_Width(pic, &pWidth);
871 IPicture_get_Height(pic, &pHeight);
872
873 SetPixelV(hdc, 0, 0, 0x00223344);
874 SetPixelV(hdc, 5, 5, 0x00223344);
875 SetPixelV(hdc, 10, 10, 0x00223344);
876 expected = GetPixel(hdc, 0, 0);
877
878 hres = picture_render(pic, hdc, 1, 1, 9, 9, 0, pHeight, pWidth, -pHeight, NULL);
880
881 if(hres != S_OK) goto done;
882
883 /* Evaluate the rendered Icon */
884 result = GetPixel(hdc, 0, 0);
885 ok(result == expected,
886 "Color at 0,0 should be unchanged 0x%06X, but was 0x%06X\n", expected, result);
887 result = GetPixel(hdc, 5, 5);
888 ok(result != expected,
889 "Color at 5,5 should have changed, but still was 0x%06X\n", expected);
890 result = GetPixel(hdc, 10, 10);
891 ok(result == expected,
892 "Color at 10,10 should be unchanged 0x%06X, but was 0x%06X\n", expected, result);
893
894done:
895 IPicture_Release(pic);
897}
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
GLuint64EXT * result
Definition: glext.h:11304
BOOL expected
Definition: store.c:2063
static HRESULT picture_render(IPicture *iface, HDC hdc, LONG x, LONG y, LONG cx, LONG cy, OLE_XPOS_HIMETRIC xSrc, OLE_YPOS_HIMETRIC ySrc, OLE_XSIZE_HIMETRIC cxSrc, OLE_YSIZE_HIMETRIC cySrc, const RECT *bounds)
Definition: olepicture.c:756
struct tagPICTDESC PICTDESC
#define CTL_E_INVALIDPROPERTYVALUE
Definition: olectl.h:292
DWORD COLORREF
Definition: windef.h:300
BOOL WINAPI SetPixelV(_In_ HDC, _In_ int, _In_ int, _In_ COLORREF)

Referenced by START_TEST().

Variable Documentation

◆ apmdata

const unsigned char apmdata[]
static
Initial value:
= {
0xd7,0xcd,0xc6,0x9a, 0x00,0x00,0x00,0x00, 0x00,0x00,0xee,0x02, 0xb1,0x03,0xa0,0x05,
0x00,0x00,0x00,0x00, 0xee,0x53,0x01,0x00, 0x09,0x00,0x00,0x03, 0x13,0x00,0x00,0x00,
0x01,0x00,0x05,0x00, 0x00,0x00,0x00,0x00, 0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00
}

Definition at line 130 of file olepicture.c.

Referenced by test_apm().

◆ bmpimage

const unsigned char bmpimage[66]
static
Initial value:
= {
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,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,0x00,
0x00,0x00
}

Definition at line 104 of file olepicture.c.

Referenced by START_TEST(), and test_OleLoadPicturePath().

◆ bmpimage_rle8

const unsigned char bmpimage_rle8[]
static
Initial value:
= {
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
}

Definition at line 113 of file olepicture.c.

Referenced by START_TEST().

◆ BOOL

LPVOID *static BOOL

Definition at line 58 of file olepicture.c.

◆ DWORD

LPVOID *static DWORD

Definition at line 59 of file olepicture.c.

◆ enhmetafile

const unsigned char enhmetafile[]
static

Definition at line 149 of file olepicture.c.

Referenced by test_enhmetafile().

◆ gif4pixel

const unsigned char gif4pixel[42]
static
Initial value:
= {
0x47,0x49,0x46,0x38,0x37,0x61,0x02,0x00,0x02,0x00,0xa1,0x00,0x00,0x00,0x00,0x00,
0x39,0x62,0xfc,0xff,0x1a,0xe5,0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x02,0x00,
0x02,0x00,0x00,0x02,0x03,0x14,0x16,0x05,0x00,0x3b
}

Definition at line 122 of file olepicture.c.

Referenced by START_TEST().

◆ gifimage

const unsigned char gifimage[35]
static
Initial value:
= {
0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
0x01,0x00,0x3b
}

Definition at line 64 of file olepicture.c.

Referenced by START_TEST(), and test_Invoke().

◆ hOleaut32

HMODULE hOleaut32
static

Definition at line 56 of file olepicture.c.

Referenced by START_TEST().

◆ jpgimage

const unsigned char jpgimage[285]
static
Initial value:
= {
0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2c,
0x01,0x2c,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x05,0x03,0x04,0x04,0x04,0x03,0x05,
0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x07,0x0c,0x08,0x07,0x07,0x07,0x07,0x0f,0x0b,
0x0b,0x09,0x0c,0x11,0x0f,0x12,0x12,0x11,0x0f,0x11,0x11,0x13,0x16,0x1c,0x17,0x13,
0x14,0x1a,0x15,0x11,0x11,0x18,0x21,0x18,0x1a,0x1d,0x1d,0x1f,0x1f,0x1f,0x13,0x17,
0x22,0x24,0x22,0x1e,0x24,0x1c,0x1e,0x1f,0x1e,0xff,0xdb,0x00,0x43,0x01,0x05,0x05,
0x05,0x07,0x06,0x07,0x0e,0x08,0x08,0x0e,0x1e,0x14,0x11,0x14,0x1e,0x1e,0x1e,0x1e,
0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0xff,0xc0,
0x00,0x11,0x08,0x00,0x01,0x00,0x01,0x03,0x01,0x22,0x00,0x02,0x11,0x01,0x03,0x11,
0x01,0xff,0xc4,0x00,0x15,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xff,0xc4,0x00,0x14,0x10,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xc4,
0x00,0x14,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xff,0xc4,0x00,0x14,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xda,0x00,0x0c,0x03,0x01,
0x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xb2,0xc0,0x07,0xff,0xd9
}

Definition at line 71 of file olepicture.c.

Referenced by START_TEST().

◆ LONG

LPVOID *static LONG

Definition at line 58 of file olepicture.c.

◆ metafile

const unsigned char metafile[]
static
Initial value:
= {
0x01, 0x00, 0x09, 0x00, 0x00, 0x03, 0x19, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x0a,
0x16, 0x00, 0x0b, 0x00, 0x04, 0x00, 0x00, 0x00,
0x54, 0x65, 0x73, 0x74, 0x03, 0x00, 0x05, 0x00,
0x08, 0x00, 0x0c, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00
}

Definition at line 138 of file olepicture.c.

Referenced by check_metafile(), decode_image_emf(), decode_image_wmf(), GdipCloneImage(), GdipConvertToEmfPlus(), GdipConvertToEmfPlusToFile(), GdipCreateMetafileFromEmf(), GdipCreateMetafileFromFile(), GdipCreateMetafileFromStream(), GdipCreateMetafileFromWmf(), GdipCreateMetafileFromWmfFile(), GdipEnumerateMetafileDestPoint(), GdipEnumerateMetafileDestPointI(), GdipEnumerateMetafileDestRect(), GdipEnumerateMetafileDestRectI(), GdipEnumerateMetafileSrcRectDestPoints(), GdipGetHemfFromMetafile(), GdipGetMetafileHeaderFromFile(), GdipGetMetafileHeaderFromMetafile(), GdipGetMetafileHeaderFromStream(), GdipGetMetafileHeaderFromWmf(), GdipPlayMetafileRecord(), GdipRecordMetafile(), GdipRecordMetafileFileName(), GdipRecordMetafileFileNameI(), GdipRecordMetafileI(), GdipRecordMetafileStream(), GdipSetMetafileDownLevelRasterizationLimit(), get_metadc_ptr(), load_emf(), load_wmf(), Metafile::Metafile(), METAFILE_AddBrushObject(), METAFILE_AddImageAttributesObject(), METAFILE_AddImageObject(), METAFILE_AddObjectId(), METAFILE_AddPathObject(), METAFILE_AddPenObject(), METAFILE_AddRegionObject(), METAFILE_AddSimpleProperty(), METAFILE_AdjustFrame(), METAFILE_AllocateRecord(), METAFILE_BeginContainer(), METAFILE_BeginContainerNoParams(), METAFILE_DrawImagePointsRect(), METAFILE_DrawPath(), METAFILE_EndContainer(), METAFILE_FillPath(), METAFILE_FillRectangles(), METAFILE_Free(), metafile_free_object_table_entry(), METAFILE_GetDC(), METAFILE_GetFinalGdiTransform(), METAFILE_GetGraphicsContext(), METAFILE_GraphicsClear(), METAFILE_GraphicsDeleted(), METAFILE_MultiplyWorldTransform(), METAFILE_PlaybackGetDC(), METAFILE_PlaybackObject(), METAFILE_PlaybackReleaseDC(), METAFILE_PlaybackUpdateClip(), METAFILE_PlaybackUpdateGdiTransform(), METAFILE_PlaybackUpdateWorldTransform(), METAFILE_ReleaseDC(), METAFILE_RemoveLastRecord(), METAFILE_ResetWorldTransform(), METAFILE_RestoreGraphics(), METAFILE_RotateWorldTransform(), METAFILE_SaveGraphics(), METAFILE_ScaleWorldTransform(), metafile_set_clip_region(), metafile_set_object_table_entry(), METAFILE_SetClipRect(), METAFILE_SetClipRegion(), METAFILE_SetPageTransform(), METAFILE_SetWorldTransform(), METAFILE_TranslateWorldTransform(), METAFILE_WriteEndOfFile(), METAFILE_WriteHeader(), METAFILE_WriteRecords(), play_metafile(), sync_metafile(), test_clear(), test_clipping(), test_containers(), test_converttoemfplus(), test_drawimage(), test_drawpath(), test_emfonly(), test_empty(), test_fillpath(), test_fillrect(), test_frameunit(), test_gditransform(), test_gditransform_cb(), test_getdc(), test_metafile(), test_nullframerect(), test_pagetransform(), test_properties(), test_system_palette_entries(), and test_worldtransform().

◆ NoStatStreamImpl_Vtbl

static const IStreamVtbl NoStatStreamImpl_Vtbl
static
Initial value:
=
{
}
static ULONG WINAPI NoStatStreamImpl_Release(IStream *iface)
Definition: olepicture.c:1629
static HRESULT WINAPI NoStatStreamImpl_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: olepicture.c:1807
static HRESULT WINAPI NoStatStreamImpl_Revert(IStream *iface)
Definition: olepicture.c:1796
static HRESULT WINAPI NoStatStreamImpl_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: olepicture.c:1740
static HRESULT WINAPI NoStatStreamImpl_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
Definition: olepicture.c:1722
static HRESULT WINAPI NoStatStreamImpl_Clone(IStream *iface, IStream **ppstm)
Definition: olepicture.c:1824
static HRESULT WINAPI NoStatStreamImpl_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: olepicture.c:1639
static HRESULT WINAPI NoStatStreamImpl_Commit(IStream *iface, DWORD grfCommitFlags)
Definition: olepicture.c:1792
static HRESULT WINAPI NoStatStreamImpl_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: olepicture.c:1691
static HRESULT WINAPI NoStatStreamImpl_QueryInterface(IStream *iface, REFIID riid, void **ppvObject)
Definition: olepicture.c:1611
static HRESULT WINAPI NoStatStreamImpl_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: olepicture.c:1798
static HRESULT WINAPI NoStatStreamImpl_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: olepicture.c:1816
static HRESULT WINAPI NoStatStreamImpl_Write(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
Definition: olepicture.c:1663

Definition at line 1830 of file olepicture.c.

Referenced by NoStatStream_Construct().

◆ pngimage

const unsigned char pngimage[285]
static
Initial value:
= {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,
0xde,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,
0x13,0x01,0x00,0x9a,0x9c,0x18,0x00,0x00,0x00,0x07,0x74,0x49,0x4d,0x45,0x07,0xd5,
0x06,0x03,0x0f,0x07,0x2d,0x12,0x10,0xf0,0xfd,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,
0x54,0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,
0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
}

Definition at line 93 of file olepicture.c.

Referenced by START_TEST().

◆ REFIID

LPVOID *static REFIID

Definition at line 58 of file olepicture.c.

◆ stock_bm

HBITMAP stock_bm
static

Definition at line 183 of file olepicture.c.

Referenced by create_render_dc(), and delete_render_dc().