ReactOS 0.4.17-dev-573-g8315b8c
olepicture.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "winerror.h"
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "ole2.h"
#include "olectl.h"
#include "oleauto.h"
#include "connpt.h"
#include "urlmon.h"
#include "initguid.h"
#include "wincodec.h"
#include "wine/debug.h"
#include "pshpack1.h"
#include "poppack.h"
Include dependency graph for olepicture.c:

Go to the source code of this file.

Classes

struct  _APM_HEADER
 
struct  CURSORICONFILEDIRENTRY
 
struct  CURSORICONFILEDIR
 
struct  OLEPictureImpl
 
struct  IClassFactoryImpl
 

Macros

#define COBJMACROS
 
#define BITMAP_FORMAT_BMP   0x4d42 /* "BM" */
 
#define BITMAP_FORMAT_JPEG   0xd8ff
 
#define BITMAP_FORMAT_GIF   0x4947
 
#define BITMAP_FORMAT_PNG   0x5089
 
#define BITMAP_FORMAT_APM   0xcdd7
 

Typedefs

typedef struct _APM_HEADER APM_HEADER
 
typedef struct OLEPictureImpl OLEPictureImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (olepicture)
 
static OLEPictureImplimpl_from_IPicture (IPicture *iface)
 
static OLEPictureImplimpl_from_IDispatch (IDispatch *iface)
 
static OLEPictureImplimpl_from_IPersistStream (IPersistStream *iface)
 
static OLEPictureImplimpl_from_IConnectionPointContainer (IConnectionPointContainer *iface)
 
static OLE_XSIZE_HIMETRIC xpixels_to_himetric (INT pixels, HDC hdc)
 
static OLE_YSIZE_HIMETRIC ypixels_to_himetric (INT pixels, HDC hdc)
 
static void OLEPictureImpl_SetBitmap (OLEPictureImpl *This)
 
static void OLEPictureImpl_SetIcon (OLEPictureImpl *This)
 
static HRESULT OLEPictureImpl_Construct (LPPICTDESC pictDesc, BOOL fOwn, OLEPictureImpl **pict)
 
static void OLEPictureImpl_Destroy (OLEPictureImpl *Obj)
 
static ULONG WINAPI OLEPictureImpl_AddRef (IPicture *iface)
 
static ULONG WINAPI OLEPictureImpl_Release (IPicture *iface)
 
static HRESULT WINAPI OLEPictureImpl_QueryInterface (IPicture *iface, REFIID riid, void **ppvObject)
 
static void OLEPicture_SendNotify (OLEPictureImpl *this, DISPID dispID)
 
static HRESULT WINAPI OLEPictureImpl_get_Handle (IPicture *iface, OLE_HANDLE *phandle)
 
static HRESULT WINAPI OLEPictureImpl_get_hPal (IPicture *iface, OLE_HANDLE *phandle)
 
static HRESULT WINAPI OLEPictureImpl_get_Type (IPicture *iface, short *ptype)
 
static HRESULT WINAPI OLEPictureImpl_get_Width (IPicture *iface, OLE_XSIZE_HIMETRIC *pwidth)
 
static HRESULT WINAPI OLEPictureImpl_get_Height (IPicture *iface, OLE_YSIZE_HIMETRIC *pheight)
 
static void render_masked_bitmap (OLEPictureImpl *This, 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, HBITMAP hbmMask, HBITMAP hbmXor)
 
static HRESULT WINAPI OLEPictureImpl_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, LPCRECT prcWBounds)
 
static HRESULT WINAPI OLEPictureImpl_set_hPal (IPicture *iface, OLE_HANDLE hpal)
 
static HRESULT WINAPI OLEPictureImpl_get_CurDC (IPicture *iface, HDC *phdc)
 
static HRESULT WINAPI OLEPictureImpl_SelectPicture (IPicture *iface, HDC hdcIn, HDC *phdcOut, OLE_HANDLE *phbmpOut)
 
static HRESULT WINAPI OLEPictureImpl_get_KeepOriginalFormat (IPicture *iface, BOOL *pfKeep)
 
static HRESULT WINAPI OLEPictureImpl_put_KeepOriginalFormat (IPicture *iface, BOOL keep)
 
static HRESULT WINAPI OLEPictureImpl_PictureChanged (IPicture *iface)
 
static HRESULT WINAPI OLEPictureImpl_SaveAsFile (IPicture *iface, IStream *pstream, BOOL SaveMemCopy, LONG *pcbSize)
 
static HRESULT WINAPI OLEPictureImpl_get_Attributes (IPicture *iface, DWORD *pdwAttr)
 
static HRESULT WINAPI OLEPictureImpl_IConnectionPointContainer_QueryInterface (IConnectionPointContainer *iface, REFIID riid, VOID **ppvoid)
 
static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_AddRef (IConnectionPointContainer *iface)
 
static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_Release (IConnectionPointContainer *iface)
 
static HRESULT WINAPI OLEPictureImpl_EnumConnectionPoints (IConnectionPointContainer *iface, IEnumConnectionPoints **ppEnum)
 
static HRESULT WINAPI OLEPictureImpl_FindConnectionPoint (IConnectionPointContainer *iface, REFIID riid, IConnectionPoint **ppCP)
 
static HRESULT WINAPI OLEPictureImpl_IPersistStream_QueryInterface (IPersistStream *iface, REFIID riid, VOID **ppvoid)
 
static ULONG WINAPI OLEPictureImpl_IPersistStream_AddRef (IPersistStream *iface)
 
static ULONG WINAPI OLEPictureImpl_IPersistStream_Release (IPersistStream *iface)
 
static HRESULT WINAPI OLEPictureImpl_GetClassID (IPersistStream *iface, CLSID *pClassID)
 
static HRESULT WINAPI OLEPictureImpl_IsDirty (IPersistStream *iface)
 
static HRESULT OLEPictureImpl_LoadDIB (OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
 
static HRESULT OLEPictureImpl_LoadWICSource (OLEPictureImpl *This, IWICBitmapSource *src)
 
static HRESULT OLEPictureImpl_LoadWICDecoder (OLEPictureImpl *This, REFCLSID decoder_clsid, BYTE *xbuf, ULONG xread)
 
static HRESULT OLEPictureImpl_LoadIcon (OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
 
static HRESULT OLEPictureImpl_LoadEnhMetafile (OLEPictureImpl *This, const BYTE *data, ULONG size)
 
static HRESULT OLEPictureImpl_LoadAPM (OLEPictureImpl *This, const BYTE *data, ULONG size)
 
static HRESULT WINAPI OLEPictureImpl_Load (IPersistStream *iface, IStream *pStm)
 
static HRESULT serializeBMP (HBITMAP hbmp, void **buffer, unsigned int *length)
 
static BOOL serializeIcon (HICON hIcon, void **ppBuffer, unsigned int *pLength)
 
static HRESULT WINAPI OLEPictureImpl_Save (IPersistStream *iface, IStream *pStm, BOOL fClearDirty)
 
static HRESULT WINAPI OLEPictureImpl_GetSizeMax (IPersistStream *iface, ULARGE_INTEGER *size)
 
static HRESULT WINAPI OLEPictureImpl_IDispatch_QueryInterface (IDispatch *iface, REFIID riid, VOID **ppvoid)
 
static ULONG WINAPI OLEPictureImpl_IDispatch_AddRef (IDispatch *iface)
 
static ULONG WINAPI OLEPictureImpl_IDispatch_Release (IDispatch *iface)
 
static HRESULT WINAPI OLEPictureImpl_GetTypeInfoCount (IDispatch *iface, unsigned int *pctinfo)
 
static HRESULT WINAPI OLEPictureImpl_GetTypeInfo (IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI OLEPictureImpl_GetIDsOfNames (IDispatch *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI OLEPictureImpl_Invoke (IDispatch *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExepInfo, UINT *puArgErr)
 
HRESULT WINAPI OleCreatePictureIndirect (LPPICTDESC lpPictDesc, REFIID riid, BOOL Own, void **ppvObj)
 
HRESULT WINAPI OleLoadPicture (LPSTREAM lpstream, LONG lSize, BOOL fRunmode, REFIID riid, LPVOID *ppvObj)
 
HRESULT WINAPI OleLoadPictureEx (LPSTREAM lpstream, LONG lSize, BOOL fRunmode, REFIID riid, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj)
 
static HRESULT create_stream (const WCHAR *filename, IStream **stream)
 
HRESULT WINAPI OleLoadPictureFile (VARIANT filename, IDispatch **picture)
 
HRESULT WINAPI OleSavePictureFile (IDispatch *picture, BSTR filename)
 
HRESULT WINAPI OleLoadPicturePath (LPOLESTR szURLorPath, LPUNKNOWN punkCaller, DWORD dwReserved, OLE_COLOR clrReserved, REFIID riid, LPVOID *ppvRet)
 
static IClassFactoryImplimpl_from_IClassFactory (IClassFactory *iface)
 
static HRESULT WINAPI SPCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
 
static ULONG WINAPI SPCF_AddRef (LPCLASSFACTORY iface)
 
static ULONG WINAPI SPCF_Release (LPCLASSFACTORY iface)
 
static HRESULT WINAPI SPCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
 
static HRESULT WINAPI SPCF_LockServer (LPCLASSFACTORY iface, BOOL dolock)
 
void _get_STDPIC_CF (LPVOID *ppv)
 

Variables

static const IPictureVtbl OLEPictureImpl_VTable
 
static const IDispatchVtbl OLEPictureImpl_IDispatch_VTable
 
static const IPersistStreamVtbl OLEPictureImpl_IPersistStream_VTable
 
static const IConnectionPointContainerVtbl OLEPictureImpl_IConnectionPointContainer_VTable
 
static const IClassFactoryVtbl SPCF_Vtbl
 
static IClassFactoryImpl STDPIC_CF = {{&SPCF_Vtbl}, 1 }
 

Macro Definition Documentation

◆ BITMAP_FORMAT_APM

#define BITMAP_FORMAT_APM   0xcdd7

Definition at line 64 of file olepicture.c.

◆ BITMAP_FORMAT_BMP

#define BITMAP_FORMAT_BMP   0x4d42 /* "BM" */

Definition at line 60 of file olepicture.c.

◆ BITMAP_FORMAT_GIF

#define BITMAP_FORMAT_GIF   0x4947

Definition at line 62 of file olepicture.c.

◆ BITMAP_FORMAT_JPEG

#define BITMAP_FORMAT_JPEG   0xd8ff

Definition at line 61 of file olepicture.c.

◆ BITMAP_FORMAT_PNG

#define BITMAP_FORMAT_PNG   0x5089

Definition at line 63 of file olepicture.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 43 of file olepicture.c.

Typedef Documentation

◆ APM_HEADER

◆ OLEPictureImpl

Function Documentation

◆ _get_STDPIC_CF()

void _get_STDPIC_CF ( LPVOID ppv)

Definition at line 2594 of file olepicture.c.

2594{ *ppv = &STDPIC_CF; }
static IClassFactoryImpl STDPIC_CF
Definition: olepicture.c:2592
REFIID LPVOID * ppv
Definition: atlbase.h:39

Referenced by DllGetClassObject().

◆ create_stream()

static HRESULT create_stream ( const WCHAR filename,
IStream **  stream 
)
static

Definition at line 2397 of file olepicture.c.

2398{
2399 HANDLE hFile;
2401 HGLOBAL hGlobal = NULL;
2402 DWORD dwBytesRead;
2403 HRESULT hr = S_OK;
2404
2408
2411 {
2412 hGlobal = GlobalAlloc(GMEM_FIXED, dwFileSize);
2413 if (!hGlobal)
2414 hr = E_OUTOFMEMORY;
2415 else
2416 {
2417 if (!ReadFile(hFile, hGlobal, dwFileSize, &dwBytesRead, NULL))
2418 {
2419 GlobalFree(hGlobal);
2421 }
2422 }
2423 }
2424
2426
2427 if (FAILED(hr)) return hr;
2428
2429 hr = CreateStreamOnHGlobal(hGlobal, TRUE, stream);
2430 if (FAILED(hr))
2431 GlobalFree(hGlobal);
2432
2433 return hr;
2434}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL delete_on_release, IStream **stream)
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
const char * filename
Definition: ioapi.h:137
DWORD dwFileSize
Definition: more.c:39
_In_ HANDLE hFile
Definition: mswsock.h:90
Definition: parse.h:23
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GMEM_FIXED
Definition: winbase.h:317
#define INVALID_FILE_SIZE
Definition: winbase.h:528
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

Referenced by OleLoadPictureFile(), and OleLoadPicturePath().

◆ impl_from_IClassFactory()

static IClassFactoryImpl * impl_from_IClassFactory ( IClassFactory iface)
inlinestatic

Definition at line 2546 of file olepicture.c.

2547{
2548 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
2549}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by SPCF_AddRef(), SPCF_LockServer(), SPCF_QueryInterface(), and SPCF_Release().

◆ impl_from_IConnectionPointContainer()

◆ impl_from_IDispatch()

static OLEPictureImpl * impl_from_IDispatch ( IDispatch iface)
inlinestatic

◆ impl_from_IPersistStream()

◆ impl_from_IPicture()

◆ OleCreatePictureIndirect()

HRESULT WINAPI OleCreatePictureIndirect ( LPPICTDESC  lpPictDesc,
REFIID  riid,
BOOL  Own,
void **  ppvObj 
)

Definition at line 2291 of file olepicture.c.

2293{
2294 OLEPictureImpl* newPict;
2295 HRESULT hr;
2296
2297 TRACE("(%p,%s,%d,%p)\n", lpPictDesc, debugstr_guid(riid), Own, ppvObj);
2298
2299 *ppvObj = NULL;
2300
2301 hr = OLEPictureImpl_Construct(lpPictDesc, Own, &newPict);
2302 if (hr != S_OK) return hr;
2303
2304 /*
2305 * Make sure it supports the interface required by the caller.
2306 */
2307 hr = IPicture_QueryInterface(&newPict->IPicture_iface, riid, ppvObj);
2308
2309 /*
2310 * Release the reference obtained in the constructor. If
2311 * the QueryInterface was unsuccessful, it will free the class.
2312 */
2313 IPicture_Release(&newPict->IPicture_iface);
2314
2315 return hr;
2316}
static HRESULT OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn, OLEPictureImpl **pict)
Definition: olepicture.c:268
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
IPicture IPicture_iface
Definition: olepicture.c:113

Referenced by create_picture(), OleLoadPicture(), OleLoadPictureEx(), SPCF_CreateInstance(), test_get_Attributes(), test_get_Handle(), test_get_Type(), test_himetric(), test_load_save_bmp(), test_load_save_dib(), test_load_save_empty_picture(), test_load_save_icon(), test_OleCreatePictureIndirect(), and test_Render().

◆ OleLoadPicture()

HRESULT WINAPI OleLoadPicture ( LPSTREAM  lpstream,
LONG  lSize,
BOOL  fRunmode,
REFIID  riid,
LPVOID ppvObj 
)

Definition at line 2322 of file olepicture.c.

2324{
2325 LPPERSISTSTREAM ps;
2326 IPicture *newpic;
2327 HRESULT hr;
2328
2329 TRACE("%p, %ld, %d, %s, %p), partially implemented.\n",
2330 lpstream, lSize, fRunmode, debugstr_guid(riid), ppvObj);
2331
2332 hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
2333 if (hr != S_OK)
2334 return hr;
2335 hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps);
2336 if (hr != S_OK) {
2337 ERR("Could not get IPersistStream iface from Ole Picture?\n");
2338 IPicture_Release(newpic);
2339 *ppvObj = NULL;
2340 return hr;
2341 }
2342 hr = IPersistStream_Load(ps,lpstream);
2343 IPersistStream_Release(ps);
2344 if (FAILED(hr))
2345 {
2346 ERR("IPersistStream_Load failed\n");
2347 IPicture_Release(newpic);
2348 *ppvObj = NULL;
2349 return hr;
2350 }
2351 hr = IPicture_QueryInterface(newpic,riid,ppvObj);
2352 if (hr != S_OK)
2353 ERR("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
2354 IPicture_Release(newpic);
2355 return hr;
2356}
#define ERR(fmt,...)
Definition: precomp.h:57
HRESULT WINAPI OleCreatePictureIndirect(LPPICTDESC lpPictDesc, REFIID riid, BOOL Own, void **ppvObj)
Definition: olepicture.c:2291
interface IPersistStream * LPPERSISTSTREAM
Definition: objfwd.h:16
const GUID IID_IPersistStream
Definition: proxy.cpp:13

Referenced by DoLoadPicture(), load_picture(), OleLoadPictureFile(), and OleLoadPicturePath().

◆ OleLoadPictureEx()

HRESULT WINAPI OleLoadPictureEx ( LPSTREAM  lpstream,
LONG  lSize,
BOOL  fRunmode,
REFIID  riid,
DWORD  xsiz,
DWORD  ysiz,
DWORD  flags,
LPVOID ppvObj 
)

Definition at line 2361 of file olepicture.c.

2363{
2364 LPPERSISTSTREAM ps;
2365 IPicture *newpic;
2366 HRESULT hr;
2367
2368 FIXME("%p, %ld, %d, %s, %lu, %lu, %#lx, %p, partially implemented.\n",
2369 lpstream, lSize, fRunmode, debugstr_guid(riid), xsiz, ysiz, flags, ppvObj);
2370
2371 hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
2372 if (hr != S_OK)
2373 return hr;
2374 hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps);
2375 if (hr != S_OK) {
2376 ERR("Could not get IPersistStream iface from Ole Picture?\n");
2377 IPicture_Release(newpic);
2378 *ppvObj = NULL;
2379 return hr;
2380 }
2381 hr = IPersistStream_Load(ps,lpstream);
2382 IPersistStream_Release(ps);
2383 if (FAILED(hr))
2384 {
2385 ERR("IPersistStream_Load failed\n");
2386 IPicture_Release(newpic);
2387 *ppvObj = NULL;
2388 return hr;
2389 }
2390 hr = IPicture_QueryInterface(newpic,riid,ppvObj);
2391 if (hr != S_OK)
2392 ERR("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
2393 IPicture_Release(newpic);
2394 return hr;
2395}
#define FIXME(fmt,...)
Definition: precomp.h:53
GLbitfield flags
Definition: glext.h:7161

◆ OleLoadPictureFile()

HRESULT WINAPI OleLoadPictureFile ( VARIANT  filename,
IDispatch **  picture 
)

Definition at line 2439 of file olepicture.c.

2440{
2441 IStream *stream;
2442 HRESULT hr;
2443
2444 TRACE("(%s,%p)\n", wine_dbgstr_variant(&filename), picture);
2445
2446 if (V_VT(&filename) != VT_BSTR)
2447 return CTL_E_FILENOTFOUND;
2448
2450 if (hr != S_OK)
2451 {
2453 return CTL_E_FILENOTFOUND;
2454
2456 }
2457
2459 IStream_Release(stream);
2460 return hr;
2461}
#define FALSE
Definition: types.h:117
@ VT_BSTR
Definition: compat.h:2303
HRESULT WINAPI OleLoadPicture(LPSTREAM lpstream, LONG lSize, BOOL fRunmode, REFIID riid, LPVOID *ppvObj)
Definition: olepicture.c:2322
static HRESULT create_stream(const WCHAR *filename, IStream **stream)
Definition: olepicture.c:2397
@ picture
Definition: id3.c:95
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define CTL_E_PATHFILEACCESSERROR
Definition: olectl.h:287
#define CTL_E_FILENOTFOUND
Definition: olectl.h:274
const GUID IID_IDispatch

Referenced by test_OleLoadPicturePath().

◆ OleLoadPicturePath()

HRESULT WINAPI OleLoadPicturePath ( LPOLESTR  szURLorPath,
LPUNKNOWN  punkCaller,
DWORD  dwReserved,
OLE_COLOR  clrReserved,
REFIID  riid,
LPVOID ppvRet 
)

Definition at line 2475 of file olepicture.c.

2478{
2479 IStream *stream;
2480 HRESULT hRes;
2481 WCHAR *file_candidate;
2482 WCHAR path_buf[MAX_PATH];
2483
2484 TRACE("%s, %p, %ld, %#lx, %s, %p.\n", debugstr_w(szURLorPath), punkCaller, dwReserved,
2485 clrReserved, debugstr_guid(riid), ppvRet);
2486
2487 if (!szURLorPath || !ppvRet)
2488 return E_INVALIDARG;
2489
2490 *ppvRet = NULL;
2491
2492 /* Convert file URLs to DOS paths. */
2493 if (wcsncmp(szURLorPath, L"file:", 5) == 0) {
2494 DWORD size;
2495 hRes = CoInternetParseUrl(szURLorPath, PARSE_PATH_FROM_URL, 0, path_buf,
2496 ARRAY_SIZE(path_buf), &size, 0);
2497 if (FAILED(hRes))
2498 return hRes;
2499
2500 file_candidate = path_buf;
2501 }
2502 else
2503 file_candidate = szURLorPath;
2504
2505 /* Handle candidate DOS paths separately. */
2506 if (file_candidate[1] == ':') {
2507 hRes = create_stream(file_candidate, &stream);
2508 if (FAILED(hRes))
2510 } else {
2511 IMoniker *pmnk;
2512 IBindCtx *pbc;
2513
2514 hRes = CreateBindCtx(0, &pbc);
2515 if (SUCCEEDED(hRes))
2516 {
2517 hRes = CreateURLMoniker(NULL, szURLorPath, &pmnk);
2518 if (SUCCEEDED(hRes))
2519 {
2520 hRes = IMoniker_BindToStorage(pmnk, pbc, NULL, &IID_IStream, (LPVOID*)&stream);
2521 IMoniker_Release(pmnk);
2522 }
2523 IBindCtx_Release(pbc);
2524 }
2525 if (FAILED(hRes))
2526 return hRes;
2527 }
2528
2529 hRes = OleLoadPicture(stream, 0, FALSE, riid, ppvRet);
2530
2531 IStream_Release(stream);
2532
2533 return hRes;
2534}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define E_INVALIDARG
Definition: ddrawi.h:101
#define MAX_PATH
Definition: compat.h:34
_ACRTIMP int __cdecl wcsncmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:523
HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwFlags, LPWSTR pszResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: internet.c:325
#define L(x)
Definition: resources.c:13
GLsizeiptr size
Definition: glext.h:5919
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_w
Definition: kernel32.h:32
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
HRESULT WINAPI CreateBindCtx(DWORD reserved, IBindCtx **bind_context)
Definition: bindctx.c:491
short WCHAR
Definition: pedump.c:58
HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk)
Definition: umon.c:747
#define INET_E_RESOURCE_NOT_FOUND
Definition: winerror.h:4655

Referenced by test_OleLoadPicturePath().

◆ OLEPicture_SendNotify()

static void OLEPicture_SendNotify ( OLEPictureImpl this,
DISPID  dispID 
)
static

Definition at line 468 of file olepicture.c.

469{
470 IEnumConnections *pEnum;
471 CONNECTDATA CD;
472
473 if (IConnectionPoint_EnumConnections(this->pCP, &pEnum) != S_OK)
474 return;
475 while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
477
478 IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink);
479 IPropertyNotifySink_OnChanged(sink, dispID);
480 IPropertyNotifySink_Release(sink);
481 IUnknown_Release(CD.pUnk);
482 }
483 IEnumConnections_Release(pEnum);
484}
GLsizei GLenum GLboolean sink
Definition: glext.h:5672
const GUID IID_IPropertyNotifySink

Referenced by OLEPictureImpl_Load(), OLEPictureImpl_PictureChanged(), and OLEPictureImpl_set_hPal().

◆ OLEPictureImpl_AddRef()

static ULONG WINAPI OLEPictureImpl_AddRef ( IPicture iface)
static

Definition at line 402 of file olepicture.c.

404{
406 ULONG refCount = InterlockedIncrement(&This->ref);
407
408 TRACE("%p, refcount %lu.\n", iface, refCount);
409
410 return refCount;
411}
#define InterlockedIncrement
Definition: armddk.h:53
static OLEPictureImpl * impl_from_IPicture(IPicture *iface)
Definition: olepicture.c:154
uint32_t ULONG
Definition: typedefs.h:59

◆ OLEPictureImpl_Construct()

static HRESULT OLEPictureImpl_Construct ( LPPICTDESC  pictDesc,
BOOL  fOwn,
OLEPictureImpl **  pict 
)
static

Definition at line 268 of file olepicture.c.

269{
270 OLEPictureImpl *newObject;
271 HRESULT hr;
272
273 if (pictDesc)
274 TRACE("(%p) type = %d\n", pictDesc, pictDesc->picType);
275
276 /*
277 * Allocate space for the object.
278 */
279 newObject = calloc(1, sizeof(OLEPictureImpl));
280 if (!newObject)
281 return E_OUTOFMEMORY;
282
283 /*
284 * Initialize the virtual function table.
285 */
286 newObject->IPicture_iface.lpVtbl = &OLEPictureImpl_VTable;
290
291 newObject->pCP = NULL;
293 &newObject->pCP);
294 if (hr != S_OK)
295 {
296 free(newObject);
297 return hr;
298 }
299
300 /*
301 * Start with one reference count. The caller of this function
302 * must release the interface pointer when it is done.
303 */
304 newObject->ref = 1;
305 newObject->hDCCur = 0;
306
307 newObject->fOwn = fOwn;
308
309 /* dunno about original value */
310 newObject->keepOrigFormat = TRUE;
311
312 newObject->hbmMask = NULL;
313 newObject->hbmXor = NULL;
314 newObject->loadtime_magic = 0xdeadbeef;
315 newObject->loadtime_format = 0;
316 newObject->bIsDirty = FALSE;
317
318 if (pictDesc) {
319 newObject->desc = *pictDesc;
320
321 switch(pictDesc->picType) {
322 case PICTYPE_BITMAP:
323 OLEPictureImpl_SetBitmap(newObject);
324 break;
325
326 case PICTYPE_METAFILE:
327 TRACE("metafile handle %p\n", pictDesc->wmf.hmeta);
328 newObject->himetricWidth = pictDesc->wmf.xExt;
329 newObject->himetricHeight = pictDesc->wmf.yExt;
330 break;
331
332 case PICTYPE_NONE:
333 /* not sure what to do here */
334 newObject->himetricWidth = newObject->himetricHeight = 0;
335 break;
336
337 case PICTYPE_ICON:
338 OLEPictureImpl_SetIcon(newObject);
339 break;
340
342 FIXME("EMF is not supported\n");
343 newObject->himetricWidth = newObject->himetricHeight = 0;
344 break;
345
346 default:
347 WARN("Unsupported type %d\n", pictDesc->picType);
348 IPicture_Release(&newObject->IPicture_iface);
349 return E_UNEXPECTED;
350 }
351 } else {
353 }
354
355 TRACE("returning %p\n", newObject);
356 *pict = newObject;
357 return S_OK;
358}
#define WARN(fmt,...)
Definition: precomp.h:61
HRESULT CreateConnectionPoint(IUnknown *pUnk, REFIID riid, IConnectionPoint **pCP)
Definition: connpt.c:482
#define free
Definition: debug_ros.c:5
static const IConnectionPointContainerVtbl OLEPictureImpl_IConnectionPointContainer_VTable
Definition: olepicture.c:180
static const IPersistStreamVtbl OLEPictureImpl_IPersistStream_VTable
Definition: olepicture.c:179
static void OLEPictureImpl_SetIcon(OLEPictureImpl *This)
Definition: olepicture.c:227
static const IDispatchVtbl OLEPictureImpl_IDispatch_VTable
Definition: olepicture.c:178
static void OLEPictureImpl_SetBitmap(OLEPictureImpl *This)
Definition: olepicture.c:197
static const IPictureVtbl OLEPictureImpl_VTable
Definition: olepicture.c:177
#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
#define calloc
Definition: rosglue.h:14
unsigned int loadtime_magic
Definition: olepicture.c:150
HBITMAP hbmMask
Definition: olepicture.c:142
IConnectionPointContainer IConnectionPointContainer_iface
Definition: olepicture.c:116
PICTDESC desc
Definition: olepicture.c:125
BOOL keepOrigFormat
Definition: olepicture.c:137
OLE_YSIZE_HIMETRIC himetricHeight
Definition: olepicture.c:133
IConnectionPoint * pCP
Definition: olepicture.c:135
IDispatch IDispatch_iface
Definition: olepicture.c:114
OLE_XSIZE_HIMETRIC himetricWidth
Definition: olepicture.c:132
unsigned int loadtime_format
Definition: olepicture.c:151
HBITMAP hbmXor
Definition: olepicture.c:143
IPersistStream IPersistStream_iface
Definition: olepicture.c:115
struct tagPICTDESC::@3475::@3477 wmf
UINT picType
Definition: olectl.h:140
#define E_UNEXPECTED
Definition: winerror.h:3528

Referenced by OleCreatePictureIndirect().

◆ OLEPictureImpl_Destroy()

static void OLEPictureImpl_Destroy ( OLEPictureImpl Obj)
static

Definition at line 366 of file olepicture.c.

367{
368 TRACE("(%p)\n", Obj);
369
370 if (Obj->pCP)
371 IConnectionPoint_Release(Obj->pCP);
372
373 if(Obj->fOwn) { /* We need to destroy the picture */
374 switch(Obj->desc.picType) {
375 case PICTYPE_BITMAP:
376 DeleteObject(Obj->desc.bmp.hbitmap);
377 if (Obj->hbmMask != NULL) DeleteObject(Obj->hbmMask);
378 if (Obj->hbmXor != NULL) DeleteObject(Obj->hbmXor);
379 break;
380 case PICTYPE_METAFILE:
381 DeleteMetaFile(Obj->desc.wmf.hmeta);
382 break;
383 case PICTYPE_ICON:
384 DestroyIcon(Obj->desc.icon.hicon);
385 break;
387 DeleteEnhMetaFile(Obj->desc.emf.hemf);
388 break;
389 case PICTYPE_NONE:
391 /* Nothing to do */
392 break;
393 default:
394 FIXME("Unsupported type %d - unable to delete\n", Obj->desc.picType);
395 break;
396 }
397 }
398 free(Obj->data);
399 free(Obj);
400}
pKey DeleteObject()
BOOL WINAPI DeleteMetaFile(_In_ HMETAFILE)
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2422

