ole32: Add support for loading dibs from presentation streams to data cache.
Signed-off-by: Sergio Gómez Del Real <sdelreal@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3350cf2320
commit
a1a99f014c
|
@ -647,48 +647,61 @@ static HRESULT load_dib( DataCacheEntry *cache_entry, IStream *stm )
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
STATSTG stat;
|
STATSTG stat;
|
||||||
void *dib;
|
BYTE *dib;
|
||||||
HGLOBAL hglobal;
|
HGLOBAL hglobal;
|
||||||
ULONG read, info_size, bi_size;
|
ULONG read, info_size, bi_size;
|
||||||
BITMAPFILEHEADER file;
|
BITMAPFILEHEADER file;
|
||||||
BITMAPINFOHEADER *info;
|
BITMAPINFOHEADER *info;
|
||||||
|
CLIPFORMAT cf;
|
||||||
if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
|
PresentationDataHeader pres;
|
||||||
{
|
ULARGE_INTEGER current_pos;
|
||||||
FIXME( "Unimplemented for presentation stream\n" );
|
static const LARGE_INTEGER offset_zero;
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = IStream_Stat( stm, &stat, STATFLAG_NONAME );
|
hr = IStream_Stat( stm, &stat, STATFLAG_NONAME );
|
||||||
if (FAILED( hr )) return hr;
|
if (FAILED( hr )) return hr;
|
||||||
|
|
||||||
if (stat.cbSize.QuadPart < sizeof(file) + sizeof(DWORD)) return E_FAIL;
|
if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
|
||||||
hr = IStream_Read( stm, &file, sizeof(file), &read );
|
{
|
||||||
if (hr != S_OK || read != sizeof(file)) return E_FAIL;
|
hr = read_clipformat( stm, &cf );
|
||||||
stat.cbSize.QuadPart -= sizeof(file);
|
if (hr != S_OK) return hr;
|
||||||
|
hr = IStream_Read( stm, &pres, sizeof(pres), &read );
|
||||||
|
if (hr != S_OK) return hr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = IStream_Read( stm, &file, sizeof(BITMAPFILEHEADER), &read );
|
||||||
|
if (hr != S_OK) return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = IStream_Seek( stm, offset_zero, STREAM_SEEK_CUR, ¤t_pos );
|
||||||
|
if (FAILED( hr )) return hr;
|
||||||
|
stat.cbSize.QuadPart -= current_pos.QuadPart;
|
||||||
|
|
||||||
hglobal = GlobalAlloc( GMEM_MOVEABLE, stat.cbSize.u.LowPart );
|
hglobal = GlobalAlloc( GMEM_MOVEABLE, stat.cbSize.u.LowPart );
|
||||||
if (!hglobal) return E_OUTOFMEMORY;
|
if (!hglobal) return E_OUTOFMEMORY;
|
||||||
dib = GlobalLock( hglobal );
|
dib = GlobalLock( hglobal );
|
||||||
|
|
||||||
|
/* read first DWORD of BITMAPINFOHEADER */
|
||||||
hr = IStream_Read( stm, dib, sizeof(DWORD), &read );
|
hr = IStream_Read( stm, dib, sizeof(DWORD), &read );
|
||||||
if (hr != S_OK || read != sizeof(DWORD)) goto fail;
|
if (hr != S_OK) goto fail;
|
||||||
bi_size = *(DWORD *)dib;
|
bi_size = *(DWORD *)dib;
|
||||||
if (stat.cbSize.QuadPart < bi_size) goto fail;
|
if (stat.cbSize.QuadPart < bi_size) goto fail;
|
||||||
|
|
||||||
hr = IStream_Read( stm, (char *)dib + sizeof(DWORD), bi_size - sizeof(DWORD), &read );
|
/* read rest of BITMAPINFOHEADER */
|
||||||
if (hr != S_OK || read != bi_size - sizeof(DWORD)) goto fail;
|
hr = IStream_Read( stm, dib + sizeof(DWORD), bi_size - sizeof(DWORD), &read );
|
||||||
|
if (hr != S_OK) goto fail;
|
||||||
|
|
||||||
info_size = bitmap_info_size( dib, DIB_RGB_COLORS );
|
info_size = bitmap_info_size( (BITMAPINFO *)dib, DIB_RGB_COLORS );
|
||||||
if (stat.cbSize.QuadPart < info_size) goto fail;
|
if (stat.cbSize.QuadPart < info_size) goto fail;
|
||||||
if (info_size > bi_size)
|
if (info_size > bi_size)
|
||||||
{
|
{
|
||||||
hr = IStream_Read( stm, (char *)dib + bi_size, info_size - bi_size, &read );
|
hr = IStream_Read( stm, dib + bi_size, info_size - bi_size, &read );
|
||||||
if (hr != S_OK || read != info_size - bi_size) goto fail;
|
if (hr != S_OK) goto fail;
|
||||||
}
|
}
|
||||||
stat.cbSize.QuadPart -= info_size;
|
stat.cbSize.QuadPart -= info_size;
|
||||||
|
|
||||||
if (file.bfOffBits)
|
/* set Stream pointer to beginning of bitmap bits */
|
||||||
|
if (cache_entry->load_stream_num == STREAM_NUMBER_CONTENTS && file.bfOffBits)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER skip;
|
LARGE_INTEGER skip;
|
||||||
|
|
||||||
|
@ -699,8 +712,8 @@ static HRESULT load_dib( DataCacheEntry *cache_entry, IStream *stm )
|
||||||
stat.cbSize.QuadPart -= skip.QuadPart;
|
stat.cbSize.QuadPart -= skip.QuadPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = IStream_Read( stm, (char *)dib + info_size, stat.cbSize.u.LowPart, &read );
|
hr = IStream_Read( stm, dib + info_size, stat.cbSize.u.LowPart, &read );
|
||||||
if (hr != S_OK || read != stat.cbSize.QuadPart) goto fail;
|
if (hr != S_OK) goto fail;
|
||||||
|
|
||||||
if (bi_size >= sizeof(*info))
|
if (bi_size >= sizeof(*info))
|
||||||
{
|
{
|
||||||
|
@ -719,12 +732,12 @@ static HRESULT load_dib( DataCacheEntry *cache_entry, IStream *stm )
|
||||||
cache_entry->stgmedium.tymed = TYMED_HGLOBAL;
|
cache_entry->stgmedium.tymed = TYMED_HGLOBAL;
|
||||||
cache_entry->stgmedium.u.hGlobal = hglobal;
|
cache_entry->stgmedium.u.hGlobal = hglobal;
|
||||||
|
|
||||||
return S_OK;
|
return hr;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
GlobalUnlock( hglobal );
|
GlobalUnlock( hglobal );
|
||||||
GlobalFree( hglobal );
|
GlobalFree( hglobal );
|
||||||
return E_FAIL;
|
return hr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue