ReactOS  0.4.14-dev-317-g96040ec
bmpdecode.c File Reference
#include "config.h"
#include <assert.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "wingdi.h"
#include "objbase.h"
#include "wincodecs_private.h"
#include "wine/debug.h"
Include dependency graph for bmpdecode.c:

Go to the source code of this file.

Classes

struct  BITMAPCOREHEADER2
 
struct  BmpDecoder
 
struct  bitfields_format
 

Macros

#define COBJMACROS
 

Typedefs

typedef HRESULT(* ReadDataFunc) (BmpDecoder *This)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wincodecs)
 
static BmpDecoderimpl_from_IWICBitmapDecoder (IWICBitmapDecoder *iface)
 
static BmpDecoderimpl_from_IWICBitmapFrameDecode (IWICBitmapFrameDecode *iface)
 
static HRESULT WINAPI BmpFrameDecode_QueryInterface (IWICBitmapFrameDecode *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI BmpFrameDecode_AddRef (IWICBitmapFrameDecode *iface)
 
static ULONG WINAPI BmpFrameDecode_Release (IWICBitmapFrameDecode *iface)
 
static HRESULT WINAPI BmpFrameDecode_GetSize (IWICBitmapFrameDecode *iface, UINT *puiWidth, UINT *puiHeight)
 
static HRESULT WINAPI BmpFrameDecode_GetPixelFormat (IWICBitmapFrameDecode *iface, WICPixelFormatGUID *pPixelFormat)
 
static HRESULT BmpHeader_GetResolution (BITMAPV5HEADER *bih, double *pDpiX, double *pDpiY)
 
static HRESULT WINAPI BmpFrameDecode_GetResolution (IWICBitmapFrameDecode *iface, double *pDpiX, double *pDpiY)
 
static HRESULT WINAPI BmpFrameDecode_CopyPalette (IWICBitmapFrameDecode *iface, IWICPalette *pIPalette)
 
static HRESULT WINAPI BmpFrameDecode_CopyPixels (IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
 
static HRESULT WINAPI BmpFrameDecode_GetMetadataQueryReader (IWICBitmapFrameDecode *iface, IWICMetadataQueryReader **ppIMetadataQueryReader)
 
static HRESULT WINAPI BmpFrameDecode_GetColorContexts (IWICBitmapFrameDecode *iface, UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
 
static HRESULT WINAPI BmpFrameDecode_GetThumbnail (IWICBitmapFrameDecode *iface, IWICBitmapSource **ppIThumbnail)
 
static HRESULT BmpFrameDecode_ReadUncompressed (BmpDecoder *This)
 
static HRESULT BmpFrameDecode_ReadRGB8 (BmpDecoder *This)
 
static HRESULT ReadByte (IStream *stream, BYTE *buffer, ULONG buffer_size, ULONG *cursor, ULONG *bytesread, BYTE *result)
 
static HRESULT BmpFrameDecode_ReadRLE8 (BmpDecoder *This)
 
static HRESULT BmpFrameDecode_ReadRLE4 (BmpDecoder *This)
 
static HRESULT BmpFrameDecode_ReadUnsupported (BmpDecoder *This)
 
static HRESULT BmpDecoder_ReadHeaders (BmpDecoder *This, IStream *stream)
 
static HRESULT WINAPI BmpDecoder_QueryInterface (IWICBitmapDecoder *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI BmpDecoder_AddRef (IWICBitmapDecoder *iface)
 
static ULONG WINAPI BmpDecoder_Release (IWICBitmapDecoder *iface)
 
static HRESULT WINAPI BmpDecoder_QueryCapability (IWICBitmapDecoder *iface, IStream *stream, DWORD *capability)
 
static HRESULT WINAPI BmpDecoder_Initialize (IWICBitmapDecoder *iface, IStream *pIStream, WICDecodeOptions cacheOptions)
 
static HRESULT WINAPI BmpDecoder_GetContainerFormat (IWICBitmapDecoder *iface, GUID *pguidContainerFormat)
 
static HRESULT WINAPI BmpDecoder_GetDecoderInfo (IWICBitmapDecoder *iface, IWICBitmapDecoderInfo **ppIDecoderInfo)
 
static HRESULT WINAPI BmpDecoder_CopyPalette (IWICBitmapDecoder *iface, IWICPalette *pIPalette)
 
static HRESULT WINAPI BmpDecoder_GetMetadataQueryReader (IWICBitmapDecoder *iface, IWICMetadataQueryReader **ppIMetadataQueryReader)
 
static HRESULT WINAPI BmpDecoder_GetPreview (IWICBitmapDecoder *iface, IWICBitmapSource **ppIBitmapSource)
 
static HRESULT WINAPI BmpDecoder_GetColorContexts (IWICBitmapDecoder *iface, UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
 
static HRESULT WINAPI BmpDecoder_GetThumbnail (IWICBitmapDecoder *iface, IWICBitmapSource **ppIThumbnail)
 
static HRESULT WINAPI BmpDecoder_GetFrameCount (IWICBitmapDecoder *iface, UINT *pCount)
 
static HRESULT WINAPI BmpDecoder_GetFrame (IWICBitmapDecoder *iface, UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
 
static HRESULT BmpDecoder_Create (int packed, int icoframe, BmpDecoder **ppDecoder)
 
static HRESULT BmpDecoder_Construct (int packed, int icoframe, REFIID iid, void **ppv)
 
HRESULT BmpDecoder_CreateInstance (REFIID iid, void **ppv)
 
HRESULT DibDecoder_CreateInstance (REFIID iid, void **ppv)
 
HRESULT IcoDibDecoder_CreateInstance (BmpDecoder **ppDecoder)
 
void BmpDecoder_GetWICDecoder (BmpDecoder *This, IWICBitmapDecoder **ppDecoder)
 
void BmpDecoder_FindIconMask (BmpDecoder *This, ULONG *mask_offset, int *topdown)
 

Variables

static const struct bitfields_format bitfields_formats []
 
static const IWICBitmapFrameDecodeVtbl BmpDecoder_FrameVtbl
 
static const IWICBitmapDecoderVtbl BmpDecoder_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file bmpdecode.c.

Typedef Documentation

◆ ReadDataFunc

typedef HRESULT(* ReadDataFunc) (BmpDecoder *This)

Definition at line 61 of file bmpdecode.c.

Function Documentation

◆ BmpDecoder_AddRef()

static ULONG WINAPI BmpDecoder_AddRef ( IWICBitmapDecoder iface)
static

Definition at line 996 of file bmpdecode.c.

997 {
1000 
1001  TRACE("(%p) refcount=%u\n", iface, ref);
1002 
1003  return ref;
1004 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
static BmpDecoder * impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
Definition: bmpdecode.c:83
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ BmpDecoder_Construct()

static HRESULT BmpDecoder_Construct ( int  packed,
int  icoframe,
REFIID  iid,
void **  ppv 
)
static

Definition at line 1176 of file bmpdecode.c.

1177 {
1178  BmpDecoder *This;
1179  HRESULT ret;
1180 
1181  TRACE("(%s,%p)\n", debugstr_guid(iid), ppv);
1182 
1183  *ppv = NULL;
1184 
1185  ret = BmpDecoder_Create(packed, icoframe, &This);
1186  if (FAILED(ret)) return ret;
1187 
1188  ret = IWICBitmapDecoder_QueryInterface(&This->IWICBitmapDecoder_iface, iid, ppv);
1189  IWICBitmapDecoder_Release(&This->IWICBitmapDecoder_iface);
1190 
1191  return ret;
1192 }
GLuint GLenum GLsizei GLsizei GLint GLint GLboolean packed
Definition: glext.h:9271
REFIID LPVOID * ppv
Definition: atlbase.h:39
static HRESULT BmpDecoder_Create(int packed, int icoframe, BmpDecoder **ppDecoder)
Definition: bmpdecode.c:1153
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
int ret

Referenced by BmpDecoder_CreateInstance(), and DibDecoder_CreateInstance().

◆ BmpDecoder_CopyPalette()

static HRESULT WINAPI BmpDecoder_CopyPalette ( IWICBitmapDecoder iface,
IWICPalette pIPalette 
)
static

Definition at line 1076 of file bmpdecode.c.

1078 {
1079  TRACE("(%p,%p)\n", iface, pIPalette);
1080 
1082 }
#define WINCODEC_ERR_PALETTEUNAVAILABLE
Definition: winerror.h:3284
#define TRACE(s)
Definition: solgame.cpp:4

◆ BmpDecoder_Create()

static HRESULT BmpDecoder_Create ( int  packed,
int  icoframe,
BmpDecoder **  ppDecoder 
)
static

Definition at line 1153 of file bmpdecode.c.

1154 {
1155  BmpDecoder *This;
1156 
1157  This = HeapAlloc(GetProcessHeap(), 0, sizeof(BmpDecoder));
1158  if (!This) return E_OUTOFMEMORY;
1159 
1160  This->IWICBitmapDecoder_iface.lpVtbl = &BmpDecoder_Vtbl;
1161  This->IWICBitmapFrameDecode_iface.lpVtbl = &BmpDecoder_FrameVtbl;
1162  This->ref = 1;
1163  This->initialized = FALSE;
1164  This->stream = NULL;
1165  This->imagedata = NULL;
1167  This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BmpDecoder.lock");
1168  This->packed = packed;
1169  This->icoframe = icoframe;
1170 
1171  *ppDecoder = This;
1172 
1173  return S_OK;
1174 }
#define DWORD_PTR
Definition: treelist.c:76
GLuint GLenum GLsizei GLsizei GLint GLint GLboolean packed
Definition: glext.h:9271
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static const IWICBitmapDecoderVtbl BmpDecoder_Vtbl
Definition: bmpdecode.c:1136
#define S_OK
Definition: intsafe.h:59
static const IWICBitmapFrameDecodeVtbl BmpDecoder_FrameVtbl
Definition: bmpdecode.c:751

Referenced by BmpDecoder_Construct(), and IcoDibDecoder_CreateInstance().

◆ BmpDecoder_CreateInstance()

HRESULT BmpDecoder_CreateInstance ( REFIID  iid,
void **  ppv 
)

Definition at line 1194 of file bmpdecode.c.

1195 {
1196  return BmpDecoder_Construct(FALSE, FALSE, iid, ppv);
1197 }
REFIID LPVOID * ppv
Definition: atlbase.h:39
static HRESULT BmpDecoder_Construct(int packed, int icoframe, REFIID iid, void **ppv)
Definition: bmpdecode.c:1176

◆ BmpDecoder_FindIconMask()

void BmpDecoder_FindIconMask ( BmpDecoder This,
ULONG mask_offset,
int topdown 
)

Definition at line 1215 of file bmpdecode.c.

1216 {
1217  assert(This->stream != NULL);
1218 
1219  if (This->read_data_func == BmpFrameDecode_ReadUncompressed)
1220  {
1221  /* RGB or BITFIELDS data */
1222  ULONG width, height, bytesperrow, datasize;
1223  IWICBitmapFrameDecode_GetSize(&This->IWICBitmapFrameDecode_iface, &width, &height);
1224  bytesperrow = (((width * This->bitsperpixel)+31)/32)*4;
1225  datasize = bytesperrow * height;
1226  *mask_offset = This->image_offset + datasize;
1227  }
1228  else
1229  *mask_offset = 0;
1230 
1231  *topdown = This->stride > 0;
1232 }
GLint GLint GLsizei width
Definition: gl.h:1546
static SIZE_T datasize
Definition: asm.c:30
#define assert(x)
Definition: debug.h:53
static HRESULT BmpFrameDecode_ReadUncompressed(BmpDecoder *This)
Definition: bmpdecode.c:363
smooth NULL
Definition: ftsmooth.c:416
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
unsigned int ULONG
Definition: retypes.h:1

Referenced by ReadIcoDib().

◆ BmpDecoder_GetColorContexts()

static HRESULT WINAPI BmpDecoder_GetColorContexts ( IWICBitmapDecoder iface,
UINT  cCount,
IWICColorContext **  ppIColorContexts,
UINT pcActualCount 
)
static

Definition at line 1098 of file bmpdecode.c.

1100 {
1101  TRACE("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount);
1103 }
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_UNSUPPORTEDOPERATION
Definition: winerror.h:3300

◆ BmpDecoder_GetContainerFormat()

static HRESULT WINAPI BmpDecoder_GetContainerFormat ( IWICBitmapDecoder iface,
GUID pguidContainerFormat 
)
static

Definition at line 1061 of file bmpdecode.c.

1063 {
1064  memcpy(pguidContainerFormat, &GUID_ContainerFormatBmp, sizeof(GUID));
1065  return S_OK;
1066 }
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59

◆ BmpDecoder_GetDecoderInfo()

static HRESULT WINAPI BmpDecoder_GetDecoderInfo ( IWICBitmapDecoder iface,
IWICBitmapDecoderInfo **  ppIDecoderInfo 
)
static

Definition at line 1068 of file bmpdecode.c.

1070 {
1071  TRACE("(%p,%p)\n", iface, ppIDecoderInfo);
1072 
1073  return get_decoder_info(&CLSID_WICBmpDecoder, ppIDecoderInfo);
1074 }
#define TRACE(s)
Definition: solgame.cpp:4
static GpStatus get_decoder_info(IStream *stream, const struct image_codec **result)
Definition: image.c:4237

◆ BmpDecoder_GetFrame()

static HRESULT WINAPI BmpDecoder_GetFrame ( IWICBitmapDecoder iface,
UINT  index,
IWICBitmapFrameDecode **  ppIBitmapFrame 
)
static

Definition at line 1121 of file bmpdecode.c.

1123 {
1125 
1126  if (index != 0) return E_INVALIDARG;
1127 
1128  if (!This->stream) return WINCODEC_ERR_FRAMEMISSING;
1129 
1130  *ppIBitmapFrame = &This->IWICBitmapFrameDecode_iface;
1131  IWICBitmapDecoder_AddRef(iface);
1132 
1133  return S_OK;
1134 }
#define E_INVALIDARG
Definition: ddrawi.h:101
GLuint index
Definition: glext.h:6031
static BmpDecoder * impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
Definition: bmpdecode.c:83
#define WINCODEC_ERR_FRAMEMISSING
Definition: winerror.h:3293
#define S_OK
Definition: intsafe.h:59

◆ BmpDecoder_GetFrameCount()

static HRESULT WINAPI BmpDecoder_GetFrameCount ( IWICBitmapDecoder iface,
UINT pCount 
)
static

Definition at line 1112 of file bmpdecode.c.

1114 {
1115  if (!pCount) return E_INVALIDARG;
1116 
1117  *pCount = 1;
1118  return S_OK;
1119 }
#define E_INVALIDARG
Definition: ddrawi.h:101
#define S_OK
Definition: intsafe.h:59

◆ BmpDecoder_GetMetadataQueryReader()

static HRESULT WINAPI BmpDecoder_GetMetadataQueryReader ( IWICBitmapDecoder iface,
IWICMetadataQueryReader **  ppIMetadataQueryReader 
)
static

Definition at line 1084 of file bmpdecode.c.

1086 {
1087  TRACE("(%p,%p)\n", iface, ppIMetadataQueryReader);
1089 }
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_UNSUPPORTEDOPERATION
Definition: winerror.h:3300

◆ BmpDecoder_GetPreview()

static HRESULT WINAPI BmpDecoder_GetPreview ( IWICBitmapDecoder iface,
IWICBitmapSource **  ppIBitmapSource 
)
static

Definition at line 1091 of file bmpdecode.c.

1093 {
1094  TRACE("(%p,%p)\n", iface, ppIBitmapSource);
1096 }
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_UNSUPPORTEDOPERATION
Definition: winerror.h:3300

◆ BmpDecoder_GetThumbnail()

static HRESULT WINAPI BmpDecoder_GetThumbnail ( IWICBitmapDecoder iface,
IWICBitmapSource **  ppIThumbnail 
)
static

Definition at line 1105 of file bmpdecode.c.

1107 {
1108  TRACE("(%p,%p)\n", iface, ppIThumbnail);
1110 }
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_CODECNOTHUMBNAIL
Definition: winerror.h:3283

◆ BmpDecoder_GetWICDecoder()

void BmpDecoder_GetWICDecoder ( BmpDecoder This,
IWICBitmapDecoder **  ppDecoder 
)

Definition at line 1209 of file bmpdecode.c.

1210 {
1211  *ppDecoder = &This->IWICBitmapDecoder_iface;
1212 }

Referenced by ReadIcoDib().

◆ BmpDecoder_Initialize()

static HRESULT WINAPI BmpDecoder_Initialize ( IWICBitmapDecoder iface,
IStream pIStream,
WICDecodeOptions  cacheOptions 
)
static

Definition at line 1042 of file bmpdecode.c.

1044 {
1045  HRESULT hr;
1047 
1048  EnterCriticalSection(&This->lock);
1049  hr = BmpDecoder_ReadHeaders(This, pIStream);
1050 
1051  if (SUCCEEDED(hr))
1052  {
1053  This->stream = pIStream;
1054  IStream_AddRef(pIStream);
1055  }
1056  LeaveCriticalSection(&This->lock);
1057 
1058  return hr;
1059 }
HRESULT hr
Definition: shlfolder.c:183
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
LONG HRESULT
Definition: typedefs.h:77
static BmpDecoder * impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
Definition: bmpdecode.c:83
static HRESULT BmpDecoder_ReadHeaders(BmpDecoder *This, IStream *stream)
Definition: bmpdecode.c:765
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ BmpDecoder_QueryCapability()

static HRESULT WINAPI BmpDecoder_QueryCapability ( IWICBitmapDecoder iface,
IStream stream,
DWORD capability 
)
static

Definition at line 1025 of file bmpdecode.c.

1027 {
1028  HRESULT hr;
1030 
1031  TRACE("(%p,%p,%p)\n", iface, stream, capability);
1032 
1033  if (!stream || !capability) return E_INVALIDARG;
1034 
1035  hr = IWICBitmapDecoder_Initialize(iface, stream, WICDecodeMetadataCacheOnDemand);
1036  if (hr != S_OK) return hr;
1037 
1039  return S_OK;
1040 }
HRESULT hr
Definition: shlfolder.c:183
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static BmpDecoder * impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
Definition: bmpdecode.c:83
Definition: parse.h:22
static HRESULT BmpFrameDecode_ReadUnsupported(BmpDecoder *This)
Definition: bmpdecode.c:727
#define S_OK
Definition: intsafe.h:59

◆ BmpDecoder_QueryInterface()

static HRESULT WINAPI BmpDecoder_QueryInterface ( IWICBitmapDecoder iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 973 of file bmpdecode.c.

975 {
977  TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
978 
979  if (!ppv) return E_INVALIDARG;
980 
981  if (IsEqualIID(&IID_IUnknown, iid) ||
982  IsEqualIID(&IID_IWICBitmapDecoder, iid))
983  {
984  *ppv = &This->IWICBitmapDecoder_iface;
985  }
986  else
987  {
988  *ppv = NULL;
989  return E_NOINTERFACE;
990  }
991 
992  IUnknown_AddRef((IUnknown*)*ppv);
993  return S_OK;
994 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
static BmpDecoder * impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
Definition: bmpdecode.c:83
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ BmpDecoder_ReadHeaders()

static HRESULT BmpDecoder_ReadHeaders ( BmpDecoder This,
IStream stream 
)
static

Definition at line 765 of file bmpdecode.c.

766 {
767  HRESULT hr;
768  ULONG bytestoread, bytesread;
770 
771  if (This->initialized) return WINCODEC_ERR_WRONGSTATE;
772 
773  seek.QuadPart = 0;
774  hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL);
775  if (FAILED(hr)) return hr;
776 
777  if (!This->packed)
778  {
779  BITMAPFILEHEADER bfh;
780  hr = IStream_Read(stream, &bfh, sizeof(BITMAPFILEHEADER), &bytesread);
781  if (FAILED(hr)) return hr;
782  if (bytesread != sizeof(BITMAPFILEHEADER) ||
783  bfh.bfType != 0x4d42 /* "BM" */) return E_FAIL;
784  This->image_offset = bfh.bfOffBits;
785  }
786 
787  hr = IStream_Read(stream, &This->bih.bV5Size, sizeof(DWORD), &bytesread);
788  if (FAILED(hr)) return hr;
789  if (bytesread != sizeof(DWORD) ||
790  (This->bih.bV5Size != sizeof(BITMAPCOREHEADER) &&
791  This->bih.bV5Size != sizeof(BITMAPCOREHEADER2) &&
792  This->bih.bV5Size != sizeof(BITMAPINFOHEADER) &&
793  This->bih.bV5Size != sizeof(BITMAPV4HEADER) &&
794  This->bih.bV5Size != sizeof(BITMAPV5HEADER))) return E_FAIL;
795 
796  bytestoread = This->bih.bV5Size-sizeof(DWORD);
797  hr = IStream_Read(stream, &This->bih.bV5Width, bytestoread, &bytesread);
798  if (FAILED(hr)) return hr;
799  if (bytestoread != bytesread) return E_FAIL;
800 
801  if (This->packed)
802  This->palette_offset = This->bih.bV5Size;
803  else
804  This->palette_offset = sizeof(BITMAPFILEHEADER) + This->bih.bV5Size;
805 
806  if (This->icoframe)
807  {
808  if (This->bih.bV5Size == sizeof(BITMAPCOREHEADER))
809  {
810  BITMAPCOREHEADER *bch = (BITMAPCOREHEADER*)&This->bih;
811  bch->bcHeight /= 2;
812  }
813  else
814  {
815  This->bih.bV5Height /= 2;
816  }
817  }
818 
819  /* if this is a BITMAPINFOHEADER with BI_BITFIELDS compression, we need to
820  read the extra fields */
821  if (This->bih.bV5Size == sizeof(BITMAPINFOHEADER) &&
822  This->bih.bV5Compression == BI_BITFIELDS)
823  {
824  hr = IStream_Read(stream, &This->bih.bV5RedMask, 12, &bytesread);
825  if (FAILED(hr)) return hr;
826  if (bytesread != 12) return E_FAIL;
827  This->bih.bV5AlphaMask = 0;
828  This->palette_offset += 12;
829  }
830 
831  /* decide what kind of bitmap this is and how/if we can read it */
832  if (This->bih.bV5Size == sizeof(BITMAPCOREHEADER))
833  {
834  BITMAPCOREHEADER *bch = (BITMAPCOREHEADER*)&This->bih;
835  TRACE("BITMAPCOREHEADER with depth=%i\n", bch->bcBitCount);
836  This->bitsperpixel = bch->bcBitCount;
837  This->read_data_func = BmpFrameDecode_ReadUncompressed;
838  switch(bch->bcBitCount)
839  {
840  case 1:
841  This->pixelformat = &GUID_WICPixelFormat1bppIndexed;
842  break;
843  case 2:
844  This->pixelformat = &GUID_WICPixelFormat2bppIndexed;
845  break;
846  case 4:
847  This->pixelformat = &GUID_WICPixelFormat4bppIndexed;
848  break;
849  case 8:
850  This->pixelformat = &GUID_WICPixelFormat8bppIndexed;
851  break;
852  case 24:
853  This->pixelformat = &GUID_WICPixelFormat24bppBGR;
854  break;
855  default:
856  This->pixelformat = &GUID_WICPixelFormatUndefined;
857  WARN("unsupported bit depth %i for BITMAPCOREHEADER\n", bch->bcBitCount);
858  break;
859  }
860  }
861  else /* struct is compatible with BITMAPINFOHEADER */
862  {
863  TRACE("bitmap header=%i compression=%i depth=%i\n", This->bih.bV5Size, This->bih.bV5Compression, This->bih.bV5BitCount);
864  switch(This->bih.bV5Compression)
865  {
866  case BI_RGB:
867  This->bitsperpixel = This->bih.bV5BitCount;
868  This->read_data_func = BmpFrameDecode_ReadUncompressed;
869  switch(This->bih.bV5BitCount)
870  {
871  case 1:
872  This->pixelformat = &GUID_WICPixelFormat1bppIndexed;
873  break;
874  case 2:
875  This->pixelformat = &GUID_WICPixelFormat2bppIndexed;
876  break;
877  case 4:
878  This->pixelformat = &GUID_WICPixelFormat4bppIndexed;
879  break;
880  case 8:
881  This->pixelformat = &GUID_WICPixelFormat8bppIndexed;
882  break;
883  case 16:
884  This->pixelformat = &GUID_WICPixelFormat16bppBGR555;
885  break;
886  case 24:
887  This->pixelformat = &GUID_WICPixelFormat24bppBGR;
888  break;
889  case 32:
890  This->pixelformat = &GUID_WICPixelFormat32bppBGR;
891  break;
892  default:
893  This->pixelformat = &GUID_WICPixelFormatUndefined;
894  FIXME("unsupported bit depth %i for uncompressed RGB\n", This->bih.bV5BitCount);
895  }
896  break;
897  case BI_RLE8:
898  This->bitsperpixel = 32;
899  This->read_data_func = BmpFrameDecode_ReadRLE8;
900  This->pixelformat = &GUID_WICPixelFormat32bppBGR;
901  break;
902  case BI_RLE4:
903  This->bitsperpixel = 32;
904  This->read_data_func = BmpFrameDecode_ReadRLE4;
905  This->pixelformat = &GUID_WICPixelFormat32bppBGR;
906  break;
907  case BI_BITFIELDS:
908  {
909  const struct bitfields_format *format;
910  if (This->bih.bV5Size == sizeof(BITMAPCOREHEADER2))
911  {
912  /* BCH2 doesn't support bitfields; this is Huffman 1D compression */
913  This->bitsperpixel = 0;
914  This->read_data_func = BmpFrameDecode_ReadUnsupported;
915  This->pixelformat = &GUID_WICPixelFormatUndefined;
916  FIXME("Huffman 1D compression is unsupported\n");
917  break;
918  }
919  This->bitsperpixel = This->bih.bV5BitCount;
920  for (format = bitfields_formats; format->bitcount; format++)
921  {
922  if ((format->bitcount == This->bih.bV5BitCount) &&
923  (format->redmask == This->bih.bV5RedMask) &&
924  (format->greenmask == This->bih.bV5GreenMask) &&
925  (format->bluemask == This->bih.bV5BlueMask) &&
926  (format->alphamask == This->bih.bV5AlphaMask))
927  {
928  This->read_data_func = format->read_data_func;
929  This->pixelformat = format->pixelformat;
930  break;
931  }
932  }
933  if (!format->bitcount)
934  {
935  This->read_data_func = BmpFrameDecode_ReadUncompressed;
936  This->pixelformat = &GUID_WICPixelFormatUndefined;
937  FIXME("unsupported bitfields type depth=%i red=%x green=%x blue=%x alpha=%x\n",
938  This->bih.bV5BitCount, This->bih.bV5RedMask, This->bih.bV5GreenMask, This->bih.bV5BlueMask, This->bih.bV5AlphaMask);
939  }
940  break;
941  }
942  default:
943  This->bitsperpixel = 0;
944  This->read_data_func = BmpFrameDecode_ReadUnsupported;
945  This->pixelformat = &GUID_WICPixelFormatUndefined;
946  FIXME("unsupported bitmap type header=%i compression=%i depth=%i\n", This->bih.bV5Size, This->bih.bV5Compression, This->bih.bV5BitCount);
947  break;
948  }
949  }
950 
951  if (This->packed)
952  {
953  /* In a packed DIB, the image follows the palette. */
954  ULONG palette_count, palette_size;
955  if (This->bih.bV5ClrUsed)
956  palette_count = This->bih.bV5ClrUsed;
957  else if (This->bih.bV5BitCount <= 8)
958  palette_count = 1 << This->bih.bV5BitCount;
959  else
960  palette_count = 0;
961  if (This->bih.bV5Size == sizeof(BITMAPCOREHEADER))
962  palette_size = sizeof(RGBTRIPLE) * palette_count;
963  else
964  palette_size = sizeof(RGBQUAD) * palette_count;
965  This->image_offset = This->palette_offset + palette_size;
966  }
967 
968  This->initialized = TRUE;
969 
970  return S_OK;
971 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
#define E_FAIL
Definition: ddrawi.h:102
#define DWORD
Definition: nt_native.h:44
#define BI_BITFIELDS
Definition: mmreg.h:507
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static HRESULT BmpFrameDecode_ReadRLE4(BmpDecoder *This)
Definition: bmpdecode.c:587
static HRESULT BmpFrameDecode_ReadUncompressed(BmpDecoder *This)
Definition: bmpdecode.c:363
#define FIXME(fmt,...)
Definition: debug.h:110
static const struct bitfields_format bitfields_formats[]
Definition: bmpdecode.c:742
smooth NULL
Definition: ftsmooth.c:416
struct tagRGBTRIPLE RGBTRIPLE
struct tagRGBQUAD RGBQUAD
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
int seek(void *fd, ulong off, int mode)
Definition: pe.c:51
Definition: parse.h:22
static unsigned int palette_size(DWORD flags)
Definition: palette.c:241
static HRESULT BmpFrameDecode_ReadRLE8(BmpDecoder *This)
Definition: bmpdecode.c:463
static HRESULT BmpFrameDecode_ReadUnsupported(BmpDecoder *This)
Definition: bmpdecode.c:727
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273
#define S_OK
Definition: intsafe.h:59
struct tagBITMAPFILEHEADER BITMAPFILEHEADER
#define BI_RLE4
Definition: precomp.h:35
unsigned int ULONG
Definition: retypes.h:1
#define BI_RLE8
Definition: wingdi.h:35
#define BI_RGB
Definition: precomp.h:34

Referenced by BmpDecoder_Initialize().

◆ BmpDecoder_Release()

static ULONG WINAPI BmpDecoder_Release ( IWICBitmapDecoder iface)
static

Definition at line 1006 of file bmpdecode.c.

1007 {
1010 
1011  TRACE("(%p) refcount=%u\n", iface, ref);
1012 
1013  if (ref == 0)
1014  {
1015  if (This->stream) IStream_Release(This->stream);
1016  HeapFree(GetProcessHeap(), 0, This->imagedata);
1017  This->lock.DebugInfo->Spare[0] = 0;
1018  DeleteCriticalSection(&This->lock);
1019  HeapFree(GetProcessHeap(), 0, This);
1020  }
1021 
1022  return ref;
1023 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
static BmpDecoder * impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
Definition: bmpdecode.c:83
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ BmpFrameDecode_AddRef()

static ULONG WINAPI BmpFrameDecode_AddRef ( IWICBitmapFrameDecode iface)
static

Definition at line 118 of file bmpdecode.c.

119 {
121 
122  return IWICBitmapDecoder_AddRef(&This->IWICBitmapDecoder_iface);
123 }
static BmpDecoder * impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
Definition: bmpdecode.c:88

◆ BmpFrameDecode_CopyPalette()

static HRESULT WINAPI BmpFrameDecode_CopyPalette ( IWICBitmapFrameDecode iface,
IWICPalette pIPalette 
)
static

Definition at line 205 of file bmpdecode.c.

207 {
208  HRESULT hr;
210  int count;
211  WICColor *wiccolors=NULL;
212  RGBTRIPLE *bgrcolors=NULL;
213 
214  TRACE("(%p,%p)\n", iface, pIPalette);
215 
216  EnterCriticalSection(&This->lock);
217 
218  if (This->bih.bV5Size == sizeof(BITMAPCOREHEADER))
219  {
220  BITMAPCOREHEADER *bch = (BITMAPCOREHEADER*)&This->bih;
221  if (bch->bcBitCount <= 8)
222  {
223  /* 2**n colors in BGR format after the header */
224  ULONG tablesize, bytesread;
226  int i;
227 
228  count = 1 << bch->bcBitCount;
229  wiccolors = HeapAlloc(GetProcessHeap(), 0, sizeof(WICColor) * count);
230  tablesize = sizeof(RGBTRIPLE) * count;
231  bgrcolors = HeapAlloc(GetProcessHeap(), 0, tablesize);
232  if (!wiccolors || !bgrcolors)
233  {
234  hr = E_OUTOFMEMORY;
235  goto end;
236  }
237 
238  offset.QuadPart = This->palette_offset;
239  hr = IStream_Seek(This->stream, offset, STREAM_SEEK_SET, NULL);
240  if (FAILED(hr)) goto end;
241 
242  hr = IStream_Read(This->stream, bgrcolors, tablesize, &bytesread);
243  if (FAILED(hr)) goto end;
244  if (bytesread != tablesize) {
245  hr = E_FAIL;
246  goto end;
247  }
248 
249  for (i=0; i<count; i++)
250  {
251  wiccolors[i] = 0xff000000|
252  (bgrcolors[i].rgbtRed<<16)|
253  (bgrcolors[i].rgbtGreen<<8)|
254  bgrcolors[i].rgbtBlue;
255  }
256  }
257  else
258  {
260  goto end;
261  }
262  }
263  else
264  {
265  if (This->bih.bV5BitCount <= 8)
266  {
267  ULONG tablesize, bytesread;
269  int i;
270 
271  if (This->bih.bV5ClrUsed == 0)
272  count = 1 << This->bih.bV5BitCount;
273  else
274  count = min(This->bih.bV5ClrUsed, 1 << This->bih.bV5BitCount);
275 
276  tablesize = sizeof(WICColor) * count;
277  wiccolors = HeapAlloc(GetProcessHeap(), 0, tablesize);
278  if (!wiccolors)
279  {
280  hr = E_OUTOFMEMORY;
281  goto end;
282  }
283 
284  offset.QuadPart = This->palette_offset;
285  hr = IStream_Seek(This->stream, offset, STREAM_SEEK_SET, NULL);
286  if (FAILED(hr)) goto end;
287 
288  hr = IStream_Read(This->stream, wiccolors, tablesize, &bytesread);
289  if (FAILED(hr)) goto end;
290  if (bytesread != tablesize) {
291  hr = E_FAIL;
292  goto end;
293  }
294 
295  /* convert from BGR to BGRA by setting alpha to 100% */
296  for (i=0; i<count; i++)
297  wiccolors[i] |= 0xff000000;
298  }
299  else
300  {
302  goto end;
303  }
304  }
305 
306 end:
307 
308  LeaveCriticalSection(&This->lock);
309 
310  if (SUCCEEDED(hr))
311  hr = IWICPalette_InitializeCustom(pIPalette, wiccolors, count);
312 
313  HeapFree(GetProcessHeap(), 0, wiccolors);
314  HeapFree(GetProcessHeap(), 0, bgrcolors);
315  return hr;
316 }
BYTE rgbtBlue
Definition: wingdi.h:1433
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLintptr offset
Definition: glext.h:5920
GLuint GLuint end
Definition: gl.h:1545
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define E_FAIL
Definition: ddrawi.h:102
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 E_OUTOFMEMORY
Definition: ddrawi.h:100
#define WINCODEC_ERR_PALETTEUNAVAILABLE
Definition: winerror.h:3284
smooth NULL
Definition: ftsmooth.c:416
struct tagRGBTRIPLE RGBTRIPLE
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
if(!(yy_init))
Definition: macro.lex.yy.c:714
LONG HRESULT
Definition: typedefs.h:77
static BmpDecoder * impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
Definition: bmpdecode.c:88
#define min(a, b)
Definition: monoChain.cc:55
BYTE rgbtRed
Definition: wingdi.h:1435
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
UINT32 WICColor
Definition: wincodec.idl:250
#define HeapFree(x, y, z)
Definition: compat.h:394
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ BmpFrameDecode_CopyPixels()

static HRESULT WINAPI BmpFrameDecode_CopyPixels ( IWICBitmapFrameDecode iface,
const WICRect prc,
UINT  cbStride,
UINT  cbBufferSize,
BYTE pbBuffer 
)
static

Definition at line 318 of file bmpdecode.c.

320 {
322  HRESULT hr=S_OK;
323  UINT width, height;
324  TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
325 
326  EnterCriticalSection(&This->lock);
327  if (!This->imagedata)
328  {
329  hr = This->read_data_func(This);
330  }
331  LeaveCriticalSection(&This->lock);
332  if (FAILED(hr)) return hr;
333 
334  hr = BmpFrameDecode_GetSize(iface, &width, &height);
335  if (FAILED(hr)) return hr;
336 
337  return copy_pixels(This->bitsperpixel, This->imagedatastart,
338  width, height, This->stride,
339  prc, cbStride, cbBufferSize, pbBuffer);
340 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static const char * debug_wic_rect(const WICRect *rect)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
void copy_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *size, const struct pixel_format_desc *format) DECLSPEC_HIDDEN
Definition: surface.c:1601
#define S_OK
Definition: intsafe.h:59
static BmpDecoder * impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
Definition: bmpdecode.c:88
static HRESULT WINAPI BmpFrameDecode_GetSize(IWICBitmapFrameDecode *iface, UINT *puiWidth, UINT *puiHeight)
Definition: bmpdecode.c:132
unsigned int UINT
Definition: ndis.h:50
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
_Out_ LPRECT prc
Definition: ntgdi.h:1658

◆ BmpFrameDecode_GetColorContexts()

static HRESULT WINAPI BmpFrameDecode_GetColorContexts ( IWICBitmapFrameDecode iface,
UINT  cCount,
IWICColorContext **  ppIColorContexts,
UINT pcActualCount 
)
static

Definition at line 349 of file bmpdecode.c.

351 {
352  TRACE("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount);
354 }
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_UNSUPPORTEDOPERATION
Definition: winerror.h:3300

◆ BmpFrameDecode_GetMetadataQueryReader()

static HRESULT WINAPI BmpFrameDecode_GetMetadataQueryReader ( IWICBitmapFrameDecode iface,
IWICMetadataQueryReader **  ppIMetadataQueryReader 
)
static

Definition at line 342 of file bmpdecode.c.

344 {
345  TRACE("(%p,%p)\n", iface, ppIMetadataQueryReader);
347 }
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_UNSUPPORTEDOPERATION
Definition: winerror.h:3300

◆ BmpFrameDecode_GetPixelFormat()

static HRESULT WINAPI BmpFrameDecode_GetPixelFormat ( IWICBitmapFrameDecode iface,
WICPixelFormatGUID pPixelFormat 
)
static

Definition at line 152 of file bmpdecode.c.

154 {
156  TRACE("(%p,%p)\n", iface, pPixelFormat);
157 
158  memcpy(pPixelFormat, This->pixelformat, sizeof(GUID));
159 
160  return S_OK;
161 }
#define TRACE(s)
Definition: solgame.cpp:4
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
static BmpDecoder * impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
Definition: bmpdecode.c:88

◆ BmpFrameDecode_GetResolution()

static HRESULT WINAPI BmpFrameDecode_GetResolution ( IWICBitmapFrameDecode iface,
double pDpiX,
double pDpiY 
)
static

Definition at line 196 of file bmpdecode.c.

198 {
200  TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
201 
202  return BmpHeader_GetResolution(&This->bih, pDpiX, pDpiY);
203 }
static HRESULT BmpHeader_GetResolution(BITMAPV5HEADER *bih, double *pDpiX, double *pDpiY)
Definition: bmpdecode.c:163
#define TRACE(s)
Definition: solgame.cpp:4
static BmpDecoder * impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
Definition: bmpdecode.c:88

◆ BmpFrameDecode_GetSize()

static HRESULT WINAPI BmpFrameDecode_GetSize ( IWICBitmapFrameDecode iface,
UINT puiWidth,
UINT puiHeight 
)
static

Definition at line 132 of file bmpdecode.c.

134 {
136  TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
137 
138  if (This->bih.bV5Size == sizeof(BITMAPCOREHEADER))
139  {
140  BITMAPCOREHEADER *bch = (BITMAPCOREHEADER*)&This->bih;
141  *puiWidth = bch->bcWidth;
142  *puiHeight = bch->bcHeight;
143  }
144  else
145  {
146  *puiWidth = This->bih.bV5Width;
147  *puiHeight = abs(This->bih.bV5Height);
148  }
149  return S_OK;
150 }
#define abs(i)
Definition: fconv.c:206
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
static BmpDecoder * impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
Definition: bmpdecode.c:88

Referenced by BmpFrameDecode_CopyPixels().

◆ BmpFrameDecode_GetThumbnail()

static HRESULT WINAPI BmpFrameDecode_GetThumbnail ( IWICBitmapFrameDecode iface,
IWICBitmapSource **  ppIThumbnail 
)
static

Definition at line 356 of file bmpdecode.c.

358 {
359  TRACE("(%p,%p)\n", iface, ppIThumbnail);
361 }
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_CODECNOTHUMBNAIL
Definition: winerror.h:3283

◆ BmpFrameDecode_QueryInterface()

static HRESULT WINAPI BmpFrameDecode_QueryInterface ( IWICBitmapFrameDecode iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 93 of file bmpdecode.c.

95 {
97 
98  TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
99 
100  if (!ppv) return E_INVALIDARG;
101 
102  if (IsEqualIID(&IID_IUnknown, iid) ||
103  IsEqualIID(&IID_IWICBitmapSource, iid) ||
104  IsEqualIID(&IID_IWICBitmapFrameDecode, iid))
105  {
106  *ppv = &This->IWICBitmapFrameDecode_iface;
107  }
108  else
109  {
110  *ppv = NULL;
111  return E_NOINTERFACE;
112  }
113 
114  IUnknown_AddRef((IUnknown*)*ppv);
115  return S_OK;
116 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
static BmpDecoder * impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
Definition: bmpdecode.c:88
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ BmpFrameDecode_ReadRGB8()

static HRESULT BmpFrameDecode_ReadRGB8 ( BmpDecoder This)
static

Definition at line 420 of file bmpdecode.c.

421 {
422  HRESULT hr;
423  UINT width, height;
424 
425  hr = IWICBitmapFrameDecode_GetSize(&This->IWICBitmapFrameDecode_iface, &width, &height);
426 
427  if (SUCCEEDED(hr))
428  {
430  }
431 
432  if (SUCCEEDED(hr))
433  {
434  reverse_bgr8(This->bitsperpixel/8, This->imagedatastart,
435  width, height, This->stride);
436  }
437 
438  return hr;
439 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
static HRESULT BmpFrameDecode_ReadUncompressed(BmpDecoder *This)
Definition: bmpdecode.c:363
LONG HRESULT
Definition: typedefs.h:77
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
unsigned int UINT
Definition: ndis.h:50
void reverse_bgr8(UINT bytesperpixel, LPBYTE bits, UINT width, UINT height, INT stride)
Definition: main.c:212
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ BmpFrameDecode_ReadRLE4()

static HRESULT BmpFrameDecode_ReadRLE4 ( BmpDecoder This)
static

Definition at line 587 of file bmpdecode.c.

588 {
589  UINT bytesperrow;
590  UINT width, height;
591  BYTE rledata[4096];
592  UINT datasize, palettesize;
593  DWORD palette[16];
594  UINT x, y;
595  DWORD *bgrdata;
596  HRESULT hr;
597  LARGE_INTEGER offbits;
598  ULONG cursor=0, bytesread=0;
599 
600  width = This->bih.bV5Width;
601  height = abs(This->bih.bV5Height);
602  bytesperrow = width * 4;
603  datasize = bytesperrow * height;
604  if (This->bih.bV5ClrUsed && This->bih.bV5ClrUsed < 16)
605  palettesize = 4 * This->bih.bV5ClrUsed;
606  else
607  palettesize = 4 * 16;
608 
609  This->imagedata = HeapAlloc(GetProcessHeap(), 0, datasize);
610  if (!This->imagedata)
611  {
612  hr = E_OUTOFMEMORY;
613  goto fail;
614  }
615 
616  /* read palette */
617  offbits.QuadPart = This->palette_offset;
618  hr = IStream_Seek(This->stream, offbits, STREAM_SEEK_SET, NULL);
619  if (FAILED(hr)) goto fail;
620 
621  hr = IStream_Read(This->stream, palette, palettesize, &bytesread);
622  if (FAILED(hr) || bytesread != palettesize) goto fail;
623 
624  /* read RLE data */
625  offbits.QuadPart = This->image_offset;
626  hr = IStream_Seek(This->stream, offbits, STREAM_SEEK_SET, NULL);
627  if (FAILED(hr)) goto fail;
628 
629  /* decode RLE */
630  bgrdata = (DWORD*)This->imagedata;
631  x = 0;
632  y = 0;
633  cursor = 0;
634  bytesread = 0;
635  while (y < height)
636  {
637  BYTE length;
638  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &length);
639 
640  if (FAILED(hr))
641  goto fail;
642  else if (length == 0)
643  {
644  /* escape code */
645  BYTE escape;
646  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &escape);
647  if (FAILED(hr))
648  goto fail;
649  switch(escape)
650  {
651  case 0: /* end of line */
652  x = 0;
653  y++;
654  break;
655  case 1: /* end of bitmap */
656  goto end;
657  case 2: /* delta */
658  {
659  BYTE dx, dy;
660  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &dx);
661  if (SUCCEEDED(hr))
662  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &dy);
663  if (FAILED(hr))
664  goto fail;
665  x += dx;
666  y += dy;
667  break;
668  }
669  default: /* absolute mode */
670  {
671  BYTE realsize=0;
672  length = escape;
673  while (length-- && x < width)
674  {
675  BYTE colors;
676  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &colors);
677  realsize++;
678  if (FAILED(hr))
679  goto fail;
680  bgrdata[y*width + x++] = palette[colors>>4];
681  if (length-- && x < width)
682  bgrdata[y*width + x++] = palette[colors&0xf];
683  else
684  break;
685  }
686  if (realsize & 1)
687  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &length); /* skip pad byte */
688  if (FAILED(hr))
689  goto fail;
690  }
691  }
692  }
693  else
694  {
695  BYTE colors;
696  DWORD color1;
697  DWORD color2;
698  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &colors);
699  if (FAILED(hr))
700  goto fail;
701  color1 = palette[colors>>4];
702  color2 = palette[colors&0xf];
703  while (length-- && x < width)
704  {
705  bgrdata[y*width + x++] = color1;
706  if (length-- && x < width)
707  bgrdata[y*width + x++] = color2;
708  else
709  break;
710  }
711  }
712  }
713 
714 end:
715  This->imagedatastart = This->imagedata + (height-1) * bytesperrow;
716  This->stride = -bytesperrow;
717 
718  return S_OK;
719 
720 fail:
721  HeapFree(GetProcessHeap(), 0, This->imagedata);
722  This->imagedata = NULL;
723  if (SUCCEEDED(hr)) hr = E_FAIL;
724  return hr;
725 }
#define abs(i)
Definition: fconv.c:206
GLint GLint GLsizei width
Definition: gl.h:1546
static HRESULT ReadByte(IStream *stream, BYTE *buffer, ULONG buffer_size, ULONG *cursor, ULONG *bytesread, BYTE *result)
Definition: bmpdecode.c:441
static SIZE_T datasize
Definition: asm.c:30
HRESULT hr
Definition: shlfolder.c:183
GLint dy
Definition: linetemp.h:97
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint end
Definition: gl.h:1545
#define E_FAIL
Definition: ddrawi.h:102
while(1)
Definition: macro.lex.yy.c:740
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define S_OK
Definition: intsafe.h:59
const char cursor[]
Definition: icontest.c:13
unsigned int UINT
Definition: ndis.h:50
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint dx
Definition: linetemp.h:97
static WCHAR escape[]
Definition: url.c:36
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394
#define SUCCEEDED(hr)
Definition: intsafe.h:57
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by BmpDecoder_ReadHeaders().

◆ BmpFrameDecode_ReadRLE8()

static HRESULT BmpFrameDecode_ReadRLE8 ( BmpDecoder This)
static

Definition at line 463 of file bmpdecode.c.

464 {
465  UINT bytesperrow;
466  UINT width, height;
467  BYTE rledata[4096];
468  UINT datasize, palettesize;
469  DWORD palette[256];
470  UINT x, y;
471  DWORD *bgrdata;
472  HRESULT hr;
473  LARGE_INTEGER offbits;
474  ULONG cursor=0, bytesread=0;
475 
476  width = This->bih.bV5Width;
477  height = abs(This->bih.bV5Height);
478  bytesperrow = width * 4;
479  datasize = bytesperrow * height;
480  if (This->bih.bV5ClrUsed && This->bih.bV5ClrUsed < 256)
481  palettesize = 4 * This->bih.bV5ClrUsed;
482  else
483  palettesize = 4 * 256;
484 
485  This->imagedata = HeapAlloc(GetProcessHeap(), 0, datasize);
486  if (!This->imagedata)
487  {
488  hr = E_OUTOFMEMORY;
489  goto fail;
490  }
491 
492  /* read palette */
493  offbits.QuadPart = This->palette_offset;
494  hr = IStream_Seek(This->stream, offbits, STREAM_SEEK_SET, NULL);
495  if (FAILED(hr)) goto fail;
496 
497  hr = IStream_Read(This->stream, palette, palettesize, &bytesread);
498  if (FAILED(hr) || bytesread != palettesize) goto fail;
499 
500  /* read RLE data */
501  offbits.QuadPart = This->image_offset;
502  hr = IStream_Seek(This->stream, offbits, STREAM_SEEK_SET, NULL);
503  if (FAILED(hr)) goto fail;
504 
505  /* decode RLE */
506  bgrdata = (DWORD*)This->imagedata;
507  x = 0;
508  y = 0;
509  cursor = 0;
510  bytesread = 0;
511  while (y < height)
512  {
513  BYTE length;
514  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &length);
515 
516  if (FAILED(hr))
517  goto fail;
518  else if (length == 0)
519  {
520  /* escape code */
521  BYTE escape;
522  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &escape);
523  if (FAILED(hr))
524  goto fail;
525  switch(escape)
526  {
527  case 0: /* end of line */
528  x = 0;
529  y++;
530  break;
531  case 1: /* end of bitmap */
532  goto end;
533  case 2: /* delta */
534  {
535  BYTE dx, dy;
536  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &dx);
537  if (SUCCEEDED(hr))
538  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &dy);
539  if (FAILED(hr))
540  goto fail;
541  x += dx;
542  y += dy;
543  break;
544  }
545  default: /* absolute mode */
546  length = escape;
547  while (length-- && x < width)
548  {
549  BYTE index;
550  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &index);
551  if (FAILED(hr))
552  goto fail;
553  bgrdata[y*width + x++] = palette[index];
554  }
555  if (escape & 1)
556  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &length); /* skip pad byte */
557  if (FAILED(hr))
558  goto fail;
559  }
560  }
561  else
562  {
563  BYTE index;
564  DWORD color;
565  hr = ReadByte(This->stream, rledata, 4096, &cursor, &bytesread, &index);
566  if (FAILED(hr))
567  goto fail;
568  color = palette[index];
569  while (length-- && x < width)
570  bgrdata[y*width + x++] = color;
571  }
572  }
573 
574 end:
575  This->imagedatastart = This->imagedata + (height-1) * bytesperrow;
576  This->stride = -bytesperrow;
577 
578  return S_OK;
579 
580 fail:
581  HeapFree(GetProcessHeap(), 0, This->imagedata);
582  This->imagedata = NULL;
583  if (SUCCEEDED(hr)) hr = E_FAIL;
584  return hr;
585 }
#define abs(i)
Definition: fconv.c:206
GLint GLint GLsizei width
Definition: gl.h:1546
static HRESULT ReadByte(IStream *stream, BYTE *buffer, ULONG buffer_size, ULONG *cursor, ULONG *bytesread, BYTE *result)
Definition: bmpdecode.c:441
static SIZE_T datasize
Definition: asm.c:30
HRESULT hr
Definition: shlfolder.c:183
GLint dy
Definition: linetemp.h:97
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint end
Definition: gl.h:1545
#define E_FAIL
Definition: ddrawi.h:102
while(1)
Definition: macro.lex.yy.c:740
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLuint color
Definition: glext.h:6243
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
#define index(s, c)
Definition: various.h:29
unsigned char BYTE
Definition: mem.h:68
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define S_OK
Definition: intsafe.h:59
const char cursor[]
Definition: icontest.c:13
unsigned int UINT
Definition: ndis.h:50
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint dx
Definition: linetemp.h:97
static WCHAR escape[]
Definition: url.c:36
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394
#define SUCCEEDED(hr)
Definition: intsafe.h:57
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by BmpDecoder_ReadHeaders().

◆ BmpFrameDecode_ReadUncompressed()

static HRESULT BmpFrameDecode_ReadUncompressed ( BmpDecoder This)
static

Definition at line 363 of file bmpdecode.c.

364 {
365  UINT bytesperrow;
366  UINT width, height;
367  UINT datasize;
368  int bottomup;
369  HRESULT hr;
370  LARGE_INTEGER offbits;
371  ULONG bytesread;
372 
373  if (This->bih.bV5Size == sizeof(BITMAPCOREHEADER))
374  {
375  BITMAPCOREHEADER *bch = (BITMAPCOREHEADER*)&This->bih;
376  width = bch->bcWidth;
377  height = bch->bcHeight;
378  bottomup = 1;
379  }
380  else
381  {
382  width = This->bih.bV5Width;
383  height = abs(This->bih.bV5Height);
384  bottomup = (This->bih.bV5Height > 0);
385  }
386 
387  /* row sizes in BMP files must be divisible by 4 bytes */
388  bytesperrow = (((width * This->bitsperpixel)+31)/32)*4;
389  datasize = bytesperrow * height;
390 
391  This->imagedata = HeapAlloc(GetProcessHeap(), 0, datasize);
392  if (!This->imagedata) return E_OUTOFMEMORY;
393 
394  offbits.QuadPart = This->image_offset;
395  hr = IStream_Seek(This->stream, offbits, STREAM_SEEK_SET, NULL);
396  if (FAILED(hr)) goto fail;
397 
398  hr = IStream_Read(This->stream, This->imagedata, datasize, &bytesread);
399  if (FAILED(hr) || bytesread != datasize) goto fail;
400 
401  if (bottomup)
402  {
403  This->imagedatastart = This->imagedata + (height-1) * bytesperrow;
404  This->stride = -bytesperrow;
405  }
406  else
407  {
408  This->imagedatastart = This->imagedata;
409  This->stride = bytesperrow;
410  }
411  return S_OK;
412 
413 fail:
414  HeapFree(GetProcessHeap(), 0, This->imagedata);
415  This->imagedata = NULL;
416  if (SUCCEEDED(hr)) hr = E_FAIL;
417  return hr;
418 }
#define abs(i)
Definition: fconv.c:206
GLint GLint GLsizei width
Definition: gl.h:1546
static SIZE_T datasize
Definition: asm.c:30
HRESULT hr
Definition: shlfolder.c:183
#define E_FAIL
Definition: ddrawi.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define S_OK
Definition: intsafe.h:59
unsigned int UINT
Definition: ndis.h:50
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394
#define SUCCEEDED(hr)
Definition: intsafe.h:57
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by BmpDecoder_FindIconMask(), BmpDecoder_ReadHeaders(), and BmpFrameDecode_ReadRGB8().

◆ BmpFrameDecode_ReadUnsupported()

static HRESULT BmpFrameDecode_ReadUnsupported ( BmpDecoder This)
static

Definition at line 727 of file bmpdecode.c.

728 {
729  return E_FAIL;
730 }
#define E_FAIL
Definition: ddrawi.h:102

Referenced by BmpDecoder_QueryCapability(), and BmpDecoder_ReadHeaders().

◆ BmpFrameDecode_Release()

static ULONG WINAPI BmpFrameDecode_Release ( IWICBitmapFrameDecode iface)
static

Definition at line 125 of file bmpdecode.c.

126 {
128 
129  return IWICBitmapDecoder_Release(&This->IWICBitmapDecoder_iface);
130 }
static BmpDecoder * impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
Definition: bmpdecode.c:88

◆ BmpHeader_GetResolution()

static HRESULT BmpHeader_GetResolution ( BITMAPV5HEADER *  bih,
double pDpiX,
double pDpiY 
)
static

Definition at line 163 of file bmpdecode.c.

164 {
165  LONG resx = 0, resy = 0;
166 
167  switch (bih->bV5Size)
168  {
169  default:
170  case sizeof(BITMAPCOREHEADER):
171  break;
172 
173  case sizeof(BITMAPCOREHEADER2):
174  case sizeof(BITMAPINFOHEADER):
175  case sizeof(BITMAPV4HEADER):
176  case sizeof(BITMAPV5HEADER):
177  resx = bih->bV5XPelsPerMeter;
178  resy = bih->bV5YPelsPerMeter;
179  break;
180  }
181 
182  if (!resx || !resy)
183  {
184  *pDpiX = 96.0;
185  *pDpiY = 96.0;
186  }
187  else
188  {
189  *pDpiX = resx * 0.0254;
190  *pDpiY = resy * 0.0254;
191  }
192 
193  return S_OK;
194 }
long LONG
Definition: pedump.c:60
struct tagBITMAPCOREHEADER BITMAPCOREHEADER
#define S_OK
Definition: intsafe.h:59

Referenced by BmpFrameDecode_GetResolution().

◆ DibDecoder_CreateInstance()

HRESULT DibDecoder_CreateInstance ( REFIID  iid,
void **  ppv 
)

Definition at line 1199 of file bmpdecode.c.

1200 {
1201  return BmpDecoder_Construct(TRUE, FALSE, iid, ppv);
1202 }
#define TRUE
Definition: types.h:120
REFIID LPVOID * ppv
Definition: atlbase.h:39
static HRESULT BmpDecoder_Construct(int packed, int icoframe, REFIID iid, void **ppv)
Definition: bmpdecode.c:1176

◆ IcoDibDecoder_CreateInstance()

HRESULT IcoDibDecoder_CreateInstance ( BmpDecoder **  ppDecoder)

Definition at line 1204 of file bmpdecode.c.

1205 {
1206  return BmpDecoder_Create(TRUE, TRUE, ppDecoder);
1207 }
#define TRUE
Definition: types.h:120
static HRESULT BmpDecoder_Create(int packed, int icoframe, BmpDecoder **ppDecoder)
Definition: bmpdecode.c:1153

Referenced by ReadIcoDib().

◆ impl_from_IWICBitmapDecoder()

static BmpDecoder* impl_from_IWICBitmapDecoder ( IWICBitmapDecoder iface)
inlinestatic

Definition at line 83 of file bmpdecode.c.

84 {
85  return CONTAINING_RECORD(iface, BmpDecoder, IWICBitmapDecoder_iface);
86 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by BmpDecoder_AddRef(), BmpDecoder_GetFrame(), BmpDecoder_Initialize(), BmpDecoder_QueryCapability(), BmpDecoder_QueryInterface(), and BmpDecoder_Release().

◆ impl_from_IWICBitmapFrameDecode()

static BmpDecoder* impl_from_IWICBitmapFrameDecode ( IWICBitmapFrameDecode iface)
inlinestatic

Definition at line 88 of file bmpdecode.c.

89 {
90  return CONTAINING_RECORD(iface, BmpDecoder, IWICBitmapFrameDecode_iface);
91 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by BmpFrameDecode_AddRef(), BmpFrameDecode_CopyPalette(), BmpFrameDecode_CopyPixels(), BmpFrameDecode_GetPixelFormat(), BmpFrameDecode_GetResolution(), BmpFrameDecode_GetSize(), BmpFrameDecode_QueryInterface(), and BmpFrameDecode_Release().

◆ ReadByte()

static HRESULT ReadByte ( IStream stream,
BYTE buffer,
ULONG  buffer_size,
ULONG cursor,
ULONG bytesread,
BYTE result 
)
static

Definition at line 441 of file bmpdecode.c.

443 {
444  HRESULT hr=S_OK;
445 
446  if (*bytesread == 0 || *cursor == *bytesread)
447  {
448  hr = IStream_Read(stream, buffer, buffer_size, bytesread);
449  *cursor = 0;
450  }
451 
452  if (SUCCEEDED(hr))
453  {
454  if (*cursor < *bytesread)
455  *result = buffer[(*cursor)++];
456  else
457  hr = E_FAIL;
458  }
459 
460  return hr;
461 }
HRESULT hr
Definition: shlfolder.c:183
GLuint buffer
Definition: glext.h:5915
#define E_FAIL
Definition: ddrawi.h:102
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:927
LONG HRESULT
Definition: typedefs.h:77
Definition: parse.h:22
#define S_OK
Definition: intsafe.h:59
const char cursor[]
Definition: icontest.c:13
GLuint64EXT * result
Definition: glext.h:11304
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by BmpFrameDecode_ReadRLE4(), and BmpFrameDecode_ReadRLE8().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wincodecs  )

Variable Documentation

◆ bitfields_formats

const struct bitfields_format bitfields_formats[]
static
Initial value:
= {
{16,0x7c00,0x3e0,0x1f,0,&GUID_WICPixelFormat16bppBGR555,BmpFrameDecode_ReadUncompressed},
{16,0xf800,0x7e0,0x1f,0,&GUID_WICPixelFormat16bppBGR565,BmpFrameDecode_ReadUncompressed},
{32,0xff0000,0xff00,0xff,0,&GUID_WICPixelFormat32bppBGR,BmpFrameDecode_ReadUncompressed},
{32,0xff0000,0xff00,0xff,0xff000000,&GUID_WICPixelFormat32bppBGRA,BmpFrameDecode_ReadUncompressed},
{32,0xff,0xff00,0xff0000,0,&GUID_WICPixelFormat32bppBGR,BmpFrameDecode_ReadRGB8},
{0}
}
static HRESULT BmpFrameDecode_ReadRGB8(BmpDecoder *This)
Definition: bmpdecode.c:420
static HRESULT BmpFrameDecode_ReadUncompressed(BmpDecoder *This)
Definition: bmpdecode.c:363

Definition at line 742 of file bmpdecode.c.

Referenced by BmpDecoder_ReadHeaders().

◆ BmpDecoder_FrameVtbl

const IWICBitmapFrameDecodeVtbl BmpDecoder_FrameVtbl
static
Initial value:
= {
}
static HRESULT WINAPI BmpFrameDecode_GetMetadataQueryReader(IWICBitmapFrameDecode *iface, IWICMetadataQueryReader **ppIMetadataQueryReader)
Definition: bmpdecode.c:342
static HRESULT WINAPI BmpFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface, WICPixelFormatGUID *pPixelFormat)
Definition: bmpdecode.c:152
static ULONG WINAPI BmpFrameDecode_AddRef(IWICBitmapFrameDecode *iface)
Definition: bmpdecode.c:118
static ULONG WINAPI BmpFrameDecode_Release(IWICBitmapFrameDecode *iface)
Definition: bmpdecode.c:125
static HRESULT WINAPI BmpFrameDecode_GetResolution(IWICBitmapFrameDecode *iface, double *pDpiX, double *pDpiY)
Definition: bmpdecode.c:196
static HRESULT WINAPI BmpFrameDecode_GetColorContexts(IWICBitmapFrameDecode *iface, UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
Definition: bmpdecode.c:349
static HRESULT WINAPI BmpFrameDecode_GetSize(IWICBitmapFrameDecode *iface, UINT *puiWidth, UINT *puiHeight)
Definition: bmpdecode.c:132
static HRESULT WINAPI BmpFrameDecode_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid, void **ppv)
Definition: bmpdecode.c:93
static HRESULT WINAPI BmpFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface, IWICPalette *pIPalette)
Definition: bmpdecode.c:205
static HRESULT WINAPI BmpFrameDecode_GetThumbnail(IWICBitmapFrameDecode *iface, IWICBitmapSource **ppIThumbnail)
Definition: bmpdecode.c:356
static HRESULT WINAPI BmpFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
Definition: bmpdecode.c:318

Definition at line 751 of file bmpdecode.c.

Referenced by BmpDecoder_Create().

◆ BmpDecoder_Vtbl

const IWICBitmapDecoderVtbl BmpDecoder_Vtbl
static
Initial value:
= {
}
static ULONG WINAPI BmpDecoder_Release(IWICBitmapDecoder *iface)
Definition: bmpdecode.c:1006
static HRESULT WINAPI BmpDecoder_GetDecoderInfo(IWICBitmapDecoder *iface, IWICBitmapDecoderInfo **ppIDecoderInfo)
Definition: bmpdecode.c:1068
static HRESULT WINAPI BmpDecoder_GetFrameCount(IWICBitmapDecoder *iface, UINT *pCount)
Definition: bmpdecode.c:1112
static HRESULT WINAPI BmpDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface, IWICMetadataQueryReader **ppIMetadataQueryReader)
Definition: bmpdecode.c:1084
static HRESULT WINAPI BmpDecoder_GetFrame(IWICBitmapDecoder *iface, UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
Definition: bmpdecode.c:1121
static HRESULT WINAPI BmpDecoder_GetThumbnail(IWICBitmapDecoder *iface, IWICBitmapSource **ppIThumbnail)
Definition: bmpdecode.c:1105
static HRESULT WINAPI BmpDecoder_GetColorContexts(IWICBitmapDecoder *iface, UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
Definition: bmpdecode.c:1098
static HRESULT WINAPI BmpDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream, WICDecodeOptions cacheOptions)
Definition: bmpdecode.c:1042
static HRESULT WINAPI BmpDecoder_CopyPalette(IWICBitmapDecoder *iface, IWICPalette *pIPalette)
Definition: bmpdecode.c:1076
static HRESULT WINAPI BmpDecoder_GetPreview(IWICBitmapDecoder *iface, IWICBitmapSource **ppIBitmapSource)
Definition: bmpdecode.c:1091
static HRESULT WINAPI BmpDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid, void **ppv)
Definition: bmpdecode.c:973
static HRESULT WINAPI BmpDecoder_GetContainerFormat(IWICBitmapDecoder *iface, GUID *pguidContainerFormat)
Definition: bmpdecode.c:1061
static ULONG WINAPI BmpDecoder_AddRef(IWICBitmapDecoder *iface)
Definition: bmpdecode.c:996
static HRESULT WINAPI BmpDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *stream, DWORD *capability)
Definition: bmpdecode.c:1025

Definition at line 1136 of file bmpdecode.c.

Referenced by BmpDecoder_Create().