ReactOS 0.4.16-dev-297-gc569aee
bmpencode.c File Reference
#include "config.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 bmpencode.c:

Go to the source code of this file.

Classes

struct  bmp_pixelformat
 
struct  BmpFrameEncode
 
struct  BmpEncoder
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct BmpFrameEncode BmpFrameEncode
 
typedef struct BmpEncoder BmpEncoder
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wincodecs)
 
static BmpFrameEncodeimpl_from_IWICBitmapFrameEncode (IWICBitmapFrameEncode *iface)
 
static HRESULT WINAPI BmpFrameEncode_QueryInterface (IWICBitmapFrameEncode *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI BmpFrameEncode_AddRef (IWICBitmapFrameEncode *iface)
 
static ULONG WINAPI BmpFrameEncode_Release (IWICBitmapFrameEncode *iface)
 
static HRESULT WINAPI BmpFrameEncode_Initialize (IWICBitmapFrameEncode *iface, IPropertyBag2 *pIEncoderOptions)
 
static HRESULT WINAPI BmpFrameEncode_SetSize (IWICBitmapFrameEncode *iface, UINT uiWidth, UINT uiHeight)
 
static HRESULT WINAPI BmpFrameEncode_SetResolution (IWICBitmapFrameEncode *iface, double dpiX, double dpiY)
 
static HRESULT WINAPI BmpFrameEncode_SetPixelFormat (IWICBitmapFrameEncode *iface, WICPixelFormatGUID *pPixelFormat)
 
static HRESULT WINAPI BmpFrameEncode_SetColorContexts (IWICBitmapFrameEncode *iface, UINT cCount, IWICColorContext **ppIColorContext)
 
static HRESULT WINAPI BmpFrameEncode_SetPalette (IWICBitmapFrameEncode *iface, IWICPalette *palette)
 
static HRESULT WINAPI BmpFrameEncode_SetThumbnail (IWICBitmapFrameEncode *iface, IWICBitmapSource *pIThumbnail)
 
static HRESULT BmpFrameEncode_AllocateBits (BmpFrameEncode *This)
 
static HRESULT WINAPI BmpFrameEncode_WritePixels (IWICBitmapFrameEncode *iface, UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE *pbPixels)
 
static HRESULT WINAPI BmpFrameEncode_WriteSource (IWICBitmapFrameEncode *iface, IWICBitmapSource *pIBitmapSource, WICRect *prc)
 
static HRESULT WINAPI BmpFrameEncode_Commit (IWICBitmapFrameEncode *iface)
 
static HRESULT WINAPI BmpFrameEncode_GetMetadataQueryWriter (IWICBitmapFrameEncode *iface, IWICMetadataQueryWriter **ppIMetadataQueryWriter)
 
static BmpEncoderimpl_from_IWICBitmapEncoder (IWICBitmapEncoder *iface)
 
static HRESULT WINAPI BmpEncoder_QueryInterface (IWICBitmapEncoder *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI BmpEncoder_AddRef (IWICBitmapEncoder *iface)
 
static ULONG WINAPI BmpEncoder_Release (IWICBitmapEncoder *iface)
 
static HRESULT WINAPI BmpEncoder_Initialize (IWICBitmapEncoder *iface, IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
 
static HRESULT WINAPI BmpEncoder_GetContainerFormat (IWICBitmapEncoder *iface, GUID *pguidContainerFormat)
 
static HRESULT WINAPI BmpEncoder_GetEncoderInfo (IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info)
 
static HRESULT WINAPI BmpEncoder_SetColorContexts (IWICBitmapEncoder *iface, UINT cCount, IWICColorContext **ppIColorContext)
 
static HRESULT WINAPI BmpEncoder_SetPalette (IWICBitmapEncoder *iface, IWICPalette *palette)
 
static HRESULT WINAPI BmpEncoder_SetThumbnail (IWICBitmapEncoder *iface, IWICBitmapSource *pIThumbnail)
 
static HRESULT WINAPI BmpEncoder_SetPreview (IWICBitmapEncoder *iface, IWICBitmapSource *pIPreview)
 
static HRESULT WINAPI BmpEncoder_CreateNewFrame (IWICBitmapEncoder *iface, IWICBitmapFrameEncode **ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions)
 
static HRESULT WINAPI BmpEncoder_Commit (IWICBitmapEncoder *iface)
 
static HRESULT WINAPI BmpEncoder_GetMetadataQueryWriter (IWICBitmapEncoder *iface, IWICMetadataQueryWriter **ppIMetadataQueryWriter)
 
HRESULT BmpEncoder_CreateInstance (REFIID iid, void **ppv)
 

Variables

static const struct bmp_pixelformat formats []
 
static const WCHAR wszEnableV5Header32bppBGRA [] = {'E','n','a','b','l','e','V','5','H','e','a','d','e','r','3','2','b','p','p','B','G','R','A',0}
 
static const IWICBitmapFrameEncodeVtbl BmpFrameEncode_Vtbl
 
static const IWICBitmapEncoderVtbl BmpEncoder_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file bmpencode.c.

Typedef Documentation

◆ BmpEncoder

◆ BmpFrameEncode

Function Documentation

◆ BmpEncoder_AddRef()

static ULONG WINAPI BmpEncoder_AddRef ( IWICBitmapEncoder iface)
static

Definition at line 461 of file bmpencode.c.

462{
465
466 TRACE("(%p) refcount=%u\n", iface, ref);
467
468 return ref;
469}
#define InterlockedIncrement
Definition: armddk.h:53
static BmpEncoder * impl_from_IWICBitmapEncoder(IWICBitmapEncoder *iface)
Definition: bmpencode.c:433
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ BmpEncoder_Commit()

static HRESULT WINAPI BmpEncoder_Commit ( IWICBitmapEncoder iface)
static

Definition at line 609 of file bmpencode.c.

610{
612 TRACE("(%p)\n", iface);
613
614 if (!This->frame || !This->frame->committed) return WINCODEC_ERR_WRONGSTATE;
615
616 return S_OK;
617}
#define S_OK
Definition: intsafe.h:52
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3281

◆ BmpEncoder_CreateInstance()

HRESULT BmpEncoder_CreateInstance ( REFIID  iid,
void **  ppv 
)

Definition at line 642 of file bmpencode.c.

643{
645 HRESULT ret;
646
647 TRACE("(%s,%p)\n", debugstr_guid(iid), ppv);
648
649 *ppv = NULL;
650
651 This = HeapAlloc(GetProcessHeap(), 0, sizeof(BmpEncoder));
652 if (!This) return E_OUTOFMEMORY;
653
654 This->IWICBitmapEncoder_iface.lpVtbl = &BmpEncoder_Vtbl;
655 This->ref = 1;
656 This->stream = NULL;
657 This->frame = NULL;
658
659 ret = IWICBitmapEncoder_QueryInterface(&This->IWICBitmapEncoder_iface, iid, ppv);
660 IWICBitmapEncoder_Release(&This->IWICBitmapEncoder_iface);
661
662 return ret;
663}
static const IWICBitmapEncoderVtbl BmpEncoder_Vtbl
Definition: bmpencode.c:626
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
int ret

◆ BmpEncoder_CreateNewFrame()

static HRESULT WINAPI BmpEncoder_CreateNewFrame ( IWICBitmapEncoder iface,
IWICBitmapFrameEncode **  ppIFrameEncode,
IPropertyBag2 **  ppIEncoderOptions 
)
static

Definition at line 558 of file bmpencode.c.

560{
562 BmpFrameEncode *encode;
563 HRESULT hr;
564 static const PROPBAG2 opts[1] =
565 {
566 { PROPBAG2_TYPE_DATA, VT_BOOL, 0, 0, (LPOLESTR)wszEnableV5Header32bppBGRA },
567 };
568
569 TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions);
570
571 if (This->frame) return WINCODEC_ERR_UNSUPPORTEDOPERATION;
572
573 if (!This->stream) return WINCODEC_ERR_NOTINITIALIZED;
574
575 if (ppIEncoderOptions)
576 {
577 hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions);
578 if (FAILED(hr)) return hr;
579 }
580
581 encode = HeapAlloc(GetProcessHeap(), 0, sizeof(BmpFrameEncode));
582 if (!encode)
583 {
584 IPropertyBag2_Release(*ppIEncoderOptions);
585 *ppIEncoderOptions = NULL;
586 return E_OUTOFMEMORY;
587 }
589 encode->ref = 2;
590 IStream_AddRef(This->stream);
591 encode->stream = This->stream;
592 encode->initialized = FALSE;
593 encode->width = 0;
594 encode->height = 0;
595 encode->bits = NULL;
596 encode->format = NULL;
597 encode->xres = 0.0;
598 encode->yres = 0.0;
599 encode->lineswritten = 0;
600 encode->colors = 0;
601 encode->committed = FALSE;
602
603 *ppIFrameEncode = &encode->IWICBitmapFrameEncode_iface;
604 This->frame = encode;
605
606 return S_OK;
607}
#define ARRAY_SIZE(A)
Definition: main.h:20
static const WCHAR wszEnableV5Header32bppBGRA[]
Definition: bmpencode.c:82
static const IWICBitmapFrameEncodeVtbl BmpFrameEncode_Vtbl
Definition: bmpencode.c:409
#define FALSE
Definition: types.h:117
@ VT_BOOL
Definition: compat.h:2306
HRESULT CreatePropertyBag2(const PROPBAG2 *options, UINT count, IPropertyBag2 **ppPropertyBag2)
Definition: propertybag.c:281
#define FAILED(hr)
Definition: intsafe.h:51
static LPOLESTR
Definition: stg_prop.c:27
HRESULT hr
Definition: shlfolder.c:183
UINT lineswritten
Definition: bmpencode.c:75
BOOL committed
Definition: bmpencode.c:79
BOOL initialized
Definition: bmpencode.c:70
const struct bmp_pixelformat * format
Definition: bmpencode.c:73
double yres
Definition: bmpencode.c:74
BYTE * bits
Definition: bmpencode.c:72
IStream * stream
Definition: bmpencode.c:69
IWICBitmapFrameEncode IWICBitmapFrameEncode_iface
Definition: bmpencode.c:67
double xres
Definition: bmpencode.c:74
#define WINCODEC_ERR_UNSUPPORTEDOPERATION
Definition: winerror.h:3308
#define WINCODEC_ERR_NOTINITIALIZED
Definition: winerror.h:3285

◆ BmpEncoder_GetContainerFormat()

static HRESULT WINAPI BmpEncoder_GetContainerFormat ( IWICBitmapEncoder iface,
GUID pguidContainerFormat 
)
static

Definition at line 501 of file bmpencode.c.

503{
504 TRACE("(%p,%p)\n", iface, pguidContainerFormat);
505
506 if (!pguidContainerFormat)
507 return E_INVALIDARG;
508
509 memcpy(pguidContainerFormat, &GUID_ContainerFormatBmp, sizeof(GUID));
510 return S_OK;
511}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

◆ BmpEncoder_GetEncoderInfo()

static HRESULT WINAPI BmpEncoder_GetEncoderInfo ( IWICBitmapEncoder iface,
IWICBitmapEncoderInfo **  info 
)
static

Definition at line 513 of file bmpencode.c.

514{
515 IWICComponentInfo *comp_info;
516 HRESULT hr;
517
518 TRACE("%p,%p\n", iface, info);
519
520 if (!info) return E_INVALIDARG;
521
522 hr = CreateComponentInfo(&CLSID_WICBmpEncoder, &comp_info);
523 if (hr == S_OK)
524 {
525 hr = IWICComponentInfo_QueryInterface(comp_info, &IID_IWICBitmapEncoderInfo, (void **)info);
526 IWICComponentInfo_Release(comp_info);
527 }
528 return hr;
529}
HRESULT CreateComponentInfo(REFCLSID clsid, IWICComponentInfo **ppIInfo)
Definition: info.c:2075

◆ BmpEncoder_GetMetadataQueryWriter()

static HRESULT WINAPI BmpEncoder_GetMetadataQueryWriter ( IWICBitmapEncoder iface,
IWICMetadataQueryWriter **  ppIMetadataQueryWriter 
)
static

Definition at line 619 of file bmpencode.c.

621{
622 FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryWriter);
623 return E_NOTIMPL;
624}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ BmpEncoder_Initialize()