Referenced by OLEPictureImpl_Release().

◆ OLEPictureImpl_EnumConnectionPoints()

static HRESULT WINAPI OLEPictureImpl_EnumConnectionPoints ( IConnectionPointContainer iface,
IEnumConnectionPoints **  ppEnum 
)
static

Definition at line 890 of file olepicture.c.

893{
895
896 FIXME("(%p,%p), stub!\n",This,ppEnum);
897 return E_NOTIMPL;
898}
#define E_NOTIMPL
Definition: ddrawi.h:99
static OLEPictureImpl * impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
Definition: olepicture.c:169

◆ OLEPictureImpl_FindConnectionPoint()

static HRESULT WINAPI OLEPictureImpl_FindConnectionPoint ( IConnectionPointContainer iface,
REFIID  riid,
IConnectionPoint **  ppCP 
)
static

Definition at line 900 of file olepicture.c.

904{
906 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppCP);
907 if (!ppCP)
908 return E_POINTER;
909 *ppCP = NULL;
911 return IConnectionPoint_QueryInterface(This->pCP, &IID_IConnectionPoint, (void**)ppCP);
912 FIXME("no connection point for %s\n",debugstr_guid(riid));
914}
#define CONNECT_E_NOCONNECTION
Definition: olectl.h:251
const GUID IID_IConnectionPoint
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_POINTER
Definition: winerror.h:3480

◆ OLEPictureImpl_get_Attributes()

static HRESULT WINAPI OLEPictureImpl_get_Attributes ( IPicture iface,
DWORD pdwAttr 
)
static

Definition at line 838 of file olepicture.c.

840{
842 TRACE("(%p)->(%p).\n", This, pdwAttr);
843
844 if(!pdwAttr)
845 return E_POINTER;
846
847 *pdwAttr = 0;
848 switch (This->desc.picType) {
850 case PICTYPE_NONE: break;
851 case PICTYPE_BITMAP: if (This->hbmMask) *pdwAttr = PICTURE_TRANSPARENT; break; /* not 'truly' scalable, see MSDN. */
852 case PICTYPE_ICON: *pdwAttr = PICTURE_TRANSPARENT;break;
853 case PICTYPE_ENHMETAFILE: /* fall through */
854 case PICTYPE_METAFILE: *pdwAttr = PICTURE_TRANSPARENT|PICTURE_SCALABLE;break;
855 default:FIXME("Unknown pictype %d\n",This->desc.picType);break;
856 }
857 return S_OK;
858}

◆ OLEPictureImpl_get_CurDC()

static HRESULT WINAPI OLEPictureImpl_get_CurDC ( IPicture iface,
HDC phdc 
)
static

Definition at line 749 of file olepicture.c.

751{
753 TRACE("(%p), returning %p\n", This, This->hDCCur);
754 if (phdc) *phdc = This->hDCCur;
755 return S_OK;
756}

◆ OLEPictureImpl_get_Handle()

static HRESULT WINAPI OLEPictureImpl_get_Handle ( IPicture iface,
OLE_HANDLE *  phandle 
)
static

Definition at line 489 of file olepicture.c.

491{
493 TRACE("(%p)->(%p)\n", This, phandle);
494
495 if(!phandle)
496 return E_POINTER;
497
498 switch(This->desc.picType) {
499 case PICTYPE_NONE:
501 *phandle = 0;
502 break;
503 case PICTYPE_BITMAP:
504 *phandle = HandleToUlong(This->desc.bmp.hbitmap);
505 break;
506 case PICTYPE_METAFILE:
507 *phandle = HandleToUlong(This->desc.wmf.hmeta);
508 break;
509 case PICTYPE_ICON:
510 *phandle = HandleToUlong(This->desc.icon.hicon);
511 break;
513 *phandle = HandleToUlong(This->desc.emf.hemf);
514 break;
515 default:
516 FIXME("Unimplemented type %d\n", This->desc.picType);
517 return E_NOTIMPL;
518 }
519 TRACE("returning handle %08x\n", *phandle);
520 return S_OK;
521}
#define HandleToUlong(h)
Definition: basetsd.h:73

◆ OLEPictureImpl_get_Height()

static HRESULT WINAPI OLEPictureImpl_get_Height ( IPicture iface,
OLE_YSIZE_HIMETRIC *  pheight 
)
static

Definition at line 568 of file olepicture.c.

569{
571 TRACE("%p, %p.\n", iface, pheight);
572 *pheight = This->himetricHeight;
573 return S_OK;
574}

◆ OLEPictureImpl_get_hPal()

static HRESULT WINAPI OLEPictureImpl_get_hPal ( IPicture iface,
OLE_HANDLE *  phandle 
)
static

Definition at line 526 of file olepicture.c.

528{
530
531 TRACE("(%p)->(%p)\n", This, phandle);
532
533 if (!phandle) return E_POINTER;
534
535 if (This->desc.picType == PICTYPE_BITMAP)
536 {
537 *phandle = HandleToUlong(This->desc.bmp.hpal);
538 return S_OK;
539 }
540
541 return E_FAIL;
542}
#define E_FAIL
Definition: ddrawi.h:102

◆ OLEPictureImpl_get_KeepOriginalFormat()

static HRESULT WINAPI OLEPictureImpl_get_KeepOriginalFormat ( IPicture iface,
BOOL pfKeep 
)
static

Definition at line 786 of file olepicture.c.

788{
790 TRACE("(%p)->(%p)\n", This, pfKeep);
791 if (!pfKeep)
792 return E_POINTER;
793 *pfKeep = This->keepOrigFormat;
794 return S_OK;
795}

◆ OLEPictureImpl_get_Type()

static HRESULT WINAPI OLEPictureImpl_get_Type ( IPicture iface,
short ptype 
)
static

Definition at line 547 of file olepicture.c.

549{
551 TRACE("(%p)->(%p): type is %d\n", This, ptype, This->desc.picType);
552
553 if(!ptype)
554 return E_POINTER;
555
556 *ptype = This->desc.picType;
557 return S_OK;
558}

Referenced by OLEPictureImpl_Invoke().

◆ OLEPictureImpl_get_Width()

static HRESULT WINAPI OLEPictureImpl_get_Width ( IPicture iface,
OLE_XSIZE_HIMETRIC *  pwidth 
)
static

Definition at line 560 of file olepicture.c.

561{
563 TRACE("%p, %p.\n", iface, pwidth);
564 *pwidth = This->himetricWidth;
565 return S_OK;
566}

◆ OLEPictureImpl_GetClassID()

static HRESULT WINAPI OLEPictureImpl_GetClassID ( IPersistStream iface,
CLSID pClassID 
)
static

Definition at line 965 of file olepicture.c.

967{
968 TRACE("(%p)\n", pClassID);
969 *pClassID = CLSID_StdPicture;
970 return S_OK;
971}
const GUID CLSID_StdPicture

◆ OLEPictureImpl_GetIDsOfNames()

static HRESULT WINAPI OLEPictureImpl_GetIDsOfNames ( IDispatch iface,
REFIID  riid,
LPOLESTR *  rgszNames,
UINT  cNames,
LCID  lcid,
DISPID rgDispId 
)
static

Definition at line 2044 of file olepicture.c.

2051{
2052 ITypeInfo * pTInfo;
2053 HRESULT hres;
2054
2055 TRACE("(%p,%s,%p,cNames=%d,lcid=%04x,%p)\n", iface, debugstr_guid(riid),
2056 rgszNames, cNames, (int)lcid, rgDispId);
2057
2058 if (cNames == 0)
2059 {
2060 return E_INVALIDARG;
2061 }
2062 else
2063 {
2064 /* retrieve type information */
2065 hres = OLEPictureImpl_GetTypeInfo(iface, 0, lcid, &pTInfo);
2066
2067 if (FAILED(hres))
2068 {
2069 ERR("GetTypeInfo failed.\n");
2070 return hres;
2071 }
2072
2073 /* convert names to DISPIDs */
2074 hres = DispGetIDsOfNames (pTInfo, rgszNames, cNames, rgDispId);
2075 ITypeInfo_Release(pTInfo);
2076
2077 return hres;
2078 }
2079}
LCID lcid
Definition: locale.c:5660
HRESULT WINAPI DispGetIDsOfNames(ITypeInfo *ptinfo, OLECHAR **rgszNames, UINT cNames, DISPID *rgdispid)
Definition: dispatch.c:92
static HRESULT WINAPI OLEPictureImpl_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: olepicture.c:2011
HRESULT hres
Definition: protocol.c:465

◆ OLEPictureImpl_GetSizeMax()

static HRESULT WINAPI OLEPictureImpl_GetSizeMax ( IPersistStream iface,
ULARGE_INTEGER size 
)
static

Definition at line 1888 of file olepicture.c.

1889{
1892 unsigned int datasize = This->datalen;
1893
1894 FIXME("(%p,%p), partial stub!\n", This, size);
1895
1896 if (!size)
1897 return E_INVALIDARG;
1898
1899 switch (This->desc.picType) {
1900 case PICTYPE_NONE:
1901 hr = S_OK;
1902 break;
1903 case PICTYPE_ICON:
1904 FIXME("(%p), PICTYPE_ICON not implemented!\n",This);
1905 break;
1906 case PICTYPE_BITMAP:
1907 if (This->bIsDirty || !This->data) {
1908 switch (This->keepOrigFormat ? This->loadtime_format : BITMAP_FORMAT_BMP) {
1909 case BITMAP_FORMAT_BMP:
1910 hr = serializeBMP(This->desc.bmp.hbitmap, NULL, &datasize);
1911 break;
1912 case BITMAP_FORMAT_JPEG:
1913 FIXME("(%p), PICTYPE_BITMAP (format JPEG) not implemented!\n",This);
1914 break;
1915 case BITMAP_FORMAT_GIF:
1916 FIXME("(%p), PICTYPE_BITMAP (format GIF) not implemented!\n",This);
1917 break;
1918 case BITMAP_FORMAT_PNG:
1919 FIXME("(%p), PICTYPE_BITMAP (format PNG) not implemented!\n",This);
1920 break;
1921 default:
1922 FIXME("(%p), PICTYPE_BITMAP (format UNKNOWN, using BMP?) not implemented!\n",This);
1923 break;
1924 }
1925 } else hr = S_OK;
1926
1927 break;
1928 case PICTYPE_METAFILE:
1929 FIXME("(%p), PICTYPE_METAFILE not implemented!\n",This);
1930 break;
1932 FIXME("(%p), PICTYPE_ENHMETAFILE not implemented!\n",This);
1933 break;
1934 default:
1935 FIXME("(%p), [unknown type] not implemented!\n",This);
1936 break;
1937 }
1938
1939 size->HighPart = 0;
1940 size->LowPart = datasize + 8;
1941 return hr;
1942}
static SIZE_T datasize
Definition: asm.c:30
#define BITMAP_FORMAT_JPEG
Definition: olepicture.c:61
#define BITMAP_FORMAT_GIF
Definition: olepicture.c:62
static HRESULT serializeBMP(HBITMAP hbmp, void **buffer, unsigned int *length)
Definition: olepicture.c:1537
static OLEPictureImpl * impl_from_IPersistStream(IPersistStream *iface)
Definition: olepicture.c:164
#define BITMAP_FORMAT_PNG
Definition: olepicture.c:63
#define BITMAP_FORMAT_BMP
Definition: olepicture.c:60

◆ OLEPictureImpl_GetTypeInfo()

static HRESULT WINAPI OLEPictureImpl_GetTypeInfo ( IDispatch iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 2011 of file olepicture.c.

2016{
2017 ITypeLib *tl;
2018 HRESULT hres;
2019
2020 TRACE("(iTInfo=%d, lcid=%04x, %p)\n", iTInfo, (int)lcid, ppTInfo);
2021
2022 if (iTInfo != 0)
2023 return E_FAIL;
2024
2025 hres = LoadTypeLib(L"stdole2.tlb", &tl);
2026 if (FAILED(hres))
2027 {
2028 ERR("Could not load stdole2.tlb\n");
2029 return hres;
2030 }
2031
2032 hres = ITypeLib_GetTypeInfoOfGuid(tl, &IID_IPictureDisp, ppTInfo);
2033 if (FAILED(hres))
2034 ERR("Did not get IPictureDisp typeinfo from typelib, hres %#lx.\n", hres);
2035
2036 return hres;
2037}
HRESULT WINAPI LoadTypeLib(const OLECHAR *szFile, ITypeLib **pptLib)
Definition: typelib.c:434
const GUID IID_IPictureDisp

Referenced by OLEPictureImpl_GetIDsOfNames().

◆ OLEPictureImpl_GetTypeInfoCount()

static HRESULT WINAPI OLEPictureImpl_GetTypeInfoCount ( IDispatch iface,
unsigned int pctinfo 
)
static

Definition at line 1995 of file olepicture.c.

1998{
1999 TRACE("(%p)\n", pctinfo);
2000
2001 *pctinfo = 1;
2002
2003 return S_OK;
2004}

◆ OLEPictureImpl_IConnectionPointContainer_AddRef()

static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_AddRef ( IConnectionPointContainer iface)
static

Definition at line 874 of file olepicture.c.

876{
878
879 return IPicture_AddRef(&This->IPicture_iface);
880}

◆ OLEPictureImpl_IConnectionPointContainer_QueryInterface()

static HRESULT WINAPI OLEPictureImpl_IConnectionPointContainer_QueryInterface ( IConnectionPointContainer iface,
REFIID  riid,
VOID **  ppvoid 
)
static

Definition at line 864 of file olepicture.c.

868{
870
871 return IPicture_QueryInterface(&This->IPicture_iface,riid,ppvoid);
872}

◆ OLEPictureImpl_IConnectionPointContainer_Release()

static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_Release ( IConnectionPointContainer iface)
static

Definition at line 882 of file olepicture.c.

884{
886
887 return IPicture_Release(&This->IPicture_iface);
888}

◆ OLEPictureImpl_IDispatch_AddRef()

static ULONG WINAPI OLEPictureImpl_IDispatch_AddRef ( IDispatch iface)
static

Definition at line 1969 of file olepicture.c.

1971{
1973
1974 return IPicture_AddRef(&This->IPicture_iface);
1975}
static OLEPictureImpl * impl_from_IDispatch(IDispatch *iface)
Definition: olepicture.c:159

◆ OLEPictureImpl_IDispatch_QueryInterface()

static HRESULT WINAPI OLEPictureImpl_IDispatch_QueryInterface ( IDispatch iface,
REFIID  riid,
VOID **  ppvoid 
)
static

Definition at line 1954 of file olepicture.c.

1958{
1960
1961 return IPicture_QueryInterface(&This->IPicture_iface, riid, ppvoid);
1962}

◆ OLEPictureImpl_IDispatch_Release()

static ULONG WINAPI OLEPictureImpl_IDispatch_Release ( IDispatch iface)
static

Definition at line 1982 of file olepicture.c.

1984{
1986
1987 return IPicture_Release(&This->IPicture_iface);
1988}

◆ OLEPictureImpl_Invoke()

static HRESULT WINAPI OLEPictureImpl_Invoke ( IDispatch iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT pVarResult,
EXCEPINFO *  pExepInfo,
UINT puArgErr 
)
static

Definition at line 2086 of file olepicture.c.

2096{
2098 HRESULT hr;
2099
2100 /* validate parameters */
2101
2102 if (!IsEqualIID(riid, &IID_NULL))
2103 {
2104 ERR("riid was %s instead of IID_NULL\n", debugstr_guid(riid));
2105 return DISP_E_UNKNOWNNAME;
2106 }
2107
2108 if (!pDispParams)
2109 {
2110 ERR("null pDispParams not allowed\n");
2112 }
2113
2115 {
2116 if (pDispParams->cArgs != 0)
2117 {
2118 ERR("param count for DISPATCH_PROPERTYGET was %d instead of 0\n", pDispParams->cArgs);
2119 return DISP_E_BADPARAMCOUNT;
2120 }
2121 if (!pVarResult)
2122 {
2123 ERR("null pVarResult not allowed when DISPATCH_PROPERTYGET specified\n");
2125 }
2126 }
2127 else if (wFlags & DISPATCH_PROPERTYPUT)
2128 {
2129 if (pDispParams->cArgs != 1)
2130 {
2131 ERR("param count for DISPATCH_PROPERTYPUT was %d instead of 1\n", pDispParams->cArgs);
2132 return DISP_E_BADPARAMCOUNT;
2133 }
2134 }
2135
2136 switch (dispIdMember)
2137 {
2138 case DISPID_PICT_HANDLE:
2140 {
2141 TRACE("DISPID_PICT_HANDLE\n");
2142 V_VT(pVarResult) = VT_I4;
2143 return IPicture_get_Handle(&This->IPicture_iface, &V_UINT(pVarResult));
2144 }
2145 break;
2146 case DISPID_PICT_HPAL:
2148 {
2149 TRACE("DISPID_PICT_HPAL\n");
2150 V_VT(pVarResult) = VT_I4;
2151 return IPicture_get_hPal(&This->IPicture_iface, &V_UINT(pVarResult));
2152 }
2153 else if (wFlags & DISPATCH_PROPERTYPUT)
2154 {
2155 VARIANTARG vararg;
2156
2157 TRACE("DISPID_PICT_HPAL\n");
2158
2159 VariantInit(&vararg);
2160 hr = VariantChangeTypeEx(&vararg, &pDispParams->rgvarg[0], lcid, 0, VT_I4);
2161 if (FAILED(hr))
2162 return hr;
2163
2164 hr = IPicture_set_hPal(&This->IPicture_iface, V_I4(&vararg));
2165
2166 VariantClear(&vararg);
2167 return hr;
2168 }
2169 break;
2170 case DISPID_PICT_TYPE:
2172 {
2173 TRACE("DISPID_PICT_TYPE\n");
2174 V_VT(pVarResult) = VT_I2;
2175 return OLEPictureImpl_get_Type(&This->IPicture_iface, &V_I2(pVarResult));
2176 }
2177 break;
2178 case DISPID_PICT_WIDTH:
2180 {
2181 TRACE("DISPID_PICT_WIDTH\n");
2182 V_VT(pVarResult) = VT_I4;
2183 return IPicture_get_Width(&This->IPicture_iface, &V_I4(pVarResult));
2184 }
2185 break;
2186 case DISPID_PICT_HEIGHT:
2188 {
2189 TRACE("DISPID_PICT_HEIGHT\n");
2190 V_VT(pVarResult) = VT_I4;
2191 return IPicture_get_Height(&This->IPicture_iface, &V_I4(pVarResult));
2192 }
2193 break;
2194 case DISPID_PICT_RENDER:
2195 if (wFlags & DISPATCH_METHOD)
2196 {
2197 VARIANTARG *args = pDispParams->rgvarg;
2198 int i;
2199
2200 TRACE("DISPID_PICT_RENDER\n");
2201
2202 if (pDispParams->cArgs != 10)
2203 return DISP_E_BADPARAMCOUNT;
2204
2205 /* All parameters are supposed to be VT_I4 (on 64 bits too). */
2206 for (i = 0; i < pDispParams->cArgs; i++)
2207 if (V_VT(&args[i]) != VT_I4)
2208 {
2209 ERR("DISPID_PICT_RENDER: wrong argument type %d:%d\n", i, V_VT(&args[i]));
2210 return DISP_E_TYPEMISMATCH;
2211 }
2212
2213 /* FIXME: rectangle pointer argument handling seems broken on 64 bits,
2214 currently Render() doesn't use it at all so for now NULL is passed. */
2215 return IPicture_Render(&This->IPicture_iface,
2216 LongToHandle(V_I4(&args[9])),
2217 V_I4(&args[8]),
2218 V_I4(&args[7]),
2219 V_I4(&args[6]),
2220 V_I4(&args[5]),
2221 V_I4(&args[4]),
2222 V_I4(&args[3]),
2223 V_I4(&args[2]),
2224 V_I4(&args[1]),
2225 NULL);
2226 }
2227 break;
2228 }
2229
2230 ERR("invalid dispid %#lx or wFlags 0x%x\n", dispIdMember, wFlags);
2231 return DISP_E_MEMBERNOTFOUND;
2232}
#define LongToHandle(h)
Definition: basetsd.h:76
@ VT_I4
Definition: compat.h:2298
@ VT_I2
Definition: compat.h:2297
static HRESULT WINAPI OLEPictureImpl_get_Type(IPicture *iface, short *ptype)
Definition: olepicture.c:547
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 DISPATCH_PROPERTYPUT
Definition: oleauto.h:1008
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define V_I4(A)
Definition: oleauto.h:247
#define V_UINT(A)
Definition: oleauto.h:264
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define V_I2(A)
Definition: oleauto.h:245
#define DISPID_PICT_RENDER
Definition: olectl.h:443
#define DISPID_PICT_TYPE
Definition: olectl.h:440
#define DISPID_PICT_WIDTH
Definition: olectl.h:441
#define DISPID_PICT_HPAL
Definition: olectl.h:439
#define DISPID_PICT_HANDLE
Definition: olectl.h:438
#define DISPID_PICT_HEIGHT
Definition: olectl.h:442
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define IID_NULL
Definition: guiddef.h:98
Definition: match.c:390
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:626
HRESULT WINAPI VariantChangeTypeEx(VARIANTARG *pvargDest, const VARIANTARG *pvargSrc, LCID lcid, USHORT wFlags, VARTYPE vt)
Definition: variant.c:965
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:547
WINBASEAPI _In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon_undoc.h:337
#define DISP_E_BADPARAMCOUNT
Definition: winerror.h:3626
#define DISP_E_MEMBERNOTFOUND
Definition: winerror.h:3615
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:3617
#define DISP_E_PARAMNOTOPTIONAL
Definition: winerror.h:3627
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:3618

◆ OLEPictureImpl_IPersistStream_AddRef()

static ULONG WINAPI OLEPictureImpl_IPersistStream_AddRef ( IPersistStream iface)
static

Definition at line 941 of file olepicture.c.

943{
945
946 return IPicture_AddRef(&This->IPicture_iface);
947}

◆ OLEPictureImpl_IPersistStream_QueryInterface()

static HRESULT WINAPI OLEPictureImpl_IPersistStream_QueryInterface ( IPersistStream iface,
REFIID  riid,
VOID **  ppvoid 
)
static

Definition at line 926 of file olepicture.c.

930{
932
933 return IPicture_QueryInterface(&This->IPicture_iface, riid, ppvoid);
934}

◆ OLEPictureImpl_IPersistStream_Release()

static ULONG WINAPI OLEPictureImpl_IPersistStream_Release ( IPersistStream iface)
static

Definition at line 954 of file olepicture.c.

956{
958
959 return IPicture_Release(&This->IPicture_iface);
960}

◆ OLEPictureImpl_IsDirty()

static HRESULT WINAPI OLEPictureImpl_IsDirty ( IPersistStream iface)
static

Definition at line 976 of file olepicture.c.

978{
980 FIXME("(%p),stub!\n",This);
981 return E_NOTIMPL;
982}

◆ OLEPictureImpl_Load()

static HRESULT WINAPI OLEPictureImpl_Load ( IPersistStream iface,
IStream pStm 
)
static

Definition at line 1344 of file olepicture.c.

1344 {
1345 HRESULT hr;
1346 BOOL headerisdata;
1347 BOOL statfailed = FALSE;
1348 ULONG xread, toread;
1349 ULONG headerread;
1350 BYTE *xbuf;
1351 DWORD header[2];
1352 WORD magic;
1353 STATSTG statstg;
1355
1356 TRACE("(%p,%p)\n",This,pStm);
1357
1358 /****************************************************************************************
1359 * Part 1: Load the data
1360 */
1361 /* Sometimes we have a header, sometimes we don't. Apply some guesses to find
1362 * out whether we do.
1363 *
1364 * UPDATE: the IStream can be mapped to a plain file instead of a stream in a
1365 * compound file. This may explain most, if not all, of the cases of "no
1366 * header", and the header validation should take this into account.
1367 * At least in Visual Basic 6, resource streams, valid headers are
1368 * header[0] == "lt\0\0",
1369 * header[1] == length_of_stream.
1370 *
1371 * Also handle streams where we do not have a working "Stat" method by
1372 * reading all data until the end of the stream.
1373 */
1374 hr = IStream_Stat(pStm,&statstg,STATFLAG_NONAME);
1375 if (hr != S_OK) {
1376 TRACE("stat failed with hres %#lx, proceeding to read all data.\n",hr);
1377 statfailed = TRUE;
1378 /* we will read at least 8 byte ... just right below */
1379 statstg.cbSize.QuadPart = 8;
1380 }
1381
1382 toread = 0;
1383 headerread = 0;
1384 headerisdata = FALSE;
1385 do {
1386 hr = IStream_Read(pStm, header, 8, &xread);
1387 if (hr != S_OK || xread!=8) {
1388 ERR("Failure while reading picture header (hr is %#lx, nread is %ld).\n",hr,xread);
1389 return (hr?hr:E_FAIL);
1390 }
1391 headerread += xread;
1392 xread = 0;
1393
1394 if (!memcmp(&(header[0]),"lt\0\0", 4) && (statfailed || (header[1] + headerread <= statstg.cbSize.QuadPart))) {
1395 if (toread != 0 && toread != header[1])
1396 FIXME("varying lengths of image data (prev=%lu curr=%lu), only last one will be used\n",
1397 toread, header[1]);
1398 toread = header[1];
1399 if (statfailed)
1400 {
1401 statstg.cbSize.QuadPart = header[1] + 8;
1402 statfailed = FALSE;
1403 }
1404 if (toread == 0) break;
1405 } else {
1406 if (!memcmp(&(header[0]), "GIF8", 4) || /* GIF header */
1407 !memcmp(&(header[0]), "BM", 2) || /* BMP header */
1408 !memcmp(&(header[0]), "\xff\xd8", 2) || /* JPEG header */
1409 (header[0] == EMR_HEADER) || /* EMF header */
1410 (header[0] == 0x10000) || /* icon: idReserved 0, idType 1 */
1411 (header[0] == 0x20000) || /* cursor: idReserved 0, idType 2 */
1412 (header[1] > statstg.cbSize.QuadPart)|| /* invalid size */
1413 (header[1]==0)
1414 ) {/* Found start of bitmap data */
1415 headerisdata = TRUE;
1416 if (toread == 0)
1417 toread = statstg.cbSize.QuadPart-8;
1418 else toread -= 8;
1419 xread = 8;
1420 } else {
1421 FIXME("Unknown stream header magic: %#lx.\n", header[0]);
1422 toread = header[1];
1423 }
1424 }
1425 } while (!headerisdata);
1426
1427 if (statfailed) { /* we don't know the size ... read all we get */
1428 unsigned int sizeinc = 4096;
1429 unsigned int origsize = sizeinc;
1430 ULONG nread = 42;
1431
1432 TRACE("Reading all data from stream.\n");
1433 xbuf = calloc(1, origsize);
1434 if (headerisdata)
1435 memcpy (xbuf, header, 8);
1436 while (1) {
1437 while (xread < origsize) {
1438 hr = IStream_Read(pStm,xbuf+xread,origsize-xread,&nread);
1439 xread += nread;
1440 if (hr != S_OK || !nread)
1441 break;
1442 }
1443 if (!nread || hr != S_OK) /* done, or error */
1444 break;
1445 if (xread == origsize) {
1446 sizeinc = 2*sizeinc; /* exponential increase */
1447 xbuf = realloc(xbuf, origsize + sizeinc);
1448 memset(xbuf + origsize, 0, sizeinc);
1449 origsize += sizeinc;
1450 }
1451 }
1452 if (hr != S_OK)
1453 TRACE("hr in no-stat loader case is %#lx.\n", hr);
1454 TRACE("loaded %ld bytes.\n", xread);
1455 This->datalen = xread;
1456 This->data = xbuf;
1457 } else {
1458 This->datalen = toread+(headerisdata?8:0);
1459 xbuf = This->data = calloc(1, This->datalen);
1460 if (!xbuf)
1461 return E_OUTOFMEMORY;
1462
1463 if (headerisdata)
1464 memcpy (xbuf, header, 8);
1465
1466 while (xread < This->datalen) {
1467 ULONG nread;
1468 hr = IStream_Read(pStm,xbuf+xread,This->datalen-xread,&nread);
1469 xread += nread;
1470 if (hr != S_OK || !nread)
1471 break;
1472 }
1473 if (xread != This->datalen)
1474 ERR("Could only read %ld of %d bytes out of stream?\n", xread, This->datalen);
1475 }
1476 if (This->datalen == 0) { /* Marks the "NONE" picture */
1477 This->desc.picType = PICTYPE_NONE;
1478 return S_OK;
1479 }
1480
1481
1482 /****************************************************************************************
1483 * Part 2: Process the loaded data
1484 */
1485
1486 magic = xbuf[0] + (xbuf[1]<<8);
1487 This->loadtime_format = magic;
1488
1489 switch (magic) {
1490 case BITMAP_FORMAT_GIF: /* GIF */
1491 hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICGifDecoder, xbuf, xread);
1492 break;
1493 case BITMAP_FORMAT_JPEG: /* JPEG */
1494 hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICJpegDecoder, xbuf, xread);
1495 break;
1496 case BITMAP_FORMAT_BMP: /* Bitmap */
1497 hr = OLEPictureImpl_LoadDIB(This, xbuf, xread);
1498 break;
1499 case BITMAP_FORMAT_PNG: /* PNG */
1500 hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICPngDecoder, xbuf, xread);
1501 break;
1502 case BITMAP_FORMAT_APM: /* APM */
1503 hr = OLEPictureImpl_LoadAPM(This, xbuf, xread);
1504 break;
1505 case 0x0000: { /* ICON or CURSOR, first word is dwReserved */
1506 hr = OLEPictureImpl_LoadIcon(This, xbuf, xread);
1507 break;
1508 }
1509 default:
1510 {
1511 unsigned int i;
1512
1513 /* let's see if it's a EMF */
1514 hr = OLEPictureImpl_LoadEnhMetafile(This, xbuf, xread);
1515 if (hr == S_OK) break;
1516
1517 FIXME("Unknown magic %04x, %ld read bytes:\n", magic, xread);
1518 hr=E_FAIL;
1519 for (i=0;i<xread+8;i++) {
1520 if (i<8) FIXME("%02x ",((unsigned char*)header)[i]);
1521 else FIXME("%02x ",xbuf[i-8]);
1522 if (i % 10 == 9) FIXME("\n");
1523 }
1524 FIXME("\n");
1525 break;
1526 }
1527 }
1528 This->bIsDirty = FALSE;
1529
1530 /* FIXME: this notify is not really documented */
1531 if (hr==S_OK)
1533 return hr;
1534}
#define realloc
Definition: debug_ros.c:6
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
static HRESULT OLEPictureImpl_LoadWICDecoder(OLEPictureImpl *This, REFCLSID decoder_clsid, BYTE *xbuf, ULONG xread)
Definition: olepicture.c:1137
static void OLEPicture_SendNotify(OLEPictureImpl *this, DISPID dispID)
Definition: olepicture.c:468
static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
Definition: olepicture.c:1192
static HRESULT OLEPictureImpl_LoadDIB(OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
Definition: olepicture.c:984
#define BITMAP_FORMAT_APM
Definition: olepicture.c:64
static HRESULT OLEPictureImpl_LoadEnhMetafile(OLEPictureImpl *This, const BYTE *data, ULONG size)
Definition: olepicture.c:1285
static HRESULT OLEPictureImpl_LoadAPM(OLEPictureImpl *This, const BYTE *data, ULONG size)
Definition: olepicture.c:1307
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1033
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static DWORD nread
Definition: url.c:172
#define memset(x, y, z)
Definition: compat.h:39
#define EMR_HEADER
Definition: wingdi.h:75
unsigned char BYTE
Definition: xxhash.c:193

◆ OLEPictureImpl_LoadAPM()

static HRESULT OLEPictureImpl_LoadAPM ( OLEPictureImpl This,
const BYTE data,
ULONG  size 
)
static

Definition at line 1307 of file olepicture.c.

1309{
1310 const APM_HEADER *header = (const APM_HEADER *)data;
1311 HMETAFILE hmf;
1312
1313 if (size < sizeof(APM_HEADER))
1314 return E_FAIL;
1315 if (header->key != 0x9ac6cdd7)
1316 return E_FAIL;
1317
1318 /* SetMetaFileBitsEx performs data check on its own */
1319 hmf = SetMetaFileBitsEx(size - sizeof(*header), data + sizeof(*header));
1320 if (!hmf) return E_FAIL;
1321
1322 This->desc.picType = PICTYPE_METAFILE;
1323 This->desc.wmf.hmeta = hmf;
1324 This->desc.wmf.xExt = 0;
1325 This->desc.wmf.yExt = 0;
1326
1327 This->origWidth = 0;
1328 This->origHeight = 0;
1329 This->himetricWidth = MulDiv((INT)header->right - header->left, 2540, header->inch);
1330 This->himetricHeight = MulDiv((INT)header->bottom - header->top, 2540, header->inch);
1331 return S_OK;
1332}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
int32_t INT
Definition: typedefs.h:58
HMETAFILE WINAPI SetMetaFileBitsEx(_In_ UINT cbBuffer, _In_reads_bytes_(cbBuffer) CONST BYTE *lpData)

Referenced by OLEPictureImpl_Load().

◆ OLEPictureImpl_LoadDIB()

static HRESULT OLEPictureImpl_LoadDIB ( OLEPictureImpl This,
BYTE xbuf,
ULONG  xread 
)
static

Definition at line 984 of file olepicture.c.

985{
987 BITMAPINFO *bi = (BITMAPINFO*)(bfh+1);
988 HDC hdcref;
989
990 /* Does not matter whether this is a coreheader or not, we only use
991 * components which are in both
992 */
993 hdcref = GetDC(0);
994 This->desc.bmp.hbitmap = CreateDIBitmap(
995 hdcref,
996 &(bi->bmiHeader),
997 CBM_INIT,
998 xbuf+bfh->bfOffBits,
999 bi,
1001 );
1002 ReleaseDC(0, hdcref);
1003 if (This->desc.bmp.hbitmap == 0)
1004 return E_FAIL;
1005 This->desc.picType = PICTYPE_BITMAP;
1007 return S_OK;
1008}
static HDC
Definition: imagelist.c:88
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1922
#define DIB_RGB_COLORS
Definition: wingdi.h:367
#define CBM_INIT
Definition: wingdi.h:365
HBITMAP WINAPI CreateDIBitmap(_In_ HDC hdc, _In_opt_ const BITMAPINFOHEADER *pbmih, _In_ DWORD fdwInit, _In_opt_ const VOID *pvInit, _In_opt_ const BITMAPINFO *pbmi, _In_ UINT uUsage)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by OLEPictureImpl_Load().

◆ OLEPictureImpl_LoadEnhMetafile()

static HRESULT OLEPictureImpl_LoadEnhMetafile ( OLEPictureImpl This,
const BYTE data,
ULONG  size 
)
static

Definition at line 1285 of file olepicture.c.

1287{
1288 HENHMETAFILE hemf;
1290
1291 hemf = SetEnhMetaFileBits(size, data);
1292 if (!hemf) return E_FAIL;
1293
1294 GetEnhMetaFileHeader(hemf, sizeof(hdr), &hdr);
1295
1296 This->desc.picType = PICTYPE_ENHMETAFILE;
1297 This->desc.emf.hemf = hemf;
1298
1299 This->origWidth = 0;
1300 This->origHeight = 0;
1301 This->himetricWidth = hdr.rclFrame.right - hdr.rclFrame.left;
1302 This->himetricHeight = hdr.rclFrame.bottom - hdr.rclFrame.top;
1303
1304 return S_OK;
1305}
char hdr[14]
Definition: iptest.cpp:33
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
UINT WINAPI GetEnhMetaFileHeader(_In_ HENHMETAFILE hemf, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPENHMETAHEADER lpEnhMetaHeader)

Referenced by OLEPictureImpl_Load().

◆ OLEPictureImpl_LoadIcon()

static HRESULT OLEPictureImpl_LoadIcon ( OLEPictureImpl This,
BYTE xbuf,
ULONG  xread 
)
static

Definition at line 1192 of file olepicture.c.

1193{
1194 HICON hicon;
1195 CURSORICONFILEDIR *cifd = (CURSORICONFILEDIR*)xbuf;
1196 HDC hdcRef;
1197 int i;
1198
1199 TRACE("(this %p, xbuf %p, xread %lu)\n", This, xbuf, xread);
1200
1201 /*
1202 FIXME("icon.idReserved=%d\n",cifd->idReserved);
1203 FIXME("icon.idType=%d\n",cifd->idType);
1204 FIXME("icon.idCount=%d\n",cifd->idCount);
1205
1206 for (i=0;i<cifd->idCount;i++) {
1207 FIXME("[%d] width %d\n",i,cifd->idEntries[i].bWidth);
1208 FIXME("[%d] height %d\n",i,cifd->idEntries[i].bHeight);
1209 FIXME("[%d] bColorCount %d\n",i,cifd->idEntries[i].bColorCount);
1210 FIXME("[%d] bReserved %d\n",i,cifd->idEntries[i].bReserved);
1211 FIXME("[%d] xHotspot %d\n",i,cifd->idEntries[i].xHotspot);
1212 FIXME("[%d] yHotspot %d\n",i,cifd->idEntries[i].yHotspot);
1213 FIXME("[%d] dwDIBSize %d\n",i,cifd->idEntries[i].dwDIBSize);
1214 FIXME("[%d] dwDIBOffset %d\n",i,cifd->idEntries[i].dwDIBOffset);
1215 }
1216 */
1217
1218 /* Need at least one icon to do something. */
1219 if (!cifd->idCount)
1220 {
1221 ERR("Invalid icon count of zero.\n");
1222 return E_FAIL;
1223 }
1224 i=0;
1225 /* If we have more than one icon, try to find the best.
1226 * this currently means '32 pixel wide'.
1227 */
1228 if (cifd->idCount!=1) {
1229 for (i=0;i<cifd->idCount;i++) {
1230 if (cifd->idEntries[i].bWidth == 32)
1231 break;
1232 }
1233 if (i==cifd->idCount) i=0;
1234 }
1235 if (xread < cifd->idEntries[i].dwDIBOffset + cifd->idEntries[i].dwDIBSize)
1236 {
1237 ERR("Icon data address %lu is over %lu bytes available.\n",
1238 cifd->idEntries[i].dwDIBOffset + cifd->idEntries[i].dwDIBSize, xread);
1239 return E_FAIL;
1240 }
1241 if (cifd->idType == 2)
1242 {
1243 BYTE *buf = malloc(cifd->idEntries[i].dwDIBSize + 4);
1244 memcpy(buf, &cifd->idEntries[i].xHotspot, 4);
1245 memcpy(buf + 4, xbuf+cifd->idEntries[i].dwDIBOffset, cifd->idEntries[i].dwDIBSize);
1247 buf,
1248 cifd->idEntries[i].dwDIBSize + 4,
1249 FALSE, /* is cursor */
1250 0x00030000,
1251 cifd->idEntries[i].bWidth,
1252 cifd->idEntries[i].bHeight,
1253 0
1254 );
1255 free(buf);
1256 }
1257 else
1258 {
1260 xbuf+cifd->idEntries[i].dwDIBOffset,
1261 cifd->idEntries[i].dwDIBSize,
1262 TRUE, /* is icon */
1263 0x00030000,
1264 cifd->idEntries[i].bWidth,
1265 cifd->idEntries[i].bHeight,
1266 0
1267 );
1268 }
1269 if (!hicon) {
1270 ERR("CreateIcon failed.\n");
1271 return E_FAIL;
1272 } else {
1273 This->desc.picType = PICTYPE_ICON;
1274 This->desc.icon.hicon = hicon;
1275 This->origWidth = cifd->idEntries[i].bWidth;
1276 This->origHeight = cifd->idEntries[i].bHeight;
1277 hdcRef = CreateCompatibleDC(0);
1278 This->himetricWidth = xpixels_to_himetric(cifd->idEntries[i].bWidth, hdcRef);
1279 This->himetricHeight= ypixels_to_himetric(cifd->idEntries[i].bHeight, hdcRef);
1280 DeleteDC(hdcRef);
1281 return S_OK;
1282 }
1283}
#define malloc
Definition: debug_ros.c:4
static OLE_YSIZE_HIMETRIC ypixels_to_himetric(INT pixels, HDC hdc)
Definition: olepicture.c:188
static OLE_XSIZE_HIMETRIC xpixels_to_himetric(INT pixels, HDC hdc)
Definition: olepicture.c:183
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static HICON
Definition: imagelist.c:80
CURSORICONFILEDIRENTRY idEntries[1]
Definition: olepicture.c:98
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)
HICON WINAPI CreateIconFromResourceEx(_In_reads_bytes_(dwResSize) PBYTE presbits, _In_ DWORD dwResSize, _In_ BOOL fIcon, _In_ DWORD dwVer, _In_ int cxDesired, _In_ int cyDesired, _In_ UINT Flags)

