Skip to content

SysWin WIC Interfaces

Paul Squires edited this page Oct 31, 2026 · 1 revision

Home › All Categories › sys/win › sys/win/direct2d › WIC interfaces and types

WIC interfaces and types

Lists the WIC interfaces, enumerations and structures of sys/win/direct2d.

The Windows Imaging Component (WIC) reads and writes image files (BMP, PNG, JPEG, GIF, TIFF, ICO, HEIF, WebP and camera RAW among them), converts between pixel formats, scales, crops and rotates images, and reads their metadata. Direct2D draws what WIC decodes: CID2D1RenderTarget.CreateBitmapFromWicBitmap turns an IWICBitmapSource into a Direct2D bitmap, and CD2D1Factory.CreateWicBitmapRenderTarget makes a render target that draws into an IWICBitmap. No class wraps WIC itself: a program works with the interfaces.

Where the objects come from. The imaging factory is a COM class. After CoInitialize, CoCreateInstance with CLSID_WICImagingFactory and IID_IWICImagingFactory gives an IWICImagingFactory ptr, and every other object comes from it: decoders from a file name, a stream or a handle, encoders for a container format, streams, bitmaps, format converters, scalers, clippers, flip-rotators, palettes and colour contexts.

Calling a method. Each interface IWICX is a name for the type IWICX_, which declares the methods and extends its parent, so p->Method( ... ) calls one, and a decoded frame (IWICBitmapFrameDecode) is also an IWICBitmapSource. A parameter that receives an object is byref ... ptr: pass the pointer variable. An optional byref GUID or rectangle can be left out by passing *cast( GUID ptr, NULL ) or *cast( WICRect ptr, NULL ). Every pointer handed out holds one reference: call Release when done.

Identifiers. All are GUID variables:

  • IID_IWICImagingFactory, IID_IWICBitmap … one per interface;
  • CLSID_WICImagingFactory, CLSID_WICImagingFactory2 and the codec classes (CLSID_WICPngDecoder, CLSID_WICJpegEncoder …);
  • container formats GUID_ContainerFormatBmp, …Png, …Ico, …Jpeg, …Tiff, …Gif, …Wmp, …Dds, …Heif, …Webp, …Raw, …JpegXL, …Adng;
  • pixel formats, named IID_WICPixelFormat… here (IID_WICPixelFormat32bppPBGRA, IID_WICPixelFormat24bppBGR …), where the Windows headers say GUID_WICPixelFormat…; the parameter type WICPixelFormatGUID is a GUID;
  • component categories CATID_WIC… and the vendor GUID_VendorMicrosoft.

Things to watch.

  • IID_IWICImagingFactory2 holds a value one byte off the one Windows registers, so CoCreateInstance and QueryInterface with it fail with E_NOINTERFACE (&h80004002). Make the identifier yourself, as below.
  • IWICImageEncoder, IWICDdsEncoder and IWICDisplayAdaptationControl are declared as names, but their methods are declared on Afx_IWICImageEncoder_, Afx_IWICDdsEncoder_ and Afx_IWICDisplayAdaptationControl_: call through a pointer of that type.
  • IWICBitmap.Lock declares its last parameter as byref ... as IWICBitmapLock, not a pointer: pass *cast( IWICBitmapLock ptr, cast( any ptr, @pLock ) ).
  • Encoders and decoders take Windows' own IStream ptr; an IWICStream (built on ComStream) is passed as cast( IStream ptr, cast( any ptr, pStream ) ). The IPropertyBag2 that CreateNewFrame returns is released with pOptions->lpVtbl->Release( pOptions ).
  • CanConvert, DoesSupportTransform and other methods declare a BOOL answer as byref ... as boolean; Windows writes four bytes there. Pass *cast( boolean ptr, @b ) with b a BOOL.
  • The functions WICConvertBitmapSource, WICCreateBitmapFromSection, WICCreateBitmapFromSectionEx, WICMapGuidToShortName, WICMapShortNameToGuid and WICMapSchemaToName are declared with lib "d2d1", which does not provide them: a program calling WICMapGuidToShortName failed to link. Use the factory's CreateFormatConverter in place of WICConvertBitmapSource.

Importing

#import "sys/win"
#import "sys/win/direct2d"
using win, direct2d

Example

A console program that makes a bitmap from its own pixels, encodes it as a PNG file, decodes the file again and reads back its size and one pixel:

#import "sys/win"
#import "sys/win/direct2d"
using win, direct2d

function main() as long
    CoInitialize( NULL )

    ' The imaging factory is a COM class: every other WIC object comes from it.
    dim pFactory as IWICImagingFactory ptr
    dim hr as HRESULT = CoCreateInstance( @CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, _
                                          @IID_IWICImagingFactory, @pFactory )
    if hr <> S_OK then print "no WIC factory: &h"; hex( hr ) : return 1

    ' A 64 x 48 bitmap made from our own pixels: blue on the left, red on the right.
    const W = 64, H = 48
    dim pixels( W * H - 1 ) as ulong
    for i as long = 0 to W * H - 1
        pixels( i ) = iif( ( i mod W ) < W \ 2, &hFF0000FFul, &hFFFF0000ul )   ' &hAARRGGBB
    next
    dim pBitmap as IWICBitmap ptr
    pFactory->CreateBitmapFromMemory( W, H, IID_WICPixelFormat32bppBGRA, W * 4, W * H * 4, _
                                      cast( byte ptr, @pixels( 0 ) ), pBitmap )

    ' Encode it as a PNG file.
    dim wszFile as wstring * MAX_PATH = environ( "TEMP" ) & "\wicdemo.png"
    dim pStream as IWICStream ptr
    pFactory->CreateStream( pStream )
    pStream->InitializeFromFilename( wszFile, GENERIC_WRITE )
    dim pEncoder as IWICBitmapEncoder ptr
    pFactory->CreateEncoder( GUID_ContainerFormatPng, *cast( GUID ptr, NULL ), pEncoder )
    pEncoder->Initialize( cast( IStream ptr, cast( any ptr, pStream ) ), WICBitmapEncoderNoCache )
    dim pFrame as IWICBitmapFrameEncode ptr
    dim pOptions as IPropertyBag2 ptr
    pEncoder->CreateNewFrame( pFrame, pOptions )
    pFrame->Initialize( pOptions )
    pFrame->SetSize( W, H )
    dim fmt as WICPixelFormatGUID = IID_WICPixelFormat32bppBGRA
    pFrame->SetPixelFormat( fmt )
    pFrame->WriteSource( cast( IWICBitmapSource ptr, pBitmap ), *cast( WICRect ptr, NULL ) )
    pFrame->Commit()
    hr = pEncoder->Commit()
    print "PNG written: "; iif( hr = S_OK, "yes", "no" )
    pFrame->Release() : pOptions->lpVtbl->Release( pOptions ) : pEncoder->Release() : pStream->Release()

    ' Decode it again and read the first frame.
    dim pDecoder as IWICBitmapDecoder ptr
    hr = pFactory->CreateDecoderFromFilename( wszFile, *cast( GUID ptr, NULL ), GENERIC_READ, _
                                              WICDecodeMetadataCacheOnDemand, pDecoder )
    dim nFrames as UINT
    pDecoder->GetFrameCount( nFrames )
    dim pDecoded as IWICBitmapFrameDecode ptr
    pDecoder->GetFrame( 0, pDecoded )
    dim as UINT cx, cy
    pDecoded->GetSize( cx, cy )
    print "frames: "; nFrames; ", size: "; cx; " x "; cy

    ' Read one pixel from the right half.
    dim rc as WICRect = ( W - 1, 0, 1, 1 )
    dim px as ulong
    pDecoded->CopyPixels( rc, 4, 4, cast( byte ptr, @px ) )
    print "top-right pixel: &h"; hex( px, 8 )

    pDecoded->Release() : pDecoder->Release() : pBitmap->Release() : pFactory->Release()
    kill( wszFile )
    CoUninitialize()
    return 0
end function

end main()

It prints:

PNG written: yes
frames: 1, size: 64 x 48
top-right pixel: &hFFFF0000

Types

The enumeration types are longs; their values are separate constants, written bare after using direct2d (WICBitmapLockWrite, WICDecodeMetadataCacheOnLoad). WICColorContextType is a named enum.

Interfaces