static HRESULT WINAPI BmpEncoder_Initialize ( IWICBitmapEncoder iface,
IStream pIStream,
WICBitmapEncoderCacheOption  cacheOption 
)
static

Definition at line 488 of file bmpencode.c.

490{
492
493 TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption);
494
495 IStream_AddRef(pIStream);
496 This->stream = pIStream;
497
498 return S_OK;
499}

◆ BmpEncoder_QueryInterface()

static HRESULT WINAPI BmpEncoder_QueryInterface ( IWICBitmapEncoder iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 438 of file bmpencode.c.

440{
442 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
443
444 if (!ppv) return E_INVALIDARG;
445
446 if (IsEqualIID(&IID_IUnknown, iid) ||
447 IsEqualIID(&IID_IWICBitmapEncoder, iid))
448 {
449 *ppv = &This->IWICBitmapEncoder_iface;
450 }
451 else
452 {
453 *ppv = NULL;
454 return E_NOINTERFACE;
455 }
456
457 IUnknown_AddRef((IUnknown*)*ppv);
458 return S_OK;
459}
const GUID IID_IUnknown
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ BmpEncoder_Release()

static ULONG WINAPI BmpEncoder_Release ( IWICBitmapEncoder iface)
static

Definition at line 471 of file bmpencode.c.

472{
475
476 TRACE("(%p) refcount=%u\n", iface, ref);
477
478 if (ref == 0)
479 {
480 if (This->stream) IStream_Release(This->stream);
481 if (This->frame) IWICBitmapFrameEncode_Release(&This->frame->IWICBitmapFrameEncode_iface);
483 }
484
485 return ref;
486}
#define InterlockedDecrement
Definition: armddk.h:52
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ BmpEncoder_SetColorContexts()

static HRESULT WINAPI BmpEncoder_SetColorContexts ( IWICBitmapEncoder iface,
UINT  cCount,
IWICColorContext **  ppIColorContext 
)
static

Definition at line 531 of file bmpencode.c.

533{
534 FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
535 return E_NOTIMPL;
536}

◆ BmpEncoder_SetPalette()

static HRESULT WINAPI BmpEncoder_SetPalette ( IWICBitmapEncoder iface,
IWICPalette palette 
)
static

Definition at line 538 of file bmpencode.c.

539{
541
542 TRACE("(%p,%p)\n", iface, palette);
544}
static HPALETTE palette
Definition: clipboard.c:1345

◆ BmpEncoder_SetPreview()

static HRESULT WINAPI BmpEncoder_SetPreview ( IWICBitmapEncoder iface,
IWICBitmapSource pIPreview 
)
static

Definition at line 552 of file bmpencode.c.

553{
554 TRACE("(%p,%p)\n", iface, pIPreview);
556}

◆ BmpEncoder_SetThumbnail()

static HRESULT WINAPI BmpEncoder_SetThumbnail ( IWICBitmapEncoder iface,
IWICBitmapSource pIThumbnail 
)
static

Definition at line 546 of file bmpencode.c.

547{
548 TRACE("(%p,%p)\n", iface, pIThumbnail);
550}

◆ BmpFrameEncode_AddRef()

static ULONG WINAPI BmpFrameEncode_AddRef ( IWICBitmapFrameEncode iface)
static

Definition at line 112 of file bmpencode.c.

113{
116
117 TRACE("(%p) refcount=%u\n", iface, ref);
118
119 return ref;
120}
static BmpFrameEncode * impl_from_IWICBitmapFrameEncode(IWICBitmapFrameEncode *iface)
Definition: bmpencode.c:84

◆ BmpFrameEncode_AllocateBits()

static HRESULT BmpFrameEncode_AllocateBits ( BmpFrameEncode This)
static

Definition at line 248 of file bmpencode.c.

249{
250 if (!This->bits)
251 {
252 if (!This->initialized || !This->width || !This->height || !This->format)
254
255 This->stride = (((This->width * This->format->bpp)+31)/32)*4;
256 This->bits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->stride * This->height);
257 if (!This->bits) return E_OUTOFMEMORY;
258 }
259
260 return S_OK;
261}
#define HEAP_ZERO_MEMORY
Definition: compat.h:134