Referenced by OLEPictureImpl_Load().

◆ OLEPictureImpl_LoadWICDecoder()

static HRESULT OLEPictureImpl_LoadWICDecoder ( OLEPictureImpl This,
REFCLSID  decoder_clsid,
BYTE xbuf,
ULONG  xread 
)
static

Definition at line 1137 of file olepicture.c.

1138{
1139 HRESULT hr;
1142 IWICBitmapFrameDecode *framedecode;
1143 HRESULT initresult;
1145
1146 initresult = CoInitialize(NULL);
1147
1148 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
1149 &IID_IWICImagingFactory, (void**)&factory);
1150 if (SUCCEEDED(hr)) /* created factory */
1151 {
1152 hr = IWICImagingFactory_CreateStream(factory, &stream);
1153 IWICImagingFactory_Release(factory);
1154 }
1155
1156 if (SUCCEEDED(hr)) /* created stream */
1157 {
1158 hr = IWICStream_InitializeFromMemory(stream, xbuf, xread);
1159
1160 if (SUCCEEDED(hr)) /* initialized stream */
1161 {
1162 hr = CoCreateInstance(decoder_clsid, NULL, CLSCTX_INPROC_SERVER,
1163 &IID_IWICBitmapDecoder, (void**)&decoder);
1164 if (SUCCEEDED(hr)) /* created decoder */
1165 {
1166 hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)stream, WICDecodeMetadataCacheOnLoad);
1167
1168 if (SUCCEEDED(hr)) /* initialized decoder */
1169 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
1170
1171 IWICBitmapDecoder_Release(decoder);
1172 }
1173 }
1174
1175 IWICStream_Release(stream);
1176 }
1177
1178 if (SUCCEEDED(hr)) /* got framedecode */
1179 {
1181 IWICBitmapFrameDecode_Release(framedecode);
1182 }
1183
1184 if (SUCCEEDED(initresult)) CoUninitialize();
1185 return hr;
1186}
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSource *src)
Definition: olepicture.c:1010
Definition: main.c:439
@ WICDecodeMetadataCacheOnLoad
Definition: wincodec.idl:30

Referenced by OLEPictureImpl_Load().

◆ OLEPictureImpl_LoadWICSource()

static HRESULT OLEPictureImpl_LoadWICSource ( OLEPictureImpl This,
IWICBitmapSource src 
)
static

Definition at line 1010 of file olepicture.c.