Interface Methods declared in Extends Is Microsoft Learn
— ComStream ComUnknown The stream methods (Read, Write, Seek, Stat …) that IWICStream inherits; it has no alias of its own. IStream
IWICPalette IWICPalette_ ComUnknown A colour table for indexed pixel formats: predefined, custom or built from a bitmap. IWICPalette
IWICBitmapSource IWICBitmapSource_ ComUnknown The base of everything that has pixels: size, pixel format, resolution, CopyPixels. Direct2D makes bitmaps from one. IWICBitmapSource
IWICFormatConverter IWICFormatConverter_ IWICBitmapSource Converts a source to another pixel format, such as 32bppPBGRA for Direct2D. IWICFormatConverter
IWICPlanarFormatConverter IWICPlanarFormatConverter_ IWICBitmapSource Converts planar (YCbCr) sources to an interleaved pixel format. IWICPlanarFormatConverter
IWICBitmapScaler IWICBitmapScaler_ IWICBitmapSource Resizes a source with a chosen interpolation mode. IWICBitmapScaler
IWICBitmapClipper IWICBitmapClipper_ IWICBitmapSource Crops a source to a rectangle. IWICBitmapClipper
IWICBitmapFlipRotator IWICBitmapFlipRotator_ IWICBitmapSource Flips or rotates a source by multiples of 90 degrees. IWICBitmapFlipRotator
IWICBitmapLock IWICBitmapLock_ ComUnknown Direct access to a locked rectangle of a bitmap: stride, data pointer, pixel format. IWICBitmapLock
IWICBitmap IWICBitmap_ IWICBitmapSource A bitmap in memory that can be written: Lock, palette, resolution. Direct2D can draw into one. IWICBitmap
IWICColorContext IWICColorContext_ ComUnknown A colour profile, from an ICC file, memory or an EXIF colour space. IWICColorContext
IWICColorTransform IWICColorTransform_ IWICBitmapSource Converts a source from one colour context to another. IWICColorTransform
IWICFastMetadataEncoder IWICFastMetadataEncoder_ ComUnknown Updates metadata in place, without re-encoding the image. IWICFastMetadataEncoder
IWICStream IWICStream_ ComStream A stream over a file, a memory block or another stream, for encoders and decoders. IWICStream
IWICEnumMetadataItem IWICEnumMetadataItem_ ComUnknown Walks the items of a metadata block. IWICEnumMetadataItem
IWICMetadataQueryReader IWICMetadataQueryReader_ ComUnknown Reads metadata by query path, such as /app1/ifd/{ushort=274}. IWICMetadataQueryReader
IWICMetadataQueryWriter IWICMetadataQueryWriter_ IWICMetadataQueryReader Writes and removes metadata by query path. IWICMetadataQueryWriter
IWICBitmapEncoder IWICBitmapEncoder_ ComUnknown Writes an image file of one container format: frames, palette, thumbnail, Commit. IWICBitmapEncoder
IWICBitmapFrameEncode IWICBitmapFrameEncode_ ComUnknown One frame being encoded: size, resolution, pixel format, pixels or a source, Commit. IWICBitmapFrameEncode
IWICPlanarBitmapFrameEncode IWICPlanarBitmapFrameEncode_ ComUnknown Writes planar (YCbCr) pixels into a frame. IWICPlanarBitmapFrameEncode
IWICImageEncoder Afx_IWICImageEncoder_ ComUnknown Encodes a Direct2D image into a frame. The name is declared but its methods are not reachable through it: they are declared on Afx_IWICImageEncoder_. IWICImageEncoder
IWICBitmapDecoder IWICBitmapDecoder_ ComUnknown Reads an image file: container format, frame count, frames, preview, thumbnail, metadata. IWICBitmapDecoder
IWICBitmapSourceTransform IWICBitmapSourceTransform_ ComUnknown Lets a decoder scale, flip or convert while it decodes. IWICBitmapSourceTransform
IWICBitmapSourceTransform2 IWICBitmapSourceTransform2_ IWICBitmapSourceTransform Adds colour contexts for a pixel format. —
IWICPlanarBitmapSourceTransform IWICPlanarBitmapSourceTransform_ ComUnknown Decodes straight to planar (YCbCr) buffers. IWICPlanarBitmapSourceTransform
IWICBitmapFrameDecode IWICBitmapFrameDecode_ IWICBitmapSource One decoded frame: an IWICBitmapSource plus metadata, colour contexts and thumbnail. IWICBitmapFrameDecode
IWICProgressiveLevelControl IWICProgressiveLevelControl_ ComUnknown Chooses the level of a progressively encoded image. IWICProgressiveLevelControl
IWICDisplayAdaptationControl Afx_IWICDisplayAdaptationControl_ ComUnknown Sets the display luminance HDR images are adapted to. The name is declared but its methods are declared on Afx_IWICDisplayAdaptationControl_. —
IWICProgressCallback IWICProgressCallback_ ComUnknown Implemented by a program to hear the progress of a long operation. IWICProgressCallback
IWICBitmapCodecProgressNotification IWICBitmapCodecProgressNotification_ ComUnknown Registers a progress callback with an encoder or decoder. IWICBitmapCodecProgressNotification
IWICComponentInfo IWICComponentInfo_ ComUnknown Common information about a WIC component: type, CLSID, author, version, friendly name. IWICComponentInfo
IWICFormatConverterInfo IWICFormatConverterInfo_ IWICComponentInfo Information about a format converter: the pixel formats it handles. IWICFormatConverterInfo
IWICBitmapCodecInfo IWICBitmapCodecInfo_ IWICComponentInfo Information about a codec: container format, pixel formats, MIME types, file extensions, capabilities. IWICBitmapCodecInfo
IWICBitmapEncoderInfo IWICBitmapEncoderInfo_ IWICBitmapCodecInfo Information about an encoder; can create it. IWICBitmapEncoderInfo
IWICBitmapDecoderInfo IWICBitmapDecoderInfo_ IWICBitmapCodecInfo Information about a decoder: the byte patterns it recognises; can create it. IWICBitmapDecoderInfo
IWICPixelFormatInfo IWICPixelFormatInfo_ IWICComponentInfo Information about a pixel format: bits per pixel, channels, channel masks. IWICPixelFormatInfo
IWICPixelFormatInfo2 IWICPixelFormatInfo2_ IWICPixelFormatInfo Adds transparency support and the numeric representation. IWICPixelFormatInfo2
IWICImagingFactory IWICImagingFactory_ ComUnknown The root object: creates decoders, encoders, streams, bitmaps, converters, scalers and palettes. From CoCreateInstance with CLSID_WICImagingFactory. IWICImagingFactory
IWICImagingFactory2 IWICImagingFactory2_ IWICImagingFactory Adds CreateImageEncoder for Direct2D images. IWICImagingFactory2
IWICDevelopRawNotificationCallback IWICDevelopRawNotificationCallback_ ComUnknown Implemented by a program to hear when RAW development settings change. IWICDevelopRawNotificationCallback
IWICDevelopRaw IWICDevelopRaw_ IWICBitmapFrameDecode Develops a camera RAW frame: exposure, white point, contrast, gamma, sharpening, tone curve, rotation. IWICDevelopRaw
IWICDdsDecoder IWICDdsDecoder_ ComUnknown DDS texture decoder: parameters and frames by array index, mip level and slice. IWICDdsDecoder
IWICDdsEncoder Afx_IWICDdsEncoder_ ComUnknown DDS texture encoder. The name is declared but its methods are declared on Afx_IWICDdsEncoder_. IWICDdsEncoder
IWICDdsFrameDecode IWICDdsFrameDecode_ ComUnknown One DDS frame: size in blocks, format information, CopyBlocks. IWICDdsFrameDecode
IWICJpegFrameDecode IWICJpegFrameDecode_ ComUnknown Low-level JPEG decoding: Huffman and quantization tables, frame and scan headers, scans. IWICJpegFrameDecode
IWICJpegFrameEncode IWICJpegFrameEncode_ ComUnknown Low-level JPEG encoding: tables and scans written as they are. IWICJpegFrameEncode

Enumerations

Type Values Is Microsoft Learn
WICColorContextType WICColorContext* What a colour context holds: nothing, an ICC profile, an EXIF colour space. WICColorContextType
WICBitmapCreateCacheOption WICBitmap* Whether a new bitmap copies its source: no cache, on demand, on load. WICBitmapCreateCacheOption
WICDecodeOptions WICDecodeMetadataCacheOnDemand, WICDecodeMetadataCacheOnLoad When a decoder reads the metadata: on demand or on load. WICDecodeOptions
WICBitmapEncoderCacheOption WICBitmapEncoder* Where an encoder keeps data: in memory, in a temporary file, nowhere. WICBitmapEncoderCacheOption
WICComponentType WICDecoder, WICEncoder … Kinds of WIC component: decoder, encoder, pixel-format converter, metadata reader and writer, pixel format. WICComponentType
WICComponentEnumerateOptions WICComponentEnumerate* Which components CreateComponentEnumerator lists: default, refresh, disabled, unsigned, built-in only. WICComponentEnumerateOptions
WICBitmapInterpolationMode WICBitmapInterpolationMode* Scaling filter: nearest neighbour, linear, cubic, Fant, high-quality cubic. WICBitmapInterpolationMode
WICBitmapPaletteType WICBitmapPaletteType* Palettes: custom, median cut, and fixed black and white, halftone, web and grey palettes. WICBitmapPaletteType
WICBitmapDitherType WICBitmapDitherType* Dithering for colour reduction: none, ordered, spiral, dual spiral, error diffusion. WICBitmapDitherType
WICBitmapAlphaChannelOption WICBitmap* How an HBITMAP alpha channel is read: use, premultiplied, ignore. WICBitmapAlphaChannelOption
WICBitmapTransformOptions WICBitmapTransform* Rotations by 0, 90, 180, 270 degrees and horizontal or vertical flips. WICBitmapTransformOptions
WICBitmapLockFlags WICBitmapLockRead, WICBitmapLockWrite Access to a locked bitmap: read, write. WICBitmapLockFlags
WICBitmapDecoderCapabilities WICBitmapDecoderCapability* What a decoder can do with a stream: same encoder, all or some images, enumerate metadata, thumbnails. WICBitmapDecoderCapabilities
WICProgressOperation WICProgressOperation* Which operations report progress: copying or writing pixels. WICProgressOperation
WICProgressNotification WICProgressNotification* When progress is reported: begin, end, frequently, always. WICProgressNotification
WICComponentSigning WICComponent* Whether a component is signed, unsigned, safe or disabled. WICComponentSigning
WICGifLogicalScreenDescriptorProperties WICGifLogicalScreen* Metadata items of a GIF logical screen descriptor. WICGifLogicalScreenDescriptorProperties
WICGifImageDescriptorProperties WICGifImageDescriptor* Metadata items of a GIF image descriptor. WICGifImageDescriptorProperties
WICGifGraphicControlExtensionProperties WICGifGraphicControlExtension* Metadata items of a GIF graphic control extension: disposal, delay, transparency. WICGifGraphicControlExtensionProperties
WICGifApplicationExtensionProperties WICGifApplicationExtensionApplication, WICGifApplicationExtensionData Metadata items of a GIF application extension. WICGifApplicationExtensionProperties
WICGifCommentExtensionProperties WICGifCommentExtensionText Metadata item of a GIF comment extension. WICGifCommentExtensionProperties
WICJpegCommentProperties WICJpegCommentText Metadata item of a JPEG comment. WICJpegCommentProperties
WICJpegLuminanceProperties WICJpegLuminanceTable Metadata item of a JPEG luminance table. WICJpegLuminanceProperties
WICJpegChrominanceProperties WICJpegChrominanceTable Metadata item of a JPEG chrominance table. WICJpegChrominanceProperties
WIC8BIMIptcProperties WIC8BIMIptcPString, WIC8BIMIptcEmbeddedIPTC Metadata items of a Photoshop 8BIM IPTC block. WIC8BIMIptcProperties
WIC8BIMResolutionInfoProperties WIC8BIMResolutionInfo* Metadata items of a Photoshop 8BIM resolution block. WIC8BIMResolutionInfoProperties
WIC8BIMIptcDigestProperties WIC8BIMIptcDigestPString, WIC8BIMIptcDigestIptcDigest Metadata items of a Photoshop 8BIM IPTC digest. WIC8BIMIptcDigestProperties
WICPngGamaProperties WICPngGamaGamma Metadata item of a PNG gAMA chunk. WICPngGamaProperties
WICPngBkgdProperties WICPngBkgdBackgroundColor Metadata item of a PNG bKGD chunk. WICPngBkgdProperties
WICPngItxtProperties WICPngItxt* Metadata items of a PNG iTXt chunk. WICPngItxtProperties
WICPngChrmProperties WICPngChrm* Metadata items of a PNG cHRM chunk. WICPngChrmProperties
WICPngHistProperties WICPngHistFrequencies Metadata item of a PNG hIST chunk. WICPngHistProperties
WICPngIccpProperties WICPngIccpProfileName, WICPngIccpProfileData Metadata items of a PNG iCCP chunk. WICPngIccpProperties
WICPngSrgbProperties WICPngSrgbRenderingIntent Metadata item of a PNG sRGB chunk. WICPngSrgbProperties
WICPngTimeProperties WICPngTime* Metadata items of a PNG tIME chunk. WICPngTimeProperties
WICHeifProperties WICHeifOrientation Metadata item of a HEIF image: orientation. WICHeifProperties
WICHeifHdrProperties WICHeifHdr* HDR metadata items of a HEIF image. WICHeifHdrProperties
WICWebpAnimProperties WICWebpAnimLoopCount Metadata item of a WebP ANIM chunk: loop count. WICWebpAnimProperties
WICWebpAnmfProperties WICWebpAnmfFrameDuration Metadata item of a WebP ANMF chunk: frame duration. WICWebpAnmfProperties
WICJpegXLAnimProperties WICJpegXLAnim* Animation metadata items of a JPEG XL image. —
WICJpegXLAnimFrameProperties WICJpegXLAnimFrameDurationInTicks, WICJpegXLAnimFrameName Frame metadata items of a JPEG XL animation. —
WICSectionAccessLevel WICSectionAccessLevelRead, WICSectionAccessLevelReadWrite Access to a section-backed bitmap: read, read and write. WICSectionAccessLevel
WICPixelFormatNumericRepresentation WICPixelFormatNumericRepresentation* How channel values are stored: indexed, integer, fixed point, float. WICPixelFormatNumericRepresentation
WICPlanarOptions WICPlanarOptionsDefault, WICPlanarOptionsPreserveSubsampling Whether planar decoding keeps chroma subsampling. WICPlanarOptions
WICJpegIndexingOptions WICJpegIndexingOptionsGenerateOnDemand, WICJpegIndexingOptionsGenerateOnLoad When a JPEG decoder builds its index: on demand, on load. WICJpegIndexingOptions
WICJpegTransferMatrix WICJpegTransferMatrixIdentity, WICJpegTransferMatrixBT601 JPEG colour transfer matrix: identity, BT.601. WICJpegTransferMatrix
WICJpegScanType WICJpegScanType* JPEG scan layout: interleaved, planar components, progressive. WICJpegScanType
WICTiffCompressionOption WICTiffCompression* TIFF encoder compression: none, CCITT, LZW, RLE, ZIP, LZWH differencing. WICTiffCompressionOption
WICJpegYCrCbSubsamplingOption WICJpegYCrCbSubsampling* JPEG encoder chroma subsampling: 4:2:0, 4:2:2, 4:4:4, 4:4:0. WICJpegYCrCbSubsamplingOption
WICPngFilterOption WICPngFilter* PNG encoder row filter: none, sub, up, average, Paeth, adaptive. WICPngFilterOption
WICHeifCompressionOption WICHeifCompression* HEIF encoder compression: none, HEVC, AV1. WICHeifCompressionOption
WICNamedWhitePoint WICWhitePoint* Named white points for RAW development: daylight, cloudy, shade, tungsten … WICNamedWhitePoint
WICRawCapabilities WICRawCapability* Whether a RAW setting can be read, set, or not at all. WICRawCapabilities
WICRawRotationCapabilities WICRawRotationCapability* Which rotations a RAW codec supports. WICRawRotationCapabilities
WICRawParameterSet WICAsShotParameterSet, WICUserAdjustedParameterSet … RAW parameter sets: as shot, user adjusted, auto adjusted. WICRawParameterSet
WICRawRenderMode WICRawRenderMode* RAW rendering quality: draft, normal, best. WICRawRenderMode
WICDdsDimension WICDdsTexture* DDS texture shape: 1D, 2D, 3D, cube. WICDdsDimension
WICDdsAlphaMode WICDdsAlphaMode* DDS alpha interpretation: unknown, straight, premultiplied, opaque, custom. WICDdsAlphaMode

Structures

Type Is Microsoft Learn
WICRect A rectangle by position and size (X, Y, Width, Height), the area CopyPixels and Lock work on. WICRect
WICBitmapPattern A byte pattern a decoder recognises at a file position. WICBitmapPattern
WICImageParameters Pixel format, DPI and area used when encoding a Direct2D image. WICImageParameters
WICBitmapPlaneDescription Format and size of one plane of a planar image. WICBitmapPlaneDescription
WICBitmapPlane Format, buffer and stride of one plane. WICBitmapPlane
WICJpegFrameHeader The header of a JPEG frame: size, transfer matrix, scan type, components. WICJpegFrameHeader
WICJpegScanHeader The header of a JPEG scan: components, restart interval, spectral selection. WICJpegScanHeader
WICRawCapabilitiesInfo Which RAW settings a codec supports. WICRawCapabilitiesInfo
WICRawToneCurvePoint One point of a RAW tone curve. WICRawToneCurvePoint
WICRawToneCurve A RAW tone curve: a count and its points. WICRawToneCurve
WICDdsParameters Size, depth, mip levels, array size, DXGI format, dimension and alpha mode of a DDS texture. WICDdsParameters
WICDdsFormatInfo DXGI format and block size of DDS data. WICDdsFormatInfo

Other types

Type Declared as Is Microsoft Learn
LPCOMSTREAM ComStream ptr A pointer to ComStream. —
ID2D1Device ID2D1Device_ The Direct2D device that IWICImagingFactory2.CreateImageEncoder takes; its methods are with Direct2D. ID2D1Device
ID2D1Image ID2D1Image_ The Direct2D image an image encoder writes; its methods are with Direct2D. ID2D1Image
WICColor UINT32 A palette colour, &hAARRGGBB. —
WICInProcPointer byte ptr A pointer to bytes, as IWICBitmapLock.GetDataPointer returns. —

Using the interfaces

A decoded frame converted to the pixel format Direct2D wants, ready for CreateBitmapFromWicBitmap:

Example

dim pFactory as IWICImagingFactory ptr
CoCreateInstance( @CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, @IID_IWICImagingFactory, @pFactory )
dim pFrame as IWICBitmapFrameDecode ptr        ' from IWICBitmapDecoder.GetFrame
dim pConverter as IWICFormatConverter ptr
pFactory->CreateFormatConverter( pConverter )
if pFrame then pConverter->Initialize( pFrame, IID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, NULL, 0, WICBitmapPaletteTypeCustom )

Writing pixels through a lock:

Example

dim pFactory as IWICImagingFactory ptr, pBitmap as IWICBitmap ptr, pLock as IWICBitmapLock ptr
CoCreateInstance( @CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, @IID_IWICImagingFactory, @pFactory )
pFactory->CreateBitmap( 8, 4, IID_WICPixelFormat32bppPBGRA, WICBitmapCacheOnLoad, pBitmap )
dim rc as WICRect = ( 0, 0, 8, 4 )
pBitmap->Lock( rc, WICBitmapLockWrite, *cast( IWICBitmapLock ptr, cast( any ptr, @pLock ) ) )
dim cb as UINT, pData as WICInProcPointer
pLock->GetDataPointer( cb, pData )            ' cb = 128: 8 x 4 pixels of 4 bytes

The second-version factory, with the identifier Windows registers:

Example

dim iid as GUID = ( &h7B816B45, &h1996, &h4476, { &hB1, &h32, &hDE, &h9E, &h24, &h7C, &h8A, &hF0 } )
dim pFactory2 as IWICImagingFactory2 ptr
CoCreateInstance( @CLSID_WICImagingFactory2, NULL, CLSCTX_INPROC_SERVER, @iid, @pFactory2 )

Microsoft Learn: Windows Imaging Component, Native pixel formats

See also

Clone this wiki locally