Referenced by BmpFrameEncode_WritePixels().

◆ BmpFrameEncode_Commit()

static HRESULT WINAPI BmpFrameEncode_Commit ( IWICBitmapFrameEncode iface)
static

Definition at line 325 of file bmpencode.c.

326{
329 BITMAPV5HEADER bih;
330 UINT info_size;
332 ULONG byteswritten;
333 HRESULT hr;
334
335 TRACE("(%p)\n", iface);
336
337 if (!This->bits || This->committed || This->height != This->lineswritten)
339
340 bfh.bfType = 0x4d42; /* "BM" */
341 bfh.bfReserved1 = 0;
342 bfh.bfReserved2 = 0;
343
344 bih.bV5Size = info_size = sizeof(BITMAPINFOHEADER);
345 bih.bV5Width = This->width;
346 bih.bV5Height = This->height;
347 bih.bV5Planes = 1;
348 bih.bV5BitCount = This->format->bpp;
349 bih.bV5Compression = This->format->compression;
350 bih.bV5SizeImage = This->stride*This->height;
351 bih.bV5XPelsPerMeter = (This->xres+0.0127) / 0.0254;
352 bih.bV5YPelsPerMeter = (This->yres+0.0127) / 0.0254;
353 bih.bV5ClrUsed = (This->format->bpp <= 8) ? This->colors : 0;
354 bih.bV5ClrImportant = bih.bV5ClrUsed;
355
356 if (This->format->compression == BI_BITFIELDS)
357 {
358 if (This->format->alphamask)
359 bih.bV5Size = info_size = sizeof(BITMAPV4HEADER);
360 else
361 info_size = sizeof(BITMAPINFOHEADER)+12;
362 bih.bV5RedMask = This->format->redmask;
363 bih.bV5GreenMask = This->format->greenmask;
364 bih.bV5BlueMask = This->format->bluemask;
365 bih.bV5AlphaMask = This->format->alphamask;
366 bih.bV5CSType = LCS_DEVICE_RGB;
367 }
368
369 bfh.bfSize = sizeof(BITMAPFILEHEADER) + info_size + bih.bV5SizeImage;
370 bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + info_size;
371 bfh.bfOffBits += bih.bV5ClrUsed * sizeof(WICColor);
372
373 pos.QuadPart = 0;
374 hr = IStream_Seek(This->stream, pos, STREAM_SEEK_SET, NULL);
375 if (FAILED(hr)) return hr;
376
377 hr = IStream_Write(This->stream, &bfh, sizeof(BITMAPFILEHEADER), &byteswritten);
378 if (FAILED(hr)) return hr;
379 if (byteswritten != sizeof(BITMAPFILEHEADER)) return E_FAIL;
380
381 hr = IStream_Write(This->stream, &bih, info_size, &byteswritten);
382 if (FAILED(hr)) return hr;
383 if (byteswritten != info_size) return E_FAIL;
384
385 /* write the palette */
386 if (This->format->colors)
387 {
388 hr = IStream_Write(This->stream, This->palette, This->colors * sizeof(WICColor), &byteswritten);
389 if (FAILED(hr)) return hr;
390 if (byteswritten != This->colors * sizeof(WICColor)) return E_FAIL;
391 }
392
393 hr = IStream_Write(This->stream, This->bits, bih.bV5SizeImage, &byteswritten);
394 if (FAILED(hr)) return hr;
395 if (byteswritten != bih.bV5SizeImage) return E_FAIL;
396
397 This->committed = TRUE;
398
399 return S_OK;
400}
#define E_FAIL
Definition: ddrawi.h:102
#define TRUE
Definition: types.h:120
if(dx< 0)
Definition: linetemp.h:194
#define BI_BITFIELDS
Definition: mmreg.h:507
unsigned int UINT
Definition: ndis.h:50
UINT32 WICColor
Definition: wincodec.idl:312
struct tagBITMAPFILEHEADER BITMAPFILEHEADER
#define LCS_DEVICE_RGB
Definition: wingdi.h:1098

◆ BmpFrameEncode_GetMetadataQueryWriter()

static HRESULT WINAPI BmpFrameEncode_GetMetadataQueryWriter ( IWICBitmapFrameEncode iface,
IWICMetadataQueryWriter **  ppIMetadataQueryWriter 
)
static

Definition at line 402 of file bmpencode.c.

404{
405 FIXME("(%p, %p): stub\n", iface, ppIMetadataQueryWriter);
406 return E_NOTIMPL;
407}

◆ BmpFrameEncode_Initialize()

static HRESULT WINAPI BmpFrameEncode_Initialize ( IWICBitmapFrameEncode iface,
IPropertyBag2 pIEncoderOptions 
)
static

Definition at line 139 of file bmpencode.c.

141{
143 TRACE("(%p,%p)\n", iface, pIEncoderOptions);
144
145 if (This->initialized) return WINCODEC_ERR_WRONGSTATE;
146
147 if (pIEncoderOptions)
148 WARN("ignoring encoder options.\n");
149
150 This->initialized = TRUE;
151
152 return S_OK;
153}
#define WARN(fmt,...)
Definition: precomp.h:61

◆ BmpFrameEncode_QueryInterface()

static HRESULT WINAPI BmpFrameEncode_QueryInterface ( IWICBitmapFrameEncode iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 89 of file bmpencode.c.

91{
93 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
94
95 if (!ppv) return E_INVALIDARG;
96
97 if (IsEqualIID(&IID_IUnknown, iid) ||
98 IsEqualIID(&IID_IWICBitmapFrameEncode, iid))
99 {
100 *ppv = &This->IWICBitmapFrameEncode_iface;
101 }
102 else
103 {
104 *ppv = NULL;
105 return E_NOINTERFACE;
106 }
107
108 IUnknown_AddRef((IUnknown*)*ppv);
109 return S_OK;
110}

◆ BmpFrameEncode_Release()

static ULONG WINAPI BmpFrameEncode_Release ( IWICBitmapFrameEncode iface)
static

Definition at line 122 of file bmpencode.c.

123{
126
127 TRACE("(%p) refcount=%u\n", iface, ref);
128
129 if (ref == 0)
130 {
131 if (This->stream) IStream_Release(This->stream);
132 HeapFree(GetProcessHeap(), 0, This->bits);
134 }
135
136 return ref;
137}

◆ BmpFrameEncode_SetColorContexts()

static HRESULT WINAPI BmpFrameEncode_SetColorContexts ( IWICBitmapFrameEncode iface,
UINT  cCount,
IWICColorContext **  ppIColorContext 
)
static

Definition at line 211 of file bmpencode.c.

213{
214 FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
215 return E_NOTIMPL;
216}

◆ BmpFrameEncode_SetPalette()

static HRESULT WINAPI BmpFrameEncode_SetPalette ( IWICBitmapFrameEncode iface,
IWICPalette palette 
)
static

Definition at line 218 of file bmpencode.c.

220{
222 HRESULT hr;
223
224 TRACE("(%p,%p)\n", iface, palette);
225
226 if (!palette) return E_INVALIDARG;
227
228 if (!This->initialized)
230
231 hr = IWICPalette_GetColors(palette, 256, This->palette, &This->colors);
232 if (hr == S_OK)
233 {
234 UINT i;
235 for (i = 0; i < This->colors; i++)
236 This->palette[i] |= 0xff000000; /* BMP palette has no alpha */
237 }
238 return hr;
239}
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

◆ BmpFrameEncode_SetPixelFormat()

static HRESULT WINAPI BmpFrameEncode_SetPixelFormat ( IWICBitmapFrameEncode iface,
WICPixelFormatGUID pPixelFormat 
)
static

Definition at line 183 of file bmpencode.c.

185{
187 int i;
188 TRACE("(%p,%s)\n", iface, debugstr_guid(pPixelFormat));
189
190 if (!This->initialized || This->bits) return WINCODEC_ERR_WRONGSTATE;
191
192 if (IsEqualGUID(pPixelFormat, &GUID_WICPixelFormatBlackWhite))
193 *pPixelFormat = GUID_WICPixelFormat1bppIndexed;
194 else if (IsEqualGUID(pPixelFormat, &GUID_WICPixelFormat2bppIndexed))
195 *pPixelFormat = GUID_WICPixelFormat4bppIndexed;
196
197 for (i=0; formats[i].guid; i++)
198 {
199 if (IsEqualGUID(formats[i].guid, pPixelFormat))
200 break;
201 }
202
203 if (!formats[i].guid) i = 0;
204
205 This->format = &formats[i];
206 memcpy(pPixelFormat, This->format->guid, sizeof(GUID));
207
208 return S_OK;
209}
static const struct bmp_pixelformat formats[]
Definition: bmpencode.c:49
const GUID * guid
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

◆ BmpFrameEncode_SetResolution()

static HRESULT WINAPI BmpFrameEncode_SetResolution ( IWICBitmapFrameEncode iface,
double  dpiX,
double  dpiY 
)
static

Definition at line 169 of file bmpencode.c.

171{
173 TRACE("(%p,%0.2f,%0.2f)\n", iface, dpiX, dpiY);
174
175 if (!This->initialized || This->bits) return WINCODEC_ERR_WRONGSTATE;
176
177 This->xres = dpiX;
178 This->yres = dpiY;
179
180 return S_OK;
181}

◆ BmpFrameEncode_SetSize()

static HRESULT WINAPI BmpFrameEncode_SetSize ( IWICBitmapFrameEncode iface,
UINT  uiWidth,
UINT  uiHeight 
)
static

Definition at line 155 of file bmpencode.c.

157{
159 TRACE("(%p,%u,%u)\n", iface, uiWidth, uiHeight);
160
161 if (!This->initialized || This->bits) return WINCODEC_ERR_WRONGSTATE;
162
163 This->width = uiWidth;
164 This->height = uiHeight;
165
166 return S_OK;
167}

◆ BmpFrameEncode_SetThumbnail()

static HRESULT WINAPI BmpFrameEncode_SetThumbnail ( IWICBitmapFrameEncode iface,
IWICBitmapSource pIThumbnail 
)
static

Definition at line 241 of file bmpencode.c.

243{
244 FIXME("(%p,%p): stub\n", iface, pIThumbnail);
246}

◆ BmpFrameEncode_WritePixels()

static HRESULT WINAPI BmpFrameEncode_WritePixels ( IWICBitmapFrameEncode iface,
UINT  lineCount,
UINT  cbStride,
UINT  cbBufferSize,
BYTE pbPixels 
)
static

Definition at line 263 of file bmpencode.c.

265{
267 UINT dstbuffersize, bytesperrow, row;
268 BYTE *dst, *src;
269 HRESULT hr;
270
271 TRACE("(%p,%u,%u,%u,%p)\n", iface, lineCount, cbStride, cbBufferSize, pbPixels);
272
273 if (!This->initialized || !This->width || !This->height || !This->format)
275
277 if (FAILED(hr)) return hr;
278
279 bytesperrow = ((This->format->bpp * This->width) + 7) / 8;
280
281 if (This->stride < bytesperrow)
282 return E_INVALIDARG;
283
284 dstbuffersize = This->stride * (This->height - This->lineswritten);
285 if ((This->stride * (lineCount - 1)) + bytesperrow > dstbuffersize)
286 return E_INVALIDARG;
287
288 src = pbPixels;
289 dst = This->bits + This->stride * (This->height - This->lineswritten - 1);
290 for (row = 0; row < lineCount; row++)
291 {
292 memcpy(dst, src, bytesperrow);
293 src += cbStride;
294 dst -= This->stride;
295 }
296
297 This->lineswritten += lineCount;
298
299 return S_OK;
300}
static HRESULT BmpFrameEncode_AllocateBits(BmpFrameEncode *This)
Definition: bmpencode.c:248
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
unsigned char BYTE
Definition: xxhash.c:193

◆ BmpFrameEncode_WriteSource()

static HRESULT WINAPI BmpFrameEncode_WriteSource ( IWICBitmapFrameEncode iface,
IWICBitmapSource pIBitmapSource,
WICRect prc 
)
static

Definition at line 302 of file bmpencode.c.

304{
306 HRESULT hr;
307 TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
308
309 if (!This->initialized)
311
312 hr = configure_write_source(iface, pIBitmapSource, prc,
313 This->format ? This->format->guid : NULL, This->width, This->height,
314 This->xres, This->yres);
315
316 if (SUCCEEDED(hr))
317 {
318 hr = write_source(iface, pIBitmapSource, prc,
319 This->format->guid, This->format->bpp, This->width, This->height);
320 }
321
322 return hr;
323}
HRESULT write_source(IWICBitmapFrameEncode *iface, IWICBitmapSource *source, const WICRect *prc, const WICPixelFormatGUID *format, UINT bpp, INT width, INT height)
Definition: main.c:155
HRESULT configure_write_source(IWICBitmapFrameEncode *iface, IWICBitmapSource *source, const WICRect *prc, const WICPixelFormatGUID *format, INT width, INT height, double xres, double yres)
Definition: main.c:123
#define SUCCEEDED(hr)
Definition: intsafe.h:50
_Out_ LPRECT prc
Definition: ntgdi.h:1658
static const char * debug_wic_rect(const WICRect *rect)

◆ impl_from_IWICBitmapEncoder()

static BmpEncoder * impl_from_IWICBitmapEncoder ( IWICBitmapEncoder iface)
inlinestatic

Definition at line 433 of file bmpencode.c.

434{
435 return CONTAINING_RECORD(iface, BmpEncoder, IWICBitmapEncoder_iface);
436}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by BmpEncoder_AddRef(), BmpEncoder_Commit(), BmpEncoder_CreateNewFrame(), BmpEncoder_Initialize(), BmpEncoder_QueryInterface(), BmpEncoder_Release(), and BmpEncoder_SetPalette().

◆ impl_from_IWICBitmapFrameEncode()

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wincodecs  )

Variable Documentation

◆ BmpEncoder_Vtbl

const IWICBitmapEncoderVtbl BmpEncoder_Vtbl
static
Initial value:
= {
}
static HRESULT WINAPI BmpEncoder_GetEncoderInfo(IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info)
Definition: bmpencode.c:513
static ULONG WINAPI BmpEncoder_Release(IWICBitmapEncoder *iface)
Definition: bmpencode.c:471
static HRESULT WINAPI BmpEncoder_CreateNewFrame(IWICBitmapEncoder *iface, IWICBitmapFrameEncode **ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions)
Definition: bmpencode.c:558
static HRESULT WINAPI BmpEncoder_SetThumbnail(IWICBitmapEncoder *iface, IWICBitmapSource *pIThumbnail)
Definition: bmpencode.c:546
static HRESULT WINAPI BmpEncoder_Initialize(IWICBitmapEncoder *iface, IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
Definition: bmpencode.c:488
static HRESULT WINAPI BmpEncoder_SetColorContexts(IWICBitmapEncoder *iface, UINT cCount, IWICColorContext **ppIColorContext)
Definition: bmpencode.c:531
static HRESULT WINAPI BmpEncoder_SetPreview(IWICBitmapEncoder *iface, IWICBitmapSource *pIPreview)
Definition: bmpencode.c:552
static HRESULT WINAPI BmpEncoder_Commit(IWICBitmapEncoder *iface)
Definition: bmpencode.c:609
static HRESULT WINAPI BmpEncoder_GetMetadataQueryWriter(IWICBitmapEncoder *iface, IWICMetadataQueryWriter **ppIMetadataQueryWriter)
Definition: bmpencode.c:619
static ULONG WINAPI BmpEncoder_AddRef(IWICBitmapEncoder *iface)
Definition: bmpencode.c:461
static HRESULT WINAPI BmpEncoder_SetPalette(IWICBitmapEncoder *iface, IWICPalette *palette)
Definition: bmpencode.c:538
static HRESULT WINAPI BmpEncoder_GetContainerFormat(IWICBitmapEncoder *iface, GUID *pguidContainerFormat)
Definition: bmpencode.c:501
static HRESULT WINAPI BmpEncoder_QueryInterface(IWICBitmapEncoder *iface, REFIID iid, void **ppv)
Definition: bmpencode.c:438

Definition at line 626 of file bmpencode.c.

Referenced by BmpEncoder_CreateInstance().

◆ BmpFrameEncode_Vtbl

const IWICBitmapFrameEncodeVtbl BmpFrameEncode_Vtbl
static
Initial value:
= {
}
static HRESULT WINAPI BmpFrameEncode_WritePixels(IWICBitmapFrameEncode *iface, UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE *pbPixels)
Definition: bmpencode.c:263
static HRESULT WINAPI BmpFrameEncode_SetThumbnail(IWICBitmapFrameEncode *iface, IWICBitmapSource *pIThumbnail)
Definition: bmpencode.c:241
static ULONG WINAPI BmpFrameEncode_AddRef(IWICBitmapFrameEncode *iface)
Definition: bmpencode.c:112
static ULONG WINAPI BmpFrameEncode_Release(IWICBitmapFrameEncode *iface)
Definition: bmpencode.c:122
static HRESULT WINAPI BmpFrameEncode_SetPalette(IWICBitmapFrameEncode *iface, IWICPalette *palette)
Definition: bmpencode.c:218
static HRESULT WINAPI BmpFrameEncode_SetSize(IWICBitmapFrameEncode *iface, UINT uiWidth, UINT uiHeight)
Definition: bmpencode.c:155
static HRESULT WINAPI BmpFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface, WICPixelFormatGUID *pPixelFormat)
Definition: bmpencode.c:183
static HRESULT WINAPI BmpFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, IWICBitmapSource *pIBitmapSource, WICRect *prc)
Definition: bmpencode.c:302
static HRESULT WINAPI BmpFrameEncode_SetResolution(IWICBitmapFrameEncode *iface, double dpiX, double dpiY)
Definition: bmpencode.c:169
static HRESULT WINAPI BmpFrameEncode_SetColorContexts(IWICBitmapFrameEncode *iface, UINT cCount, IWICColorContext **ppIColorContext)
Definition: bmpencode.c:211
static HRESULT WINAPI BmpFrameEncode_Initialize(IWICBitmapFrameEncode *iface, IPropertyBag2 *pIEncoderOptions)
Definition: bmpencode.c:139
static HRESULT WINAPI BmpFrameEncode_GetMetadataQueryWriter(IWICBitmapFrameEncode *iface, IWICMetadataQueryWriter **ppIMetadataQueryWriter)
Definition: bmpencode.c:402
static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
Definition: bmpencode.c:325
static HRESULT WINAPI BmpFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface, REFIID iid, void **ppv)
Definition: bmpencode.c:89