1011{
1012 HRESULT hr;
1013 BITMAPINFOHEADER bih;
1014 HDC hdcref;
1015 UINT width, height;
1016 UINT stride, buffersize;
1018 WICRect rc;
1019 IWICBitmapSource *real_source;
1020 UINT x, y;
1021 COLORREF white = RGB(255, 255, 255), black = RGB(0, 0, 0);
1022 BOOL has_alpha=FALSE;
1023
1024 hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, src, &real_source);
1025 if (FAILED(hr)) return hr;
1026
1027 hr = IWICBitmapSource_GetSize(real_source, &width, &height);
1028 if (FAILED(hr)) goto end;
1029
1030 bih.biSize = sizeof(bih);
1031 bih.biWidth = width;
1032 bih.biHeight = -height;
1033 bih.biPlanes = 1;
1034 bih.biBitCount = 32;
1035 bih.biCompression = BI_RGB;
1036 bih.biSizeImage = 0;
1037 bih.biXPelsPerMeter = 4085; /* olepicture ignores the stored resolution */
1038 bih.biYPelsPerMeter = 4085;
1039 bih.biClrUsed = 0;
1040 bih.biClrImportant = 0;
1041
1042 stride = 4 * width;
1043 buffersize = stride * height;
1044
1045 bits = malloc(buffersize);
1046 if (!bits)
1047 {
1048 hr = E_OUTOFMEMORY;
1049 goto end;
1050 }
1051
1052 rc.X = 0;
1053 rc.Y = 0;
1054 rc.Width = width;
1055 rc.Height = height;
1056 hr = IWICBitmapSource_CopyPixels(real_source, &rc, stride, buffersize, bits);
1057 if (FAILED(hr))
1058 goto end;
1059
1060 hdcref = GetDC(0);
1061 This->desc.bmp.hbitmap = CreateDIBitmap(
1062 hdcref,
1063 &bih,
1064 CBM_INIT,
1065 bits,
1066 (BITMAPINFO*)&bih,
1068
1069 if (This->desc.bmp.hbitmap == 0)
1070 {
1071 hr = E_FAIL;
1072 ReleaseDC(0, hdcref);
1073 goto end;
1074 }
1075
1076 This->desc.picType = PICTYPE_BITMAP;
1078
1079 /* set transparent pixels to black, all others to white */
1080 for(y = 0; y < height; y++){
1081 for(x = 0; x < width; x++){
1082 DWORD *pixel = (DWORD*)(bits + stride*y + 4*x);
1083 if((*pixel & 0x80000000) == 0)
1084 {
1085 has_alpha = TRUE;
1086 *pixel = black;
1087 }
1088 else
1089 *pixel = white;
1090 }
1091 }
1092
1093 if (has_alpha)
1094 {
1095 HDC hdcBmp, hdcXor, hdcMask;
1096 HBITMAP hbmoldBmp, hbmoldXor, hbmoldMask;
1097
1098 This->hbmXor = CreateDIBitmap(
1099 hdcref,
1100 &bih,
1101 CBM_INIT,
1102 bits,
1103 (BITMAPINFO*)&bih,
1105 );
1106
1107 This->hbmMask = CreateBitmap(width,-height,1,1,NULL);
1108 hdcBmp = CreateCompatibleDC(NULL);
1109 hdcXor = CreateCompatibleDC(NULL);
1110 hdcMask = CreateCompatibleDC(NULL);
1111
1112 hbmoldBmp = SelectObject(hdcBmp,This->desc.bmp.hbitmap);
1113 hbmoldXor = SelectObject(hdcXor,This->hbmXor);
1114 hbmoldMask = SelectObject(hdcMask,This->hbmMask);
1115
1116 SetBkColor(hdcXor,black);
1117 BitBlt(hdcMask,0,0,width,height,hdcXor,0,0,SRCCOPY);
1118 BitBlt(hdcXor,0,0,width,height,hdcBmp,0,0,SRCAND);
1119
1120 SelectObject(hdcBmp,hbmoldBmp);
1121 SelectObject(hdcXor,hbmoldXor);
1122 SelectObject(hdcMask,hbmoldMask);
1123
1124 DeleteDC(hdcBmp);
1125 DeleteDC(hdcXor);
1126 DeleteDC(hdcMask);
1127 }
1128
1129 ReleaseDC(0, hdcref);
1130
1131end:
1132 free(bits);
1133 IWICBitmapSource_Release(real_source);
1134 return hr;
1135}
HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
Definition: info.c:2437
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Height *Stride) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Stride)
Definition: common.c:42
#define RGB(r, g, b)
Definition: precomp.h:67
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint end
Definition: gl.h:1545
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizei stride
Definition: glext.h:5848
GLenum src
Definition: glext.h:6340
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
unsigned int UINT
Definition: sysinfo.c:13
static HBITMAP
Definition: button.c:44
LONG biYPelsPerMeter
Definition: amvideo.idl:38
DWORD biCompression
Definition: amvideo.idl:35
DWORD biClrImportant
Definition: amvideo.idl:40
LONG biXPelsPerMeter
Definition: amvideo.idl:37
DWORD biSizeImage
Definition: amvideo.idl:36
INT Height
Definition: wincodec.idl:335
INT Width
Definition: wincodec.idl:334
unsigned char * LPBYTE
Definition: typedefs.h:53
#define BI_RGB
Definition: uefivid.c:46
DWORD COLORREF
Definition: windef.h:100
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define SRCCOPY
Definition: wingdi.h:333
#define SRCAND
Definition: wingdi.h:330

Referenced by OLEPictureImpl_LoadWICDecoder().

◆ OLEPictureImpl_PictureChanged()

static HRESULT WINAPI OLEPictureImpl_PictureChanged ( IPicture iface)
static

Definition at line 813 of file olepicture.c.

814{
816 TRACE("(%p)->()\n", This);
818 This->bIsDirty = TRUE;
819 return S_OK;
820}

◆ OLEPictureImpl_put_KeepOriginalFormat()

static HRESULT WINAPI OLEPictureImpl_put_KeepOriginalFormat ( IPicture iface,
BOOL  keep 
)
static

Definition at line 800 of file olepicture.c.

802{
804 TRACE("(%p)->(%d)\n", This, keep);
805 This->keepOrigFormat = keep;
806 /* FIXME: what DISPID notification here? */
807 return S_OK;
808}

◆ OLEPictureImpl_QueryInterface()

static HRESULT WINAPI OLEPictureImpl_QueryInterface ( IPicture iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 426 of file olepicture.c.

430{
432
433 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject);
434
435 if (!ppvObject)
436 return E_INVALIDARG;
437
438 *ppvObject = 0;
439
441 *ppvObject = &This->IPicture_iface;
442 else if (IsEqualIID(&IID_IDispatch, riid))
443 *ppvObject = &This->IDispatch_iface;
444 else if (IsEqualIID(&IID_IPictureDisp, riid))
445 *ppvObject = &This->IDispatch_iface;
447 *ppvObject = &This->IPersistStream_iface;
449 *ppvObject = &This->IConnectionPointContainer_iface;
450
451 if (!*ppvObject)
452 {
453 FIXME("() : asking for unsupported interface %s\n",debugstr_guid(riid));
454 return E_NOINTERFACE;
455 }
456
457 IPicture_AddRef(iface);
458
459 return S_OK;
460}
const GUID IID_IUnknown
const GUID IID_IPicture
const GUID IID_IConnectionPointContainer
const GUID IID_IPersist
Definition: proxy.cpp:14
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ OLEPictureImpl_Release()

static ULONG WINAPI OLEPictureImpl_Release ( IPicture iface)
static

Definition at line 413 of file olepicture.c.

415{
417 ULONG refCount = InterlockedDecrement(&This->ref);
418
419 TRACE("%p, refcount %lu.\n", iface, refCount);
420
421 if (!refCount) OLEPictureImpl_Destroy(This);
422
423 return refCount;
424}
#define InterlockedDecrement
Definition: armddk.h:52
static void OLEPictureImpl_Destroy(OLEPictureImpl *Obj)
Definition: olepicture.c:366

◆ OLEPictureImpl_Render()

static HRESULT WINAPI OLEPictureImpl_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,
LPCRECT  prcWBounds 
)
static

Definition at line 621 of file olepicture.c.

628{
630 TRACE("%p, %p, (%ld,%ld), (%ld,%ld), (%ld,%ld), (%ld,%ld), %p)\n", iface, hdc, x, y, cx, cy, xSrc, ySrc,
631 cxSrc, cySrc, prcWBounds);
632 if(prcWBounds)
633 TRACE("prcWBounds %s\n", wine_dbgstr_rect(prcWBounds));
634
635 if(cx == 0 || cy == 0 || cxSrc == 0 || cySrc == 0){
637 }
638
639 /*
640 * While the documentation suggests this to be here (or after rendering?)
641 * it does cause an endless recursion in my sample app. -MM 20010804
642 OLEPicture_SendNotify(This,DISPID_PICT_RENDER);
643 */
644
645 switch(This->desc.picType) {
647 case PICTYPE_NONE:
648 /* nothing to do */
649 return S_OK;
650 case PICTYPE_BITMAP:
651 {
652 HBITMAP hbmMask, hbmXor;
653
654 if (This->hbmMask)
655 {
656 hbmMask = This->hbmMask;
657 hbmXor = This->hbmXor;
658 }
659 else
660 {
661 hbmMask = 0;
662 hbmXor = This->desc.bmp.hbitmap;
663 }
664
665 render_masked_bitmap(This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, hbmMask, hbmXor);
666 break;
667 }
668
669 case PICTYPE_ICON:
670 {
672
673 if (!GetIconInfo(This->desc.icon.hicon, &info))
674 return E_FAIL;
675
676 render_masked_bitmap(This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, info.hbmMask, info.hbmColor);
677
678 DeleteObject(info.hbmMask);
679 if (info.hbmColor) DeleteObject(info.hbmColor);
680 break;
681 }
682
683 case PICTYPE_METAFILE:
684 {
685 POINT prevOrg, prevWndOrg;
686 SIZE prevExt, prevWndExt;
687 int oldmode;
688
689 /* Render the WMF to the appropriate location by setting the
690 appropriate ratio between "device units" and "logical units" */
691 oldmode = SetMapMode(hdc, MM_ANISOTROPIC);
692 /* For the "source rectangle" the y-axis must be inverted */
693 SetWindowOrgEx(hdc, xSrc, This->himetricHeight-ySrc, &prevWndOrg);
694 SetWindowExtEx(hdc, cxSrc, -cySrc, &prevWndExt);
695 /* For the "destination rectangle" no inversion is necessary */
696 SetViewportOrgEx(hdc, x, y, &prevOrg);
697 SetViewportExtEx(hdc, cx, cy, &prevExt);
698
699 if (!PlayMetaFile(hdc, This->desc.wmf.hmeta))
700 ERR("PlayMetaFile failed!\n");
701
702 /* We're done, restore the DC to the previous settings for converting
703 logical units to device units */
704 SetWindowExtEx(hdc, prevWndExt.cx, prevWndExt.cy, NULL);
705 SetWindowOrgEx(hdc, prevWndOrg.x, prevWndOrg.y, NULL);
706 SetViewportExtEx(hdc, prevExt.cx, prevExt.cy, NULL);
707 SetViewportOrgEx(hdc, prevOrg.x, prevOrg.y, NULL);
708 SetMapMode(hdc, oldmode);
709 break;
710 }
711
713 {
714 RECT rc = { x, y, x + cx, y + cy };
715 PlayEnhMetaFile(hdc, This->desc.emf.hemf, &rc);
716 break;
717 }
718
719 default:
720 FIXME("type %d not implemented\n", This->desc.picType);
721 return E_NOTIMPL;
722 }
723 return S_OK;
724}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
static void render_masked_bitmap(OLEPictureImpl *This, 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, HBITMAP hbmMask, HBITMAP hbmXor)
Definition: olepicture.c:576
HDC hdc
Definition: main.c:9
#define CTL_E_INVALIDPROPERTYVALUE
Definition: olectl.h:292
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int WINAPI SetMapMode(_In_ HDC, _In_ int)
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
#define MM_ANISOTROPIC
Definition: wingdi.h:867
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
BOOL WINAPI PlayMetaFile(_In_ HDC, _In_ HMETAFILE)
BOOL WINAPI PlayEnhMetaFile(_In_ HDC, _In_ HENHMETAFILE, _In_ LPCRECT)
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2414

◆ OLEPictureImpl_Save()

static HRESULT WINAPI OLEPictureImpl_Save ( IPersistStream iface,
IStream pStm,
BOOL  fClearDirty 
)
static

Definition at line 1803 of file olepicture.c.

1805{
1806 HRESULT hResult = E_NOTIMPL;
1807 void * pIconData;
1808 unsigned int iDataSize;
1809 DWORD header[2];
1810 ULONG dummy;
1812
1813 TRACE("%p %p %d\n", This, pStm, fClearDirty);
1814
1815 switch (This->desc.picType) {
1816 case PICTYPE_NONE:
1817 header[0] = 0x0000746c;
1818 header[1] = 0;
1819 hResult = IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1820 break;
1821
1822 case PICTYPE_ICON:
1823 if (This->bIsDirty || !This->data) {
1824 if (!serializeIcon(This->desc.icon.hicon, &pIconData, &iDataSize)) {
1825 ERR("(%p,%p,%d), serializeIcon() failed\n", This, pStm, fClearDirty);
1826 hResult = E_FAIL;
1827 break;
1828 }
1829 free(This->data);
1830 This->data = pIconData;
1831 This->datalen = iDataSize;
1832 }
1833
1834 header[0] = (This->loadtime_magic != 0xdeadbeef) ? This->loadtime_magic : 0x0000746c;
1835 header[1] = This->datalen;
1836 IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1837 IStream_Write(pStm, This->data, This->datalen, &dummy);
1838 hResult = S_OK;
1839 break;
1840 case PICTYPE_BITMAP:
1841 if (This->bIsDirty || !This->data) {
1842 switch (This->keepOrigFormat ? This->loadtime_format : BITMAP_FORMAT_BMP) {
1843 case BITMAP_FORMAT_BMP:
1844 hResult = serializeBMP(This->desc.bmp.hbitmap, &pIconData, &iDataSize);
1845 break;
1846 case BITMAP_FORMAT_JPEG:
1847 FIXME("(%p,%p,%d), PICTYPE_BITMAP (format JPEG) not implemented!\n",This,pStm,fClearDirty);
1848 break;
1849 case BITMAP_FORMAT_GIF:
1850 FIXME("(%p,%p,%d), PICTYPE_BITMAP (format GIF) not implemented!\n",This,pStm,fClearDirty);
1851 break;
1852 case BITMAP_FORMAT_PNG:
1853 FIXME("(%p,%p,%d), PICTYPE_BITMAP (format PNG) not implemented!\n",This,pStm,fClearDirty);
1854 break;
1855 default:
1856 FIXME("(%p,%p,%d), PICTYPE_BITMAP (format UNKNOWN, using BMP?) not implemented!\n",This,pStm,fClearDirty);
1857 break;
1858 }
1859
1860 if (hResult != S_OK)
1861 break;
1862
1863 free(This->data);
1864 This->data = pIconData;
1865 This->datalen = iDataSize;
1866 }
1867
1868 header[0] = (This->loadtime_magic != 0xdeadbeef) ? This->loadtime_magic : 0x0000746c;
1869 header[1] = This->datalen;
1870 IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1871 IStream_Write(pStm, This->data, This->datalen, &dummy);
1872 hResult = S_OK;
1873 break;
1874 case PICTYPE_METAFILE:
1875 FIXME("(%p,%p,%d), PICTYPE_METAFILE not implemented!\n",This,pStm,fClearDirty);
1876 break;
1878 FIXME("(%p,%p,%d),PICTYPE_ENHMETAFILE not implemented!\n",This,pStm,fClearDirty);
1879 break;
1880 default:
1881 FIXME("(%p,%p,%d), [unknown type] not implemented!\n",This,pStm,fClearDirty);
1882 break;
1883 }
1884 if (hResult == S_OK && fClearDirty) This->bIsDirty = FALSE;
1885 return hResult;
1886}
static BOOL serializeIcon(HICON hIcon, void **ppBuffer, unsigned int *pLength)
Definition: olepicture.c:1653

◆ OLEPictureImpl_SaveAsFile()

static HRESULT WINAPI OLEPictureImpl_SaveAsFile ( IPicture iface,
IStream pstream,
BOOL  SaveMemCopy,
LONG pcbSize 
)
static

Definition at line 825 of file olepicture.c.

829{
831 FIXME("(%p)->(%p, %d, %p), hacked stub.\n", This, pstream, SaveMemCopy, pcbSize);
832 return IStream_Write(pstream,This->data,This->datalen,(ULONG*)pcbSize);
833}

◆ OLEPictureImpl_SelectPicture()

static HRESULT WINAPI OLEPictureImpl_SelectPicture ( IPicture iface,
HDC  hdcIn,
HDC phdcOut,
OLE_HANDLE *  phbmpOut 
)
static

Definition at line 761 of file olepicture.c.

765{
767 TRACE("(%p)->(%p, %p, %p)\n", This, hdcIn, phdcOut, phbmpOut);
768 if (This->desc.picType == PICTYPE_BITMAP) {
769 if (phdcOut)
770 *phdcOut = This->hDCCur;
771 if (This->hDCCur) SelectObject(This->hDCCur,This->stock_bitmap);
772 if (hdcIn) SelectObject(hdcIn,This->desc.bmp.hbitmap);
773 This->hDCCur = hdcIn;
774 if (phbmpOut)
775 *phbmpOut = HandleToUlong(This->desc.bmp.hbitmap);
776 return S_OK;
777 } else {
778 FIXME("Don't know how to select picture type %d\n",This->desc.picType);
779 return E_FAIL;
780 }
781}

◆ OLEPictureImpl_set_hPal()

static HRESULT WINAPI OLEPictureImpl_set_hPal ( IPicture iface,
OLE_HANDLE  hpal 
)
static

Definition at line 729 of file olepicture.c.

731{
733
734 TRACE("(%p)->(%08x)\n", This, hpal);
735
736 if (This->desc.picType == PICTYPE_BITMAP)
737 {
738 This->desc.bmp.hpal = ULongToHandle(hpal);
740 return S_OK;
741 }
742
743 return E_FAIL;
744}
#define ULongToHandle(h)
Definition: basetsd.h:75

◆ OLEPictureImpl_SetBitmap()

static void OLEPictureImpl_SetBitmap ( OLEPictureImpl This)
static

Definition at line 197 of file olepicture.c.

198{
199 BITMAP bm;
200 HDC hdcRef;
201
202 TRACE("bitmap handle %p\n", This->desc.bmp.hbitmap);
203 if(GetObjectW(This->desc.bmp.hbitmap, sizeof(bm), &bm) != sizeof(bm)) {
204 ERR("GetObject fails\n");
205 return;
206 }
207 This->origWidth = bm.bmWidth;
208 This->origHeight = bm.bmHeight;
209
210 TRACE("width %d, height %d, bpp %d\n", bm.bmWidth, bm.bmHeight, bm.bmBitsPixel);
211
212 /* The width and height are stored in HIMETRIC units (0.01 mm),
213 so we take our pixel width divide by pixels per inch and
214 multiply by 25.4 * 100 */
215 /* Should we use GetBitmapDimension if available? */
216 hdcRef = CreateCompatibleDC(0);
217
218 This->himetricWidth = xpixels_to_himetric(bm.bmWidth, hdcRef);
219 This->himetricHeight = ypixels_to_himetric(bm.bmHeight, hdcRef);
220 This->stock_bitmap = GetCurrentObject( hdcRef, OBJ_BITMAP );
221
222 This->loadtime_format = BITMAP_FORMAT_BMP;
223
224 DeleteDC(hdcRef);
225}
#define OBJ_BITMAP
Definition: objidl.idl:1020
LONG bmHeight
Definition: wingdi.h:1869
LONG bmWidth
Definition: wingdi.h:1868
WORD bmBitsPixel
Definition: wingdi.h:1872
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428

Referenced by OLEPictureImpl_Construct(), OLEPictureImpl_LoadDIB(), and OLEPictureImpl_LoadWICSource().

◆ OLEPictureImpl_SetIcon()

static void OLEPictureImpl_SetIcon ( OLEPictureImpl This)
static

Definition at line 227 of file olepicture.c.

228{
229 ICONINFO infoIcon;
230
231 TRACE("icon handle %p\n", This->desc.icon.hicon);
232 if (GetIconInfo(This->desc.icon.hicon, &infoIcon)) {
233 HDC hdcRef;
234 BITMAP bm;
235
236 TRACE("bitmap handle for icon is %p\n", infoIcon.hbmColor);
237 if(GetObjectW(infoIcon.hbmColor ? infoIcon.hbmColor : infoIcon.hbmMask, sizeof(bm), &bm) != sizeof(bm)) {
238 ERR("GetObject fails on icon bitmap\n");
239 return;
240 }
241
242 This->origWidth = bm.bmWidth;
243 This->origHeight = infoIcon.hbmColor ? bm.bmHeight : bm.bmHeight / 2;
244 /* see comment on HIMETRIC on OLEPictureImpl_SetBitmap() */
245 hdcRef = GetDC(0);
246
247 This->himetricWidth = xpixels_to_himetric(This->origWidth, hdcRef);
248 This->himetricHeight = ypixels_to_himetric(This->origHeight, hdcRef);
249
250 ReleaseDC(0, hdcRef);
251
252 DeleteObject(infoIcon.hbmMask);
253 if (infoIcon.hbmColor) DeleteObject(infoIcon.hbmColor);
254 } else {
255 ERR("GetIconInfo() fails on icon %p\n", This->desc.icon.hicon);
256 }
257}
HBITMAP hbmColor
Definition: winuser.h:3235
HBITMAP hbmMask
Definition: winuser.h:3234

Referenced by OLEPictureImpl_Construct().

◆ OleSavePictureFile()

HRESULT WINAPI OleSavePictureFile ( IDispatch picture,
BSTR  filename 
)

Definition at line 2466 of file olepicture.c.

2467{
2468 FIXME("(%p %s): stub\n", picture, debugstr_w(filename));
2469 return CTL_E_FILENOTFOUND;
2470}

◆ render_masked_bitmap()

static void render_masked_bitmap ( OLEPictureImpl This,
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,
HBITMAP  hbmMask,
HBITMAP  hbmXor 
)
static

Definition at line 576 of file olepicture.c.

579{
580 HDC hdcBmp;
581
582 /* Set a mapping mode that maps bitmap pixels into HIMETRIC units.
583 * NB y-axis gets flipped
584 */
585
586 hdcBmp = CreateCompatibleDC(0);
587 SetMapMode(hdcBmp, MM_ANISOTROPIC);
588 SetWindowOrgEx(hdcBmp, 0, 0, NULL);
589 SetWindowExtEx(hdcBmp, This->himetricWidth, This->himetricHeight, NULL);
590 SetViewportOrgEx(hdcBmp, 0, This->origHeight, NULL);
591 SetViewportExtEx(hdcBmp, This->origWidth, -This->origHeight, NULL);
592
593 if (hbmMask)
594 {
595 SetBkColor(hdc, RGB(255, 255, 255));
596 SetTextColor(hdc, RGB(0, 0, 0));
597
598 SelectObject(hdcBmp, hbmMask);
599 StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCAND);
600
601 if (hbmXor)
602 {
603 SelectObject(hdcBmp, hbmXor);
604 StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCPAINT);
605 }
606 else StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc - This->himetricHeight,
607 cxSrc, cySrc, SRCPAINT);
608 }
609 else
610 {
611 SelectObject(hdcBmp, hbmXor);
612 StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCCOPY);
613 }
614
615 DeleteDC(hdcBmp);
616}
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCPAINT
Definition: wingdi.h:334
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917

Referenced by OLEPictureImpl_Render().

◆ serializeBMP()

static HRESULT serializeBMP ( HBITMAP  hbmp,
void **  buffer,
unsigned int length 
)
static

Definition at line 1537 of file olepicture.c.

1538{
1539 char infobuf[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)] = { 0 };
1540 BITMAPINFO *info = (BITMAPINFO *)infobuf;
1541 BITMAP bm;
1542 HBITMAP hdib = NULL;
1544 BITMAPFILEHEADER *filehdr;
1545 int numentries;
1546 HDC hdc;
1547 HRESULT hr = S_OK;
1548 unsigned char *data = NULL;
1549
1550 hdc = GetDC(0);
1551 if (!GetObjectW(hbmp, sizeof(bm), &bm)) {
1552 hr = E_INVALIDARG;
1553 goto done;
1554 }
1555
1556 /* Convert 16bpp/32bpp bitmap to 24bpp */
1557 if (bm.bmBitsPixel == 16 || bm.bmBitsPixel == 32) {
1558 void *bits;
1559 info->bmiHeader.biSize = sizeof(info->bmiHeader);
1560 info->bmiHeader.biWidth = bm.bmWidth;
1561 info->bmiHeader.biHeight = bm.bmHeight;
1562 info->bmiHeader.biPlanes = 1;
1563 info->bmiHeader.biBitCount = 24;
1564 info->bmiHeader.biCompression = BI_RGB;
1566 if (!hdib) {
1567 hr = E_OUTOFMEMORY;
1568 goto done;
1569 }
1570 if (buffer) {
1571 HDC src, dst;
1575 SelectObject(dst, hdib);
1576 if (!BitBlt(dst, 0, 0, bm.bmWidth, bm.bmHeight, src, 0, 0, SRCCOPY))
1577 hr = E_INVALIDARG;
1578 DeleteDC(src);
1579 DeleteDC(dst);
1580 if (FAILED(hr))
1581 goto done;
1582 }
1583 hbmp = hdib;
1584 }
1585
1586 /* Find out bitmap size and padded length */
1587 info->bmiHeader.biSize = sizeof(info->bmiHeader);
1588 if (!GetDIBits(hdc, hbmp, 0, 0, NULL, info, DIB_RGB_COLORS)) {
1589 hr = E_INVALIDARG;
1590 goto done;
1591 }
1592
1593 /* Calculate the total length required for the BMP data */
1594 if (info->bmiHeader.biClrUsed != 0) {
1595 numentries = info->bmiHeader.biClrUsed;
1596 if (numentries > 256)
1597 numentries = 256;
1598 } else {
1599 if (info->bmiHeader.biBitCount <= 8)
1600 numentries = 1 << info->bmiHeader.biBitCount;
1601 else
1602 numentries = 0;
1603 }
1604
1605 *length =
1606 sizeof(BITMAPFILEHEADER) +
1607 sizeof(BITMAPINFOHEADER) +
1608 numentries * sizeof(RGBQUAD) +
1609 info->bmiHeader.biSizeImage;
1610
1611 if (!buffer)
1612 goto done;
1613
1614 /* Fetch bitmap palette & pixel data */
1615 if (!(data = malloc(info->bmiHeader.biSizeImage))) {
1616 hr = E_OUTOFMEMORY;
1617 goto done;
1618 }
1619
1620 if (!GetDIBits(hdc, hbmp, 0, info->bmiHeader.biHeight, data, info, DIB_RGB_COLORS)) {
1621 hr = E_INVALIDARG;
1622 goto done;
1623 }
1624
1625 if (!(*buffer = malloc(*length))) {
1626 hr = E_OUTOFMEMORY;
1627 goto done;
1628 }
1629
1630 /* Fill the BITMAPFILEHEADER */
1631 filehdr = *buffer;
1632 filehdr->bfType = BITMAP_FORMAT_BMP;
1633 filehdr->bfSize = *length;
1634 filehdr->bfReserved1 = 0;
1635 filehdr->bfReserved2 = 0;
1636 filehdr->bfOffBits =
1637 sizeof(BITMAPFILEHEADER) +
1638 sizeof(BITMAPINFOHEADER) +
1639 numentries * sizeof(RGBQUAD);
1640
1641 /* Fill the BITMAPINFOHEADER and the palette data */
1642 bitmap = (BITMAPINFO *)((unsigned char *)(*buffer) + sizeof(BITMAPFILEHEADER));
1643 memcpy(bitmap, info, sizeof(BITMAPINFOHEADER) + numentries * sizeof(RGBQUAD));
1644 memcpy((unsigned char *)(*buffer) + filehdr->bfOffBits, data, bitmap->bmiHeader.biSizeImage);
1645
1646done:
1647 free(data);
1648 ReleaseDC(0, hdc);
1649 if (hdib) DeleteObject(hdib);
1650 return hr;
1651}
HBITMAP hbmp
ULONG RGBQUAD
Definition: precomp.h:47
GLuint buffer
Definition: glext.h:5915
GLenum GLenum dst
Definition: glext.h:6340
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define bits
Definition: infblock.c:15
if(dx< 0)
Definition: linetemp.h:194
Definition: uimain.c:89
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
struct tagBITMAPFILEHEADER BITMAPFILEHEADER
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)

Referenced by OLEPictureImpl_GetSizeMax(), and OLEPictureImpl_Save().

◆ serializeIcon()

static BOOL serializeIcon ( HICON  hIcon,
void **  ppBuffer,
unsigned int pLength 
)
static

Definition at line 1653 of file olepicture.c.

1654{
1655 ICONINFO infoIcon;
1656 BOOL success = FALSE;
1657
1658 *ppBuffer = NULL; *pLength = 0;
1659 if (GetIconInfo(hIcon, &infoIcon)) {
1660 HDC hDC;
1661 BITMAPINFO * pInfoBitmap;
1662 unsigned char * pIconData = NULL;
1663 unsigned int iDataSize = 0;
1664
1665 pInfoBitmap = calloc(1, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
1666
1667 /* Find out icon size */
1668 hDC = GetDC(0);
1669 pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
1670 GetDIBits(hDC, infoIcon.hbmColor, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
1671 if (1) {
1672 /* Auxiliary pointers */
1673 CURSORICONFILEDIR * pIconDir;
1674 CURSORICONFILEDIRENTRY * pIconEntry;
1675 BITMAPINFOHEADER * pIconBitmapHeader;
1676 unsigned int iOffsetPalette;
1677 unsigned int iOffsetColorData;
1678 unsigned int iOffsetMaskData;
1679
1680 unsigned int iLengthScanLineMask;
1681 unsigned int iNumEntriesPalette;
1682
1683 iLengthScanLineMask = ((pInfoBitmap->bmiHeader.biWidth + 31) >> 5) << 2;
1684/*
1685 FIXME("DEBUG: bitmap size is %d x %d\n",
1686 pInfoBitmap->bmiHeader.biWidth,
1687 pInfoBitmap->bmiHeader.biHeight);
1688 FIXME("DEBUG: bitmap bpp is %d\n",
1689 pInfoBitmap->bmiHeader.biBitCount);
1690 FIXME("DEBUG: bitmap nplanes is %d\n",
1691 pInfoBitmap->bmiHeader.biPlanes);
1692 FIXME("DEBUG: bitmap biSizeImage is %u\n",
1693 pInfoBitmap->bmiHeader.biSizeImage);
1694*/
1695 /* Let's start with one CURSORICONFILEDIR and one CURSORICONFILEDIRENTRY */
1696 iDataSize += 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY) + sizeof(BITMAPINFOHEADER);
1697 pIconData = calloc(1, iDataSize);
1698
1699 /* Fill out the CURSORICONFILEDIR */
1700 pIconDir = (CURSORICONFILEDIR *)pIconData;
1701 pIconDir->idType = 1;
1702 pIconDir->idCount = 1;
1703 pIconDir->idReserved = 0;
1704
1705 /* Fill out the CURSORICONFILEDIRENTRY */
1706 pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD));
1707 pIconEntry->bWidth = (unsigned char)pInfoBitmap->bmiHeader.biWidth;
1708 pIconEntry->bHeight = (unsigned char)pInfoBitmap->bmiHeader.biHeight;
1709 pIconEntry->bColorCount =
1710 (pInfoBitmap->bmiHeader.biBitCount < 8)
1711 ? 1 << pInfoBitmap->bmiHeader.biBitCount
1712 : 0;
1713 pIconEntry->xHotspot = pInfoBitmap->bmiHeader.biPlanes;
1714 pIconEntry->yHotspot = pInfoBitmap->bmiHeader.biBitCount;
1715 pIconEntry->dwDIBSize = 0;
1716 pIconEntry->dwDIBOffset = 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY);
1717
1718 /* Fill out the BITMAPINFOHEADER */
1719 pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
1720 *pIconBitmapHeader = pInfoBitmap->bmiHeader;
1721
1722 /* Find out whether a palette exists for the bitmap */
1723 if ( (pInfoBitmap->bmiHeader.biBitCount == 16 && pInfoBitmap->bmiHeader.biCompression == BI_RGB)
1724 || (pInfoBitmap->bmiHeader.biBitCount == 24)
1725 || (pInfoBitmap->bmiHeader.biBitCount == 32 && pInfoBitmap->bmiHeader.biCompression == BI_RGB)) {
1726 iNumEntriesPalette = pInfoBitmap->bmiHeader.biClrUsed;
1727 if (iNumEntriesPalette > 256) iNumEntriesPalette = 256;
1728 } else if ((pInfoBitmap->bmiHeader.biBitCount == 16 || pInfoBitmap->bmiHeader.biBitCount == 32)
1729 && pInfoBitmap->bmiHeader.biCompression == BI_BITFIELDS) {
1730 iNumEntriesPalette = 3;
1731 } else if (pInfoBitmap->bmiHeader.biBitCount <= 8) {
1732 iNumEntriesPalette = 1 << pInfoBitmap->bmiHeader.biBitCount;
1733 } else {
1734 iNumEntriesPalette = 0;
1735 }
1736
1737 /* Add bitmap size and header size to icon data size. */
1738 iOffsetPalette = iDataSize;
1739 iDataSize += iNumEntriesPalette * sizeof(DWORD);
1740 iOffsetColorData = iDataSize;
1741 iDataSize += pIconBitmapHeader->biSizeImage;
1742 iOffsetMaskData = iDataSize;
1743 iDataSize += pIconBitmapHeader->biHeight * iLengthScanLineMask;
1744 pIconBitmapHeader->biSizeImage += pIconBitmapHeader->biHeight * iLengthScanLineMask;
1745 pIconBitmapHeader->biHeight *= 2;
1746 pIconData = realloc(pIconData, iDataSize);
1747 pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD));
1748 pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
1749 pIconEntry->dwDIBSize = iDataSize - (3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
1750
1751 /* Get the actual bitmap data from the icon bitmap */
1752 GetDIBits(hDC, infoIcon.hbmColor, 0, pInfoBitmap->bmiHeader.biHeight,
1753 pIconData + iOffsetColorData, pInfoBitmap, DIB_RGB_COLORS);
1754 if (iNumEntriesPalette > 0) {
1755 memcpy(pIconData + iOffsetPalette, pInfoBitmap->bmiColors,
1756 iNumEntriesPalette * sizeof(RGBQUAD));
1757 }
1758
1759 /* Reset all values so that GetDIBits call succeeds */
1760 memset(pIconData + iOffsetMaskData, 0, iDataSize - iOffsetMaskData);
1761 memset(pInfoBitmap, 0, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
1762 pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
1763/*
1764 if (!(GetDIBits(hDC, infoIcon.hbmMask, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS)
1765 && GetDIBits(hDC, infoIcon.hbmMask, 0, pIconEntry->bHeight,
1766 pIconData + iOffsetMaskData, pInfoBitmap, DIB_RGB_COLORS))) {
1767
1768 printf("ERROR: unable to get bitmap mask (error %u)\n",
1769 GetLastError());
1770
1771 }
1772*/
1773 GetDIBits(hDC, infoIcon.hbmMask, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
1774 GetDIBits(hDC, infoIcon.hbmMask, 0, pIconEntry->bHeight, pIconData + iOffsetMaskData, pInfoBitmap, DIB_RGB_COLORS);
1775
1776 /* Write out everything produced so far to the stream */
1777 *ppBuffer = pIconData; *pLength = iDataSize;
1778 success = TRUE;
1779 } else {
1780/*
1781 printf("ERROR: unable to get bitmap information via GetDIBits() (error %u)\n",
1782 GetLastError());
1783*/
1784 }
1785 /*
1786 Remarks (from MSDN entry on GetIconInfo):
1787
1788 GetIconInfo creates bitmaps for the hbmMask and hbmColor
1789 members of ICONINFO. The calling application must manage
1790 these bitmaps and delete them when they are no longer
1791 necessary.
1792 */
1793 if (hDC) ReleaseDC(0, hDC);
1794 DeleteObject(infoIcon.hbmMask);
1795 if (infoIcon.hbmColor) DeleteObject(infoIcon.hbmColor);
1796 free(pInfoBitmap);
1797 } else {
1798 ERR("Unable to get icon information (error %lu)\n", GetLastError());
1799 }
1800 return success;
1801}
static HDC hDC
Definition: 3dtext.c:33
unsigned char
Definition: typeof.h:29
#define BI_BITFIELDS
Definition: mmreg.h:507
HICON hIcon
Definition: msconfig.c:44
#define DWORD
Definition: nt_native.h:44
USHORT biBitCount
Definition: precomp.h:34
ULONG biCompression
Definition: precomp.h:35
RGBQUAD bmiColors[1]
Definition: wingdi.h:1923
#define success(from, fromstr, to, tostr)

Referenced by OLEPictureImpl_Save().

◆ SPCF_AddRef()

static ULONG WINAPI SPCF_AddRef ( LPCLASSFACTORY  iface)
static

Definition at line 2560 of file olepicture.c.

2560 {
2562 return InterlockedIncrement(&This->ref);
2563}
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: olepicture.c:2546

◆ SPCF_CreateInstance()

static HRESULT WINAPI SPCF_CreateInstance ( LPCLASSFACTORY  iface,
LPUNKNOWN  pOuter,
REFIID  riid,
LPVOID ppobj 
)
static

Definition at line 2571 of file olepicture.c.

2573 {
2574 /* Creates an uninitialized picture */
2575 return OleCreatePictureIndirect(NULL,riid,TRUE,ppobj);
2576
2577}

◆ SPCF_LockServer()

static HRESULT WINAPI SPCF_LockServer ( LPCLASSFACTORY  iface,
BOOL  dolock 
)
static

Definition at line 2579 of file olepicture.c.

2579 {
2581 FIXME("(%p)->(%d),stub!\n",This,dolock);
2582 return S_OK;
2583}

◆ SPCF_QueryInterface()

static HRESULT WINAPI SPCF_QueryInterface ( LPCLASSFACTORY  iface,
REFIID  riid,
LPVOID ppobj 
)
static

Definition at line 2552 of file olepicture.c.

2552 {
2554
2555 FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
2556 return E_NOINTERFACE;
2557}

◆ SPCF_Release()

static ULONG WINAPI SPCF_Release ( LPCLASSFACTORY  iface)
static

Definition at line 2565 of file olepicture.c.

2565 {
2567 /* static class, won't be freed */
2568 return InterlockedDecrement(&This->ref);
2569}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( olepicture  )

◆ xpixels_to_himetric()

static OLE_XSIZE_HIMETRIC xpixels_to_himetric ( INT  pixels,
HDC  hdc 
)
inlinestatic

Definition at line 183 of file olepicture.c.

184{
185 return MulDiv(pixels, 2540, GetDeviceCaps(hdc, LOGPIXELSX));
186}
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSX
Definition: wingdi.h:718

Referenced by OLEPictureImpl_LoadIcon(), OLEPictureImpl_SetBitmap(), and OLEPictureImpl_SetIcon().

◆ ypixels_to_himetric()

static OLE_YSIZE_HIMETRIC ypixels_to_himetric ( INT  pixels,
HDC  hdc 
)
inlinestatic

Definition at line 188 of file olepicture.c.

189{
190 return MulDiv(pixels, 2540, GetDeviceCaps(hdc, LOGPIXELSY));
191}
#define LOGPIXELSY
Definition: wingdi.h:719

Referenced by OLEPictureImpl_LoadIcon(), OLEPictureImpl_SetBitmap(), and OLEPictureImpl_SetIcon().

Variable Documentation

◆ OLEPictureImpl_IConnectionPointContainer_VTable

static const IConnectionPointContainerVtbl OLEPictureImpl_IConnectionPointContainer_VTable
static
Initial value:
=
{
}
static HRESULT WINAPI OLEPictureImpl_IConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface, REFIID riid, VOID **ppvoid)
Definition: olepicture.c:864
static HRESULT WINAPI OLEPictureImpl_EnumConnectionPoints(IConnectionPointContainer *iface, IEnumConnectionPoints **ppEnum)
Definition: olepicture.c:890
static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_Release(IConnectionPointContainer *iface)
Definition: olepicture.c:882
static HRESULT WINAPI OLEPictureImpl_FindConnectionPoint(IConnectionPointContainer *iface, REFIID riid, IConnectionPoint **ppCP)
Definition: olepicture.c:900
static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
Definition: olepicture.c:874

Definition at line 180 of file olepicture.c.

Referenced by OLEPictureImpl_Construct().

◆ OLEPictureImpl_IDispatch_VTable

static const IDispatchVtbl OLEPictureImpl_IDispatch_VTable
static
Initial value:
=
{
}
static HRESULT WINAPI OLEPictureImpl_IDispatch_QueryInterface(IDispatch *iface, REFIID riid, VOID **ppvoid)
Definition: olepicture.c:1954
static ULONG WINAPI OLEPictureImpl_IDispatch_Release(IDispatch *iface)
Definition: olepicture.c:1982
static HRESULT WINAPI OLEPictureImpl_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExepInfo, UINT *puArgErr)
Definition: olepicture.c:2086
static ULONG WINAPI OLEPictureImpl_IDispatch_AddRef(IDispatch *iface)
Definition: olepicture.c:1969
static HRESULT WINAPI OLEPictureImpl_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: olepicture.c:2044
static HRESULT WINAPI OLEPictureImpl_GetTypeInfoCount(IDispatch *iface, unsigned int *pctinfo)
Definition: olepicture.c:1995

Definition at line 178 of file olepicture.c.

Referenced by OLEPictureImpl_Construct().

◆ OLEPictureImpl_IPersistStream_VTable

static const IPersistStreamVtbl OLEPictureImpl_IPersistStream_VTable
static
Initial value:
=
{
}
static ULONG WINAPI OLEPictureImpl_IPersistStream_Release(IPersistStream *iface)
Definition: olepicture.c:954
static HRESULT WINAPI OLEPictureImpl_Save(IPersistStream *iface, IStream *pStm, BOOL fClearDirty)
Definition: olepicture.c:1803
static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream *iface, IStream *pStm)
Definition: olepicture.c:1344
static HRESULT WINAPI OLEPictureImpl_IsDirty(IPersistStream *iface)
Definition: olepicture.c:976
static ULONG WINAPI OLEPictureImpl_IPersistStream_AddRef(IPersistStream *iface)
Definition: olepicture.c:941
static HRESULT WINAPI OLEPictureImpl_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *size)
Definition: olepicture.c:1888
static HRESULT WINAPI OLEPictureImpl_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid, VOID **ppvoid)
Definition: olepicture.c:926
static HRESULT WINAPI OLEPictureImpl_GetClassID(IPersistStream *iface, CLSID *pClassID)
Definition: olepicture.c:965

Definition at line 179 of file olepicture.c.

Referenced by OLEPictureImpl_Construct().

◆ OLEPictureImpl_VTable

static const IPictureVtbl OLEPictureImpl_VTable
static
Initial value:
=
{
}
static HRESULT WINAPI OLEPictureImpl_set_hPal(IPicture *iface, OLE_HANDLE hpal)
Definition: olepicture.c:729
static HRESULT WINAPI OLEPictureImpl_get_Handle(IPicture *iface, OLE_HANDLE *phandle)
Definition: olepicture.c:489
static HRESULT WINAPI OLEPictureImpl_PictureChanged(IPicture *iface)
Definition: olepicture.c:813
static HRESULT WINAPI OLEPictureImpl_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, LPCRECT prcWBounds)
Definition: olepicture.c:621
static ULONG WINAPI OLEPictureImpl_Release(IPicture *iface)
Definition: olepicture.c:413
static HRESULT WINAPI OLEPictureImpl_SelectPicture(IPicture *iface, HDC hdcIn, HDC *phdcOut, OLE_HANDLE *phbmpOut)
Definition: olepicture.c:761
static HRESULT WINAPI OLEPictureImpl_get_hPal(IPicture *iface, OLE_HANDLE *phandle)
Definition: olepicture.c:526
static HRESULT WINAPI OLEPictureImpl_put_KeepOriginalFormat(IPicture *iface, BOOL keep)
Definition: olepicture.c:800
static HRESULT WINAPI OLEPictureImpl_QueryInterface(IPicture *iface, REFIID riid, void **ppvObject)
Definition: olepicture.c:426
static HRESULT WINAPI OLEPictureImpl_SaveAsFile(IPicture *iface, IStream *pstream, BOOL SaveMemCopy, LONG *pcbSize)
Definition: olepicture.c:825
static HRESULT WINAPI OLEPictureImpl_get_Height(IPicture *iface, OLE_YSIZE_HIMETRIC *pheight)
Definition: olepicture.c:568
static HRESULT WINAPI OLEPictureImpl_get_Width(IPicture *iface, OLE_XSIZE_HIMETRIC *pwidth)
Definition: olepicture.c:560
static HRESULT WINAPI OLEPictureImpl_get_CurDC(IPicture *iface, HDC *phdc)
Definition: olepicture.c:749
static ULONG WINAPI OLEPictureImpl_AddRef(IPicture *iface)
Definition: olepicture.c:402
static HRESULT WINAPI OLEPictureImpl_get_Attributes(IPicture *iface, DWORD *pdwAttr)
Definition: olepicture.c:838
static HRESULT WINAPI OLEPictureImpl_get_KeepOriginalFormat(IPicture *iface, BOOL *pfKeep)
Definition: olepicture.c:786

Definition at line 177 of file olepicture.c.

Referenced by OLEPictureImpl_Construct().

◆ SPCF_Vtbl

const IClassFactoryVtbl SPCF_Vtbl
static
Initial value:
= {
}
static ULONG WINAPI SPCF_AddRef(LPCLASSFACTORY iface)
Definition: olepicture.c:2560
static ULONG WINAPI SPCF_Release(LPCLASSFACTORY iface)
Definition: olepicture.c:2565
static HRESULT WINAPI SPCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
Definition: olepicture.c:2552
static HRESULT WINAPI SPCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
Definition: olepicture.c:2571
static HRESULT WINAPI SPCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
Definition: olepicture.c:2579

Definition at line 2585 of file olepicture.c.

◆ STDPIC_CF

IClassFactoryImpl STDPIC_CF = {{&SPCF_Vtbl}, 1 }
static

Definition at line 2592 of file olepicture.c.

Referenced by _get_STDPIC_CF().