Definition at line 409 of file bmpencode.c.

Referenced by BmpEncoder_CreateNewFrame().

◆ formats

const struct bmp_pixelformat formats[]
static
Initial value:
= {
{&GUID_WICPixelFormat24bppBGR, 24, 0, BI_RGB},
{&GUID_WICPixelFormatBlackWhite, 1, 2, BI_RGB},
{&GUID_WICPixelFormat1bppIndexed, 1, 2, BI_RGB},
{&GUID_WICPixelFormat2bppIndexed, 2, 4, BI_RGB},
{&GUID_WICPixelFormat4bppIndexed, 4, 16, BI_RGB},
{&GUID_WICPixelFormat8bppIndexed, 8, 256, BI_RGB},
{&GUID_WICPixelFormat16bppBGR555, 16, 0, BI_RGB},
{&GUID_WICPixelFormat16bppBGR565, 16, 0, BI_BITFIELDS, 0xf800, 0x7e0, 0x1f, 0},
{&GUID_WICPixelFormat32bppBGR, 32, 0, BI_RGB},
{NULL}
}
#define BI_RGB
Definition: precomp.h:56

Definition at line 49 of file bmpencode.c.

Referenced by BmpFrameEncode_SetPixelFormat().

◆ wszEnableV5Header32bppBGRA

const WCHAR wszEnableV5Header32bppBGRA[] = {'E','n','a','b','l','e','V','5','H','e','a','d','e','r','3','2','b','p','p','B','G','R','A',0}
static

Definition at line 82 of file bmpencode.c.

Referenced by BmpEncoder_CreateNewFrame().