using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using Vanara.InteropServices;
using static Vanara.PInvoke.D2d1;
using static Vanara.PInvoke.Ole32;
namespace Vanara.PInvoke
{
/// Items from the WindowsCodecs.dll
public static partial class WindowsCodecs
{
private delegate void GetArrayAction(uint cbSize, T[] value, out uint actualSize);
private delegate void GetStringAction(uint cbSize, StringBuilder value, out uint actualSize);
///
/// Provides access to a single frame of DDS image data in its native DXGI_FORMAT form, as well as information about the image data.
///
///
/// This interface is implemented by the WIC DDS codec. To obtain this interface, create an IWICBitmapFrameDecode using the DDS
/// codec and QueryInterface for IID_IWICDdsFrameDecode.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicddsframedecode
[PInvokeData("wincodec.h", MSDNShortId = "52E76A8D-E7E2-46F5-BBCC-B7C74F1B1122")]
[ComImport, Guid("3d4c0c61-18a4-41e4-bd80-481a4fc9f464"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICDdsFrameDecode
{
/// Gets the width and height, in blocks, of the DDS image.
///
/// Type: UINT*
/// The width of the DDS image in blocks.
///
///
/// Type: UINT*
/// The height of the DDS image in blocks.
///
///
///
/// For block compressed textures, the returned width and height values do not completely define the texture size because the
/// image is padded to fit the closest whole block size. For example, three BC1 textures with pixel dimensions of 1x1, 2x2 and
/// 4x4 will all report pWidthInBlocks = 1 and pHeightInBlocks = 1.
///
///
/// If the texture does not use a block-compressed DXGI_FORMAT, this method returns the texture size in pixels; for these
/// formats the block size returned by IWICDdsFrameDecoder::GetFormatInfo is 1x1.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicddsframedecode-getsizeinblocks HRESULT
// GetSizeInBlocks( UINT *pWidthInBlocks, UINT *pHeightInBlocks );
void GetSizeInBlocks(out uint pWidthInBlocks, out uint pHeightInBlocks);
/// Gets information about the format in which the DDS image is stored.
///
/// Type: WICDdsFormatInfo*
/// Information about the DDS format.
///
///
/// This information can be used for allocating memory or constructing Direct3D or Direct2D resources, for example by using
/// ID3D11Device::CreateTexture2D or ID2D1DeviceContext::CreateBitmap.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicddsframedecode-getformatinfo HRESULT
// GetFormatInfo( WICDdsFormatInfo *pFormatInfo );
WICDdsFormatInfo GetFormatInfo();
/// Requests pixel data as it is natively stored within the DDS file.
///
/// Type: const WICRect*
/// The rectangle to copy from the source. A NULL value specifies the entire texture.
///
/// If the texture uses a block-compressed DXGI_FORMAT, all values of the rectangle are expressed in number of blocks, not pixels.
///
///
///
/// Type: UINT
///
/// The stride, in bytes, of the destination buffer. This represents the number of bytes from the buffer pointer to the next row
/// of data. If the texture uses a block-compressed DXGI_FORMAT, a "row of data" is defined as a row of blocks which contains
/// multiple pixel scanlines.
///
///
///
/// Type: UINT
/// The size, in bytes, of the destination buffer.
///
///
/// Type: BYTE*
/// A pointer to the destination buffer.
///
///
/// Type: HRESULT
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// If the texture does not use a block-compressed DXGI_FORMAT, this method behaves similarly to IWICBitmapSource::CopyPixels.
/// However, it does not perform any pixel format conversion, and instead produces the raw data from the DDS file.
///
///
/// If the texture uses a block-compressed DXGI_FORMAT, this method copies the block data directly into the provided buffer. In
/// this case, the prcBoundsInBlocks parameter is defined in blocks, not pixels. To determine if this is the case, call
/// GetFormatInfo and read the DxgiFormat member of the returned WICDdsFormatInfo structure.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicddsframedecode-copyblocks HRESULT CopyBlocks(
// const WICRect *prcBoundsInBlocks, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer );
void CopyBlocks([In, Optional] PWICRect prcBoundsInBlocks, uint cbStride, uint cbBufferSize, [Out] IntPtr pbBuffer);
}
/// Exposes methods that provide enumeration services for individual metadata items.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicenummetadataitem
[PInvokeData("wincodec.h", MSDNShortId = "4fe0e47f-9ef4-4aa1-a3ae-578b3759f9ef")]
[ComImport, Guid("DC2BB46D-3F07-481E-8625-220C4AEDBB33"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICEnumMetadataItem
{
/// Advanced the current position in the enumeration.
///
/// Type: ULONG
/// The number of items to be retrieved.
///
///
/// Type: PROPVARIANT*
/// An array of enumerated items. This parameter is optional.
///
///
/// Type: PROPVARIANT*
/// An array of enumerated items.
///
///
/// Type: PROPVARIANT*
/// An array of enumerated items. This parameter is optional.
///
///
/// Type: ULONG*
/// The number of items that were retrieved. This value is always less than or equal to the number of items requested.
///
///
/// Type: HRESULT
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicenummetadataitem-next HRESULT Next( ULONG celt,
// PROPVARIANT *rgeltSchema, PROPVARIANT *rgeltId, PROPVARIANT *rgeltValue, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0), Optional] PROPVARIANT_IMMUTABLE[] rgeltSchema,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] PROPVARIANT_IMMUTABLE[] rgeltId,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0), Optional] PROPVARIANT_IMMUTABLE[] rgeltValue, out uint pceltFetched);
/// Skips to given number of objects.
///
/// Type: ULONG
/// The number of objects to skip.
///
///
/// Type: HRESULT
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicenummetadataitem-skip HRESULT Skip( ULONG celt );
[PreserveSig]
HRESULT Skip(uint celt);
/// Resets the current position to the beginning of the enumeration.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicenummetadataitem-reset HRESULT Reset();
void Reset();
/// Creates a copy of the current IWICEnumMetadataItem.
///
/// Type: IWICEnumMetadataItem**
/// A pointer that receives a pointer to the IWICEnumMetadataItem copy.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicenummetadataitem-clone HRESULT Clone(
// IWICEnumMetadataItem **ppIEnumMetadataItem );
IWICEnumMetadataItem Clone();
}
///
/// Exposes methods used for in-place metadata editing. A fast metadata encoder enables you to add and remove metadata to an image
/// without having to fully re-encode the image.
///
///
///
/// A decoder must be created using the WICDecodeOptions value WICDecodeMetadataCacheOnDemand to perform in-place metadata
/// updates. Using the WICDecodeMetadataCacheOnLoad option causes the decoder to release the file stream necessary to perform
/// the metadata updates.
///
///
/// Not all metadata formats support fast metadata encoding. The native metadata handlers that support metadata are IFD, Exif, XMP,
/// and GPS.
///
/// If a fast metadata encoder fails, the image will need to be fully re-encoded to add the metadata.
/// Examples
///
/// The following demonstrates how to obtain a fast metadata encoder from an image frame and use its query writer to write a
/// metadata item.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicfastmetadataencoder
[PInvokeData("wincodec.h", MSDNShortId = "c7b57a71-f1fe-4e30-a52e-72ab6ce021f7")]
[ComImport, Guid("B84E2C09-78C9-4AC4-8BD3-524AE1663A2F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICFastMetadataEncoder
{
/// Finalizes metadata changes to the image stream.
///
///
/// If the commit fails and returns WINCODEC_ERR_STREAMNOTAVAILABLE, ensure that the image decoder was loaded using the
/// WICDecodeMetadataCacheOnDemand option. A fast metadata encoder is not supported when the decoder is created using the
/// WICDecodeMetadataCacheOnLoad option.
///
///
/// If the commit fails for any reason, you will need to re-encode the image to ensure the new metadata is added to the image.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicfastmetadataencoder-commit HRESULT Commit();
void Commit();
/// Retrieves a metadata query writer for fast metadata encoding.
///
/// Type: IWICMetadataQueryWriter**
/// When this method returns, contains a pointer to the fast metadata encoder's metadata query writer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicfastmetadataencoder-getmetadataquerywriter
// HRESULT GetMetadataQueryWriter( IWICMetadataQueryWriter **ppIMetadataQueryWriter );
IWICMetadataQueryWriter GetMetadataQueryWriter();
}
///
/// Represents an IWICBitmapSource that converts the image data from one pixel format to another, handling dithering and halftoning
/// to indexed formats, palette translation and alpha thresholding.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicformatconverter
[PInvokeData("wincodec.h", MSDNShortId = "d558aaa7-5962-424c-9e83-363fba09ad50")]
[ComImport, Guid("00000301-a8f2-4877-ba0a-fd2b6645fb94"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICFormatConverter : IWICBitmapSource
{
/// Retrieves the pixel width and height of the bitmap.
///
/// Type: UINT*
/// A pointer that receives the pixel width of the bitmap.
///
///
/// Type: UINT*
/// A pointer that receives the pixel height of the bitmap
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapsource-getsize HRESULT GetSize( UINT
// *puiWidth, UINT *puiHeight );
new void GetSize(out uint puiWidth, out uint puiHeight);
/// Retrieves the pixel format of the bitmap source..
///
/// Receives the pixel format GUID the bitmap is stored in. For a list of available pixel formats, see the Native Pixel Formats topic.
///
///
/// The pixel format returned by this method is not necessarily the pixel format the image is stored as. The codec may perform a
/// format conversion from the storage pixel format to an output pixel format.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapsource-getpixelformat HRESULT
// GetPixelFormat( Guid *pPixelFormat );
new Guid GetPixelFormat();
/// Retrieves the sampling rate between pixels and physical world measurements.
///
/// Type: double*
/// A pointer that receives the x-axis dpi resolution.
///
///
/// Type: double*
/// A pointer that receives the y-axis dpi resolution.
///
///
///
/// Some formats, such as GIF and ICO, do not have full DPI support. For GIF, this method calculates the DPI values from the
/// aspect ratio, using a base DPI of (96.0, 96.0). The ICO format does not support DPI at all, and the method always returns
/// (96.0,96.0) for ICO images.
///
///
/// Additionally, WIC itself does not transform images based on the DPI values in an image. It is up to the caller to transform
/// an image based on the resolution returned.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapsource-getresolution HRESULT GetResolution(
// double *pDpiX, double *pDpiY );
new void GetResolution(out double pDpiX, out double pDpiY);
/// Retrieves the color table for indexed pixel formats.
///
/// Type: IWICPalette*
/// An IWICPalette. A palette can be created using the CreatePalette method.
///
///
/// Type: HRESULT
/// Returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// WINCODEC_ERR_PALETTEUNAVAILABLE
/// The palette was unavailable.
///
/// -
/// S_OK
/// The palette was successfully copied.
///
///
///
///
/// If the IWICBitmapSource is an IWICBitmapFrameDecode, the function may return the image's global palette if a frame-level
/// palette is not available. The global palette may also be retrieved using the CopyPalette method.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapsource-copypalette HRESULT CopyPalette(
// IWICPalette *pIPalette );
[PreserveSig]
new HRESULT CopyPalette(IWICPalette pIPalette);
/// Instructs the object to produce pixels.
///
/// Type: const WICRect*
/// The rectangle to copy. A NULL value specifies the entire bitmap.
///
///
/// Type: UINT
/// The stride of the bitmap
///
///
/// Type: UINT
/// The size of the buffer.
///
///
/// Type: BYTE*
/// A pointer to the buffer.
///
///
/// Type: HRESULT
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing.
/// It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored
/// on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent
/// on the object implementing the interface.
///
///
/// The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must
/// be fully contained in the bounds of the bitmap. Specifying a NULL ROI implies that the whole bitmap should be returned.
///
///
/// The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along
/// with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent
/// pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width,
/// height and pixel format of the bitmap and the sub-rectangle provided to the copy method.
///
///
/// If the caller needs to perform numerous copies of an expensive IWICBitmapSource such as a JPEG, it is recommended to create
/// an in-memory IWICBitmap first.
///
/// Codec Developer Remarks
///
/// The callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this
/// case, a line is a consecutive string of cbStride bytes).
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapsource-copypixels HRESULT CopyPixels( const
// WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer );
new void CopyPixels([In, Optional] PWICRect prc, uint cbStride, uint cbBufferSize, [In, Out] IntPtr pbBuffer);
/// Initializes the format converter.
///
/// Type: IWICBitmapSource*
/// The input bitmap to convert
///
///
/// Type: REFWICPixelFormatGUID
/// The destination pixel format GUID.
///
///
/// Type: WICBitmapDitherType
/// The WICBitmapDitherType used for conversion.
///
///
/// Type: IWICPalette*
/// The palette to use for conversion.
///
///
/// Type: double
/// The alpha threshold to use for conversion.
///
///
/// Type: WICBitmapPaletteType
/// The palette translation type to use for conversion.
///
///
///
/// If you do not have a predefined palette, you must first create one. Use InitializeFromBitmap to create the palette object,
/// then pass it in along with your other parameters.
///
///
/// dither, pIPalette, alphaThresholdPercent, and paletteTranslate are used to mitigate color loss when converting to a reduced
/// bit-depth format. For conversions that do not need these settings, the following parameters values should be used: dither
/// set to WICBitmapDitherTypeNone, pIPalette set to NULL, alphaThresholdPercent set to 0.0f, and
/// paletteTranslate set to WICBitmapPaletteTypeCustom.
///
///
/// The basic algorithm involved when using an ordered dither requires a fixed palette, found in the WICBitmapPaletteType
/// enumeration, in a specific order. Often, the actual palette provided for the output may have a different ordering or some
/// slight variation in the actual colors. This is the case when using the Microsoft Windows palette which has slight
/// differences among versions of Windows. To provide for this, a palette and a palette translation are given to the format
/// converter. The pIPalette is the actual destination palette to be used and the paletteTranslate is a fixed palette. Once the
/// conversion is complete, the colors are mapped from the fixed palette to the actual colors in pIPalette using a nearest color
/// matching algorithm.
///
///
/// WICBitmapDitherTypeOrdered4x4 can be useful in format conversions from 8-bit formats to 5- or 6-bit formats as there
/// is no way to accurately convert color data.
///
///
/// WICBitmapDitherTypeErrorDiffusion selects the error diffusion algorithm and may be used with any palette. If an
/// arbitrary palette is provided, WICBitmapPaletteCustom should be passed in as the paletteTranslate. Error diffusion
/// often provides superior results compared to the ordered dithering algorithms especially when combined with the optimized
/// palette generation functionality on the IWICPalette.
///
///
/// Some 8bpp content can contains an alpha color; for instance, the Graphics Interchange Format (GIF) format allows for a
/// single palette entry to be used as a transparent color. For this type of content, alphaThresholdPercent specifies what
/// percentage of transparency should map to the transparent color. Because the alpha value is directly proportional to the
/// opacity (not transparency) of a pixel, the alphaThresholdPercent indicates what level of opacity is mapped to the fully
/// transparent color. For instance, 9.8% implies that any pixel with an alpha value of less than 25 will be mapped to the
/// transparent color. A value of 100% maps all pixels which are not fully opaque to the transparent color. Note that the
/// palette should provide a transparent color. If it does not, the 'transparent' color will be the one closest to zero - often black.
///
/// Examples
///
/// The following example converts an image frame to a 32bppPBGRA format with no dithering or alpha threshold. Direct2D requires
/// bitmap sources to be in the a 32bppPBGRA format for rendering. For a full sample demonstrating the use of the
/// IWICFormatConverter, see the WIC Image Viewer Using Direct2D Sample.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicformatconverter-initialize HRESULT Initialize(
// IWICBitmapSource *pISource, REFWICPixelFormatGUID dstFormat, WICBitmapDitherType dither, IWICPalette *pIPalette, double
// alphaThresholdPercent, WICBitmapPaletteType paletteTranslate );
void Initialize(IWICBitmapSource pISource, in Guid dstFormat, WICBitmapDitherType dither, IWICPalette pIPalette, double alphaThresholdPercent, WICBitmapPaletteType paletteTranslate);
/// Determines if the source pixel format can be converted to the destination pixel format.
///
/// Type: REFWICPixelFormatGUID
/// The source pixel format.
///
///
/// Type: REFWICPixelFormatGUID
/// The destionation pixel format.
///
///
/// Type: BOOL*
///
/// A pointer that receives a value indicating whether the source pixel format can be converted to the destination pixel format.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicformatconverter-canconvert HRESULT CanConvert(
// REFWICPixelFormatGUID srcPixelFormat, REFWICPixelFormatGUID dstPixelFormat, BOOL *pfCanConvert );
[return: MarshalAs(UnmanagedType.Bool)]
bool CanConvert(in Guid srcPixelFormat, in Guid dstPixelFormat);
}
/// Exposes methods that provide information about a pixel format converter.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicformatconverterinfo
[PInvokeData("wincodec.h", MSDNShortId = "e6e2bade-66c1-4994-89b9-68aa038bdc8c")]
[ComImport, Guid("9F34FB65-13F4-4f15-BC57-3726B5E53D9F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICFormatConverterInfo : IWICComponentInfo
{
/// Retrieves the component's WICComponentType.
///
/// Type: WICComponentType*
/// A pointer that receives the WICComponentType.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getcomponenttype HRESULT
// GetComponentType( WICComponentType *pType );
new WICComponentType GetComponentType();
/// Retrieves the component's class identifier (CLSID)
///
/// Type: CLSID*
/// A pointer that receives the component's CLSID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getclsid HRESULT GetCLSID( CLSID
// *pclsid );
new Guid GetCLSID();
/// Retrieves the signing status of the component.
///
/// Type: DWORD*
/// A pointer that receives the WICComponentSigning status of the component.
///
///
/// Signing is unused by WIC. Therefore, all components WICComponentSigned.
///
/// This function can be used to determine whether a component has no binary component or has been added to the disabled
/// components list in the registry.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getsigningstatus HRESULT
// GetSigningStatus( DWORD *pStatus );
new WICComponentSigning GetSigningStatus();
/// Retrieves the name of component's author.
///
/// Type: UINT
/// The size of the wzAuthor buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the name of the component's author. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's authors name. The author name is optional; if an author name is
/// not specified by the component, the length returned is 0.
///
///
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getauthor HRESULT GetAuthor( UINT
// cchAuthor, WCHAR *wzAuthor, UINT *pcchActual );
new void GetAuthor(uint cchAuthor, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAuthor, out uint pcchActual);
/// Retrieves the vendor GUID.
///
/// Type: GUID*
/// A pointer that receives the component's vendor GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getvendorguid HRESULT
// GetVendorGUID( GUID *pguidVendor );
new Guid GetVendorGUID();
/// Retrieves the component's version.
///
/// Type: UINT
/// The size of the wzVersion buffer.
///
///
/// Type: WCHAR*
/// A pointer that receives a culture invariant string of the component's version.
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's version. The version is optional; if a value is not specified
/// by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getversion HRESULT GetVersion( UINT
// cchVersion, WCHAR *wzVersion, UINT *pcchActual );
new void GetVersion(uint cchVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzVersion, out uint pcchActual);
/// Retrieves the component's specification version.
///
/// Type: UINT
/// The size of the wzSpecVersion buffer.
///
///
/// Type: WCHAR*
///
/// When this method returns, contain a culture invarient string of the component's specification version. The version form is NN.NN.NN.NN.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's specification version. The specification version is optional;
/// if a value is not specified by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a spec version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getspecversion HRESULT
// GetSpecVersion( UINT cchSpecVersion, WCHAR *wzSpecVersion, UINT *pcchActual );
new void GetSpecVersion(uint cchSpecVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzSpecVersion, out uint pcchActual);
/// Retrieves the component's friendly name, which is a human-readable display name for the component.
///
/// Type: UINT
/// The size of the wzFriendlyName buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the friendly name of the component. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
/// A pointer that receives the actual length of the component's friendly name.
///
/// If cchFriendlyName is 0 and wzFriendlyName is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getfriendlyname HRESULT
// GetFriendlyName( UINT cchFriendlyName, WCHAR *wzFriendlyName, UINT *pcchActual );
new void GetFriendlyName(uint cchFriendlyName, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFriendlyName, out uint pcchActual);
/// Retrieves a list of GUIDs that signify which pixel formats the converter supports.
///
/// Type: UINT
/// The size of the pPixelFormatGUIDs array.
///
///
/// Type: WICPixelFormatGUID*
/// Pointer to a GUID array that receives the pixel formats the converter supports.
///
///
/// Type: UINT*
/// The actual array size needed to retrieve all pixel formats supported by the converter.
///
///
///
/// The format converter does not necessarily guarantee symmetricality with respect to conversion; that is, a converter may be
/// able to convert FROM a particular format without actually being able to convert TO a particular format. In order to test
/// symmetricality, use CanConvert.
///
///
/// To determine the number of pixel formats a coverter can handle, set cFormats to and pPixelFormatGUIDs to . The converter
/// will fill pcActual with the number of formats supported by that converter.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicformatconverterinfo-getpixelformats HRESULT
// GetPixelFormats( UINT cFormats, WICPixelFormatGUID *pPixelFormatGUIDs, UINT *pcActual );
void GetPixelFormats(uint cFormats, [In] Guid[] pPixelFormatGUIDs, out uint pcActual);
/// Creates a new IWICFormatConverter instance.
///
/// Type: IWICFormatConverter**
/// A pointer that receives a new IWICFormatConverter instance.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicformatconverterinfo-createinstance HRESULT
// CreateInstance( IWICFormatConverter **ppIConverter );
IWICFormatConverter CreateInstance();
}
///
/// Encodes ID2D1Image interfaces to an IWICBitmapEncoder. The input images can be larger than the maximum device texture size.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicimageencoder
[PInvokeData("wincodec.h", MSDNShortId = "D9854D82-0226-4DD8-AE54-93E5B6544B46")]
[ComImport, Guid("04C75BF8-3CE1-473B-ACC5-3CC4F5E94999"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICImageEncoder
{
/// Encodes the image to the frame given by the IWICBitmapFrameEncode.
///
/// Type: ID2D1Image*
/// The Direct2D image that will be encoded.
///
///
/// Type: IWICBitmapFrameEncode*
/// The frame encoder to which the image is written.
///
///
/// Type: const WICImageParameters*
/// Additional parameters to control encoding.
///
///
///
/// The image passed in must be created on the same device as in IWICImagingFactory2::CreateImageEncoder. If the
/// pImageParameters are not specified, a set of useful defaults will be assumed, see WICImageParameters for more info.
///
/// You must correctly and independently have set up the IWICBitmapFrameEncode before calling this API.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimageencoder-writeframe HRESULT WriteFrame(
// ID2D1Image *pImage, IWICBitmapFrameEncode *pFrameEncode, const WICImageParameters *pImageParameters );
void WriteFrame(ID2D1Image pImage, IWICBitmapFrameEncode pFrameEncode, in WICImageParameters pImageParameters);
/// Encodes the image as a thumbnail to the frame given by the IWICBitmapFrameEncode.
///
/// Type: ID2D1Image*
/// The Direct2D image that will be encoded.
///
///
/// Type: IWICBitmapFrameEncode*
/// The frame encoder on which the thumbnail is set.
///
///
/// Type: const WICImageParameters*
/// Additional parameters to control encoding.
///
///
///
/// The image passed in must be created on the same device as in IWICImagingFactory2::CreateImageEncoder. If the
/// pImageParameters are not specified, a set of useful defaults will be assumed, see WICImageParameters for more info.
///
/// You must correctly and independently have set up the IWICBitmapFrameEncode before calling this API.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimageencoder-writeframethumbnail HRESULT
// WriteFrameThumbnail( ID2D1Image *pImage, IWICBitmapFrameEncode *pFrameEncode, const WICImageParameters *pImageParameters );
void WriteFrameThumbnail(ID2D1Image pImage, IWICBitmapFrameEncode pFrameEncode, in WICImageParameters pImageParameters);
/// Encodes the given image as the thumbnail to the given WIC bitmap encoder.
///
/// Type: ID2D1Image*
/// The Direct2D image that will be encoded.
///
///
/// Type: IWICBitmapEncoder*
/// The encoder on which the thumbnail is set.
///
///
/// Type: const WICImageParameters*
/// Additional parameters to control encoding.
///
///
///
/// You must create the image that you pass in on the same device as in IWICImagingFactory2::CreateImageEncoder. If you don't
/// specify additional parameters in the variable that pImageParameters points to, the encoder uses a set of useful defaults.
/// For info about these defaults, see WICImageParameters.
///
///
/// Before you call WriteThumbnail, you must set up the IWICBitmapEncoder interface for the encoder on which you want to
/// set the thumbnail.
///
///
/// If WriteThumbnail fails, it might return E_OUTOFMEMORY, D2DERR_WRONG_RESOURCE_DOMAIN, or other error codes from the encoder.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimageencoder-writethumbnail HRESULT
// WriteThumbnail( ID2D1Image *pImage, IWICBitmapEncoder *pEncoder, const WICImageParameters *pImageParameters );
void WriteThumbnail(ID2D1Image pImage, IWICBitmapEncoder pEncoder, in WICImageParameters pImageParameters);
}
///
/// Exposes methods used to create components for the Windows Imaging Component (WIC) such as decoders, encoders and pixel format converters.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicimagingfactory
[PInvokeData("wincodec.h", MSDNShortId = "30d155b1-a46c-46c4-9f8f-fb56dc6bf0a9")]
[ComImport, Guid("ec5ec8a9-c395-4314-9c77-54d7a935ff70"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICImagingFactory
{
/// Creates a new instance of the IWICBitmapDecoder class based on the given file.
///
/// Type: LPCWSTR
/// A pointer to a null-terminated string that specifies the name of an object to create or open.
///
///
/// Type: const GUID*
/// The GUID for the preferred decoder vendor. Use default if no preferred vendor.
///
///
/// Type: DWORD
/// The access to the object, which can be read, write, or both.
///
///
/// Value
/// Meaning
///
/// -
/// GENERIC_READ
/// Read access.
///
/// -
/// GENERIC_WRITE
/// Write access.
///
///
/// For more information, see Generic Access Rights.
///
///
/// Type: WICDecodeOptions
/// The WICDecodeOptions to use when creating the decoder.
///
///
/// Type: IWICBitmapDecoder**
/// A pointer that receives a pointer to the new IWICBitmapDecoder.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createdecoderfromfilename HRESULT
// CreateDecoderFromFilename( LPCWSTR wzFilename, const GUID *pguidVendor, DWORD dwDesiredAccess, WICDecodeOptions
// metadataOptions, IWICBitmapDecoder **ppIDecoder );
IWICBitmapDecoder CreateDecoderFromFilename([MarshalAs(UnmanagedType.LPWStr)] string wzFilename, [In] SafeGuidPtr pguidVendor, ACCESS_MASK dwDesiredAccess, WICDecodeOptions metadataOptions);
/// Creates a new instance of the IWICBitmapDecoder class based on the given IStream.
///
/// Type: IStream*
/// The stream to create the decoder from.
///
///
/// Type: const GUID*
/// The GUID for the preferred decoder vendor. Use default if no preferred vendor.
///
///
/// Type: WICDecodeOptions
/// The WICDecodeOptions to use when creating the decoder.
///
///
/// Type: IWICBitmapDecoder**
/// A pointer that receives a pointer to a new IWICBitmapDecoder.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createdecoderfromstream HRESULT
// CreateDecoderFromStream( IStream *pIStream, const GUID *pguidVendor, WICDecodeOptions metadataOptions, IWICBitmapDecoder
// **ppIDecoder );
IWICBitmapDecoder CreateDecoderFromStream(IStream pIStream, [In] SafeGuidPtr pguidVendor, WICDecodeOptions metadataOptions);
/// Creates a new instance of the IWICBitmapDecoder based on the given file handle.
///
/// Type: ULONG_PTR
/// The file handle to create the decoder from.
///
///
/// Type: const GUID*
/// The GUID for the preferred decoder vendor. Use default if no preferred vendor.
///
///
/// Type: WICDecodeOptions
/// The WICDecodeOptions to use when creating the decoder.
///
///
/// Type: IWICBitmapDecoder**
/// A pointer that receives a pointer to a new IWICBitmapDecoder.
///
/// When a decoder is created using this method, the file handle must remain alive during the lifetime of the decoder.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createdecoderfromfilehandle
// HRESULT CreateDecoderFromFileHandle( ULONG_PTR hFile, const GUID *pguidVendor, WICDecodeOptions metadataOptions,
// IWICBitmapDecoder **ppIDecoder );
IWICBitmapDecoder CreateDecoderFromFileHandle(HFILE hFile, [In] SafeGuidPtr pguidVendor, WICDecodeOptions metadataOptions);
/// Creates a new instance of the IWICComponentInfo class for the given component class identifier (CLSID).
///
/// Type: REFCLSID
/// The CLSID for the desired component.
///
///
/// Type: IWICComponentInfo**
/// A pointer that receives a pointer to a new IWICComponentInfo.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcomponentinfo HRESULT
// CreateComponentInfo( REFCLSID clsidComponent, IWICComponentInfo **ppIInfo );
IWICComponentInfo CreateComponentInfo(in Guid clsidComponent);
/// Creates a new instance of IWICBitmapDecoder.
///
/// Type: REFGUID
/// The GUID for the desired container format.
///
///
/// Value
/// Meaning
///
/// -
/// GUID_ContainerFormatBmp
/// The BMP container format GUID.
///
/// -
/// GUID_ContainerFormatPng
/// The PNG container format GUID.
///
/// -
/// GUID_ContainerFormatIco
/// The ICO container format GUID.
///
/// -
/// GUID_ContainerFormatJpeg
/// The JPEG container format GUID.
///
/// -
/// GUID_ContainerFormatTiff
/// The TIFF container format GUID.
///
/// -
/// GUID_ContainerFormatGif
/// The GIF container format GUID.
///
/// -
/// GUID_ContainerFormatWmp
/// The HD Photo container format GUID.
///
///
///
///
/// Type: const GUID*
/// The GUID for the preferred encoder vendor.
///
///
/// Value
/// Meaning
///
/// -
/// SafeGuidPtr.Null
/// No preferred codec vendor.
///
/// -
/// GUID_VendorMicrosoft
/// Prefer to use Microsoft encoder.
///
/// -
/// GUID_VendorMicrosoftBuiltIn
/// Prefer to use the native Microsoft encoder.
///
///
///
///
/// Type: IWICBitmapDecoder**
///
/// A pointer that receives a pointer to a new IWICBitmapDecoder. You must initialize this IWICBitmapDecoder on a stream
/// using the Initialize method later.
///
///
///
/// Other values may be available for both guidContainerFormat and pguidVendor depending on the installed WIC-enabled encoders.
/// The values listed are those that are natively supported by the operating system.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createdecoder HRESULT
// CreateDecoder( REFGUID guidContainerFormat, const GUID *pguidVendor, IWICBitmapDecoder **ppIDecoder );
IWICBitmapDecoder CreateDecoder(in Guid guidContainerFormat, [In] SafeGuidPtr pguidVendor);
/// Creates a new instance of the IWICBitmapEncoder class.
///
/// Type: REFGUID
/// The GUID for the desired container format.
///
///
/// Value
/// Meaning
///
/// -
/// GUID_ContainerFormatBmp
/// The BMP container format GUID.
///
/// -
/// GUID_ContainerFormatPng
/// The PNG container format GUID.
///
/// -
/// GUID_ContainerFormatIco
/// The ICO container format GUID.
///
/// -
/// GUID_ContainerFormatJpeg
/// The JPEG container format GUID.
///
/// -
/// GUID_ContainerFormatTiff
/// The TIFF container format GUID.
///
/// -
/// GUID_ContainerFormatGif
/// The GIF container format GUID.
///
/// -
/// GUID_ContainerFormatWmp
/// The HD Photo container format GUID.
///
///
///
///
/// Type: const GUID*
/// The GUID for the preferred encoder vendor.
///
///
/// Value
/// Meaning
///
/// -
/// SafeGuidPtr.Null
/// No preferred codec vendor.
///
/// -
/// GUID_VendorMicrosoft
/// Prefer to use Microsoft encoder.
///
/// -
/// GUID_VendorMicrosoftBuiltIn
/// Prefer to use the native Microsoft encoder.
///
///
///
///
/// Type: IWICBitmapEncoder**
/// A pointer that receives a pointer to a new IWICBitmapEncoder.
///
///
/// Other values may be available for both guidContainerFormat and pguidVendor depending on the installed WIC-enabled encoders.
/// The values listed are those that are natively supported by the operating system.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createencoder HRESULT
// CreateEncoder( REFGUID guidContainerFormat, const GUID *pguidVendor, IWICBitmapEncoder **ppIEncoder );
IWICBitmapDecoder CreateEncoder(in Guid guidContainerFormat, [In] SafeGuidPtr pguidVendor);
/// Creates a new instance of the IWICPalette class.
///
/// Type: IWICPalette**
/// A pointer that receives a pointer to a new IWICPalette.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createpalette HRESULT
// CreatePalette( IWICPalette **ppIPalette );
IWICPalette CreatePalette();
/// Creates a new instance of the IWICFormatConverter class.
///
/// Type: IWICFormatConverter**
/// A pointer that receives a pointer to a new IWICFormatConverter.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createformatconverter HRESULT
// CreateFormatConverter( IWICFormatConverter **ppIFormatConverter );
IWICFormatConverter CreateFormatConverter();
/// Creates a new instance of an IWICBitmapScaler.
///
/// Type: IWICBitmapScaler**
/// A pointer that receives a pointer to a new IWICBitmapScaler.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapscaler HRESULT
// CreateBitmapScaler( IWICBitmapScaler **ppIBitmapScaler );
IWICBitmapScaler CreateBitmapScaler();
/// Creates a new instance of an IWICBitmapClipper object.
///
/// Type: IWICBitmapClipper**
/// A pointer that receives a pointer to a new IWICBitmapClipper.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapclipper HRESULT
// CreateBitmapClipper( IWICBitmapClipper **ppIBitmapClipper );
IWICBitmapClipper CreateBitmapClipper();
/// Creates a new instance of an IWICBitmapFlipRotator object.
///
/// Type: IWICBitmapFlipRotator**
/// A pointer that receives a pointer to a new IWICBitmapFlipRotator.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfliprotator HRESULT
// CreateBitmapFlipRotator( IWICBitmapFlipRotator **ppIBitmapFlipRotator );
IWICBitmapFlipRotator CreateBitmapFlipRotator();
/// Creates a new instance of the IWICStream class.
///
/// Type: IWICStream**
/// A pointer that receives a pointer to a new IWICStream.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createstream HRESULT CreateStream(
// IWICStream **ppIWICStream );
IWICStream CreateStream();
/// Creates a new instance of the IWICColorContext class.
///
/// Type: IWICColorContext**
/// A pointer that receives a pointer to a new IWICColorContext.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcolorcontext HRESULT
// CreateColorContext( IWICColorContext **ppIWICColorContext );
IWICColorContext CreateColorContext();
/// Creates a new instance of the IWICColorTransform class.
///
/// Type: IWICColorTransform**
/// A pointer that receives a pointer to a new IWICColorTransform.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcolortransformer HRESULT
// CreateColorTransformer( IWICColorTransform **ppIWICColorTransform );
IWICColorTransform CreateColorTransformer();
/// Creates an IWICBitmap object.
///
/// Type: UINT
/// The width of the new bitmap .
///
///
/// Type: UINT
/// The height of the new bitmap.
///
///
/// Type: in Guid
/// The pixel format of the new bitmap.
///
///
/// Type: WICBitmapCreateCacheOption
/// The cache creation options of the new bitmap. This can be one of the values in the WICBitmapCreateCacheOption enumeration.
///
///
/// Value
/// Meaning
///
/// -
/// WICBitmapCacheOnDemand
/// Allocates system memory for the bitmap at initialization.
///
/// -
/// WICBitmapCacheOnLoad
/// Allocates system memory for the bitmap when the bitmap is first used.
///
/// -
/// WICBitmapNoCache
/// This option is not valid for this method and should not be used.
///
///
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmap HRESULT CreateBitmap(
// UINT uiWidth, UINT uiHeight, in Guid pixelFormat, WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap );
IWICBitmap CreateBitmap(uint uiWidth, uint uiHeight, in Guid pixelFormat, WICBitmapCreateCacheOption option);
/// Creates a IWICBitmap from a IWICBitmapSource.
///
/// Type: IWICBitmapSource*
/// The IWICBitmapSource to create the bitmap from.
///
///
/// Type: WICBitmapCreateCacheOption
/// The cache options of the new bitmap. This can be one of the values in the WICBitmapCreateCacheOption enumeration.
///
///
/// Value
/// Meaning
///
/// -
/// WICBitmapNoCache
/// Do not create a system memory copy. Share the bitmap with the source.
///
/// -
/// WICBitmapCacheOnDemand
/// Create a system memory copy when the bitmap is first used.
///
/// -
/// WICBitmapCacheOnLoad
/// Create a system memory copy when this method is called.
///
///
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfromsource HRESULT
// CreateBitmapFromSource( IWICBitmapSource *pIBitmapSource, WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap );
IWICBitmap CreateBitmapFromSource(IWICBitmapSource pIBitmapSource, WICBitmapCreateCacheOption option);
/// Creates an IWICBitmap from a specified rectangle of an IWICBitmapSource.
///
/// Type: IWICBitmapSource*
/// The IWICBitmapSource to create the bitmap from.
///
///
/// Type: UINT
/// The horizontal coordinate of the upper-left corner of the rectangle.
///
///
/// Type: UINT
/// The vertical coordinate of the upper-left corner of the rectangle.
///
///
/// Type: UINT
/// The width of the rectangle and the new bitmap.
///
///
/// Type: UINT
/// The height of the rectangle and the new bitmap.
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
///
/// Providing a rectangle that is larger than the source will produce undefined results.
/// This method always creates a separate copy of the source image, similar to the cache option WICBitmapCacheOnLoad.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfromsourcerect HRESULT
// CreateBitmapFromSourceRect( IWICBitmapSource *pIBitmapSource, UINT x, UINT y, UINT width, UINT height, IWICBitmap **ppIBitmap );
IWICBitmap CreateBitmapFromSourceRect(IWICBitmapSource pIBitmapSource, uint x, uint y, uint width, uint height);
/// Creates an IWICBitmap from a memory block.
///
/// Type: UINT
/// The width of the new bitmap.
///
///
/// Type: UINT
/// The height of the new bitmap.
///
///
/// Type: in Guid
/// The pixel format of the new bitmap. For valid pixel formats, see Native Pixel Formats.
///
///
/// Type: UINT
/// The number of bytes between successive scanlines in pbBuffer.
///
///
/// Type: UINT
/// The size of pbBuffer.
///
///
/// Type: BYTE*
/// The buffer used to create the bitmap.
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
///
/// The size of the IWICBitmap to be created must be smaller than or equal to the size of the image in pbBuffer.
///
/// The stride of the destination bitmap will equal the stride of the source data, regardless of the width and height specified.
///
/// The pixelFormat parameter defines the pixel format for both the input data and the output bitmap.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfrommemory HRESULT
// CreateBitmapFromMemory( UINT uiWidth, UINT uiHeight, in Guid pixelFormat, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer,
// IWICBitmap **ppIBitmap );
IWICBitmap CreateBitmapFromMemory(uint uiWidth, uint uiHeight, in Guid pixelFormat, uint cbStride, uint cbBufferSize, [In] IntPtr pbBuffer);
/// Creates an IWICBitmap from a bitmap handle.
///
/// Type: HBITMAP
/// A bitmap handle to create the bitmap from.
///
///
/// Type: HPALETTE
/// A palette handle used to create the bitmap.
///
///
/// Type: WICBitmapAlphaChannelOption
/// The alpha channel options to create the bitmap.
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
/// For a non-palletized bitmap, set NULL for the hPalette parameter.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfromhbitmap HRESULT
// CreateBitmapFromHBITMAP( HBITMAP hBitmap, HPALETTE hPalette, WICBitmapAlphaChannelOption options, IWICBitmap **ppIBitmap );
IWICBitmap CreateBitmapFromHBITMAP(HBITMAP hBitmap, [Optional] HPALETTE hPalette, WICBitmapAlphaChannelOption options);
/// Creates an IWICBitmap from an icon handle.
///
/// Type: HICON
/// The icon handle to create the new bitmap from.
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfromhicon HRESULT
// CreateBitmapFromHICON( HICON hIcon, IWICBitmap **ppIBitmap );
IWICBitmap CreateBitmapFromHICON(HICON hIcon);
/// Creates an IEnumUnknown object of the specified component types.
///
/// Type: DWORD
/// The types of WICComponentType to enumerate.
///
///
/// Type: DWORD
/// The WICComponentEnumerateOptions used to enumerate the given component types.
///
///
/// Type: IEnumUnknown**
/// A pointer that receives a pointer to a new component enumerator.
///
///
/// Component types must be enumerated seperately. Combinations of component types and WICAllComponents are unsupported.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcomponentenumerator HRESULT
// CreateComponentEnumerator( DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown );
IEnumUnknown CreateComponentEnumerator(WICComponentType componentTypes, WICComponentEnumerateOptions options);
/// Creates a new instance of the fast metadata encoder based on the given IWICBitmapDecoder.
///
/// Type: IWICBitmapDecoder*
/// The decoder to create the fast metadata encoder from.
///
///
/// Type: IWICFastMetadataEncoder**
/// When this method returns, contains a pointer to the new IWICFastMetadataEncoder.
///
///
/// The Windows provided codecs do not support fast metadata encoding at the decoder level, and only support fast metadata
/// encoding at the frame level. To create a fast metadata encoder from a frame, see CreateFastMetadataEncoderFromFrameDecode.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createfastmetadataencoderfromdecoder
// HRESULT CreateFastMetadataEncoderFromDecoder( IWICBitmapDecoder *pIDecoder, IWICFastMetadataEncoder **ppIFastEncoder );
IWICFastMetadataEncoder CreateFastMetadataEncoderFromDecoder(IWICBitmapDecoder pIDecoder);
/// Creates a new instance of the fast metadata encoder based on the given image frame.
///
/// Type: IWICBitmapFrameDecode*
/// The IWICBitmapFrameDecode to create the IWICFastMetadataEncoder from.
///
///
/// Type: IWICFastMetadataEncoder**
/// When this method returns, contains a pointer to a new fast metadata encoder.
///
///
/// For a list of support metadata formats for fast metadata encoding, see WIC Metadata Overview.
/// Examples
///
/// The following code demonstrates how to use the CreateFastMetadataEncoderFromFrameDecode method for fast metadata encoding.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createfastmetadataencoderfromframedecode
// HRESULT CreateFastMetadataEncoderFromFrameDecode( IWICBitmapFrameDecode *pIFrameDecoder, IWICFastMetadataEncoder
// **ppIFastEncoder );
IWICFastMetadataEncoder CreateFastMetadataEncoderFromFrameDecode(IWICBitmapFrameDecode pIFrameDecoder);
/// Creates a new instance of a query writer.
///
/// Type: REFGUID
/// The GUID for the desired metadata format.
///
///
/// Type: const GUID*
/// The GUID for the preferred metadata writer vendor. Use NULL if no preferred vendor.
///
///
/// Type: IWICMetadataQueryWriter**
/// When this method returns, contains a pointer to a new IWICMetadataQueryWriter.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createquerywriter HRESULT
// CreateQueryWriter( REFGUID guidMetadataFormat, const GUID *pguidVendor, IWICMetadataQueryWriter **ppIQueryWriter );
IWICMetadataQueryWriter CreateQueryWriter(in Guid guidMetadataFormat, [In] SafeGuidPtr pguidVendor);
///
/// Creates a new instance of a query writer based on the given query reader. The query writer will be pre-populated with
/// metadata from the query reader.
///
///
/// Type: IWICMetadataQueryReader*
/// The IWICMetadataQueryReader to create the IWICMetadataQueryWriter from.
///
///
/// Type: const GUID*
/// The GUID for the preferred metadata writer vendor. Use NULL if no preferred vendor.
///
///
/// Type: IWICMetadataQueryWriter**
/// When this method returns, contains a pointer to a new metadata writer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createquerywriterfromreader
// HRESULT CreateQueryWriterFromReader( IWICMetadataQueryReader *pIQueryReader, const GUID *pguidVendor, IWICMetadataQueryWriter
// **ppIQueryWriter );
IWICMetadataQueryWriter CreateQueryWriterFromReader(IWICMetadataQueryReader pIQueryReader, [In] SafeGuidPtr pguidVendor);
}
///
/// An extension of the WIC factory interface that includes the ability to create an IWICImageEncoder. This interface uses a
/// Direct2D device and an input image to encode to a destination IWICBitmapEncoder.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicimagingfactory2
[PInvokeData("wincodec.h", MSDNShortId = "95F64E01-6174-4C1C-B0BE-331380E583C2")]
[ComImport, Guid("7B816B45-1996-4476-B132-DE9E247C8AF0"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICImagingFactory2 : IWICImagingFactory
{
/// Creates a new instance of the IWICBitmapDecoder class based on the given file.
///
/// Type: LPCWSTR
/// A pointer to a null-terminated string that specifies the name of an object to create or open.
///
///
/// Type: const GUID*
/// The GUID for the preferred decoder vendor. Use default if no preferred vendor.
///
///
/// Type: DWORD
/// The access to the object, which can be read, write, or both.
///
///
/// Value
/// Meaning
///
/// -
/// GENERIC_READ
/// Read access.
///
/// -
/// GENERIC_WRITE
/// Write access.
///
///
/// For more information, see Generic Access Rights.
///
///
/// Type: WICDecodeOptions
/// The WICDecodeOptions to use when creating the decoder.
///
///
/// Type: IWICBitmapDecoder**
/// A pointer that receives a pointer to the new IWICBitmapDecoder.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createdecoderfromfilename HRESULT
// CreateDecoderFromFilename( LPCWSTR wzFilename, const GUID *pguidVendor, DWORD dwDesiredAccess, WICDecodeOptions
// metadataOptions, IWICBitmapDecoder **ppIDecoder );
new IWICBitmapDecoder CreateDecoderFromFilename([MarshalAs(UnmanagedType.LPWStr)] string wzFilename, [In] SafeGuidPtr pguidVendor, ACCESS_MASK dwDesiredAccess, WICDecodeOptions metadataOptions);
/// Creates a new instance of the IWICBitmapDecoder class based on the given IStream.
///
/// Type: IStream*
/// The stream to create the decoder from.
///
///
/// Type: const GUID*
/// The GUID for the preferred decoder vendor. Use default if no preferred vendor.
///
///
/// Type: WICDecodeOptions
/// The WICDecodeOptions to use when creating the decoder.
///
///
/// Type: IWICBitmapDecoder**
/// A pointer that receives a pointer to a new IWICBitmapDecoder.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createdecoderfromstream HRESULT
// CreateDecoderFromStream( IStream *pIStream, const GUID *pguidVendor, WICDecodeOptions metadataOptions, IWICBitmapDecoder
// **ppIDecoder );
new IWICBitmapDecoder CreateDecoderFromStream(IStream pIStream, [In] SafeGuidPtr pguidVendor, WICDecodeOptions metadataOptions);
/// Creates a new instance of the IWICBitmapDecoder based on the given file handle.
///
/// Type: ULONG_PTR
/// The file handle to create the decoder from.
///
///
/// Type: const GUID*
/// The GUID for the preferred decoder vendor. Use default if no preferred vendor.
///
///
/// Type: WICDecodeOptions
/// The WICDecodeOptions to use when creating the decoder.
///
///
/// Type: IWICBitmapDecoder**
/// A pointer that receives a pointer to a new IWICBitmapDecoder.
///
/// When a decoder is created using this method, the file handle must remain alive during the lifetime of the decoder.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createdecoderfromfilehandle
// HRESULT CreateDecoderFromFileHandle( ULONG_PTR hFile, const GUID *pguidVendor, WICDecodeOptions metadataOptions,
// IWICBitmapDecoder **ppIDecoder );
new IWICBitmapDecoder CreateDecoderFromFileHandle(HFILE hFile, [In] SafeGuidPtr pguidVendor, WICDecodeOptions metadataOptions);
/// Creates a new instance of the IWICComponentInfo class for the given component class identifier (CLSID).
///
/// Type: REFCLSID
/// The CLSID for the desired component.
///
///
/// Type: IWICComponentInfo**
/// A pointer that receives a pointer to a new IWICComponentInfo.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcomponentinfo HRESULT
// CreateComponentInfo( REFCLSID clsidComponent, IWICComponentInfo **ppIInfo );
new IWICComponentInfo CreateComponentInfo(in Guid clsidComponent);
/// Creates a new instance of IWICBitmapDecoder.
///
/// Type: REFGUID
/// The GUID for the desired container format.
///
///
/// Value
/// Meaning
///
/// -
/// GUID_ContainerFormatBmp
/// The BMP container format GUID.
///
/// -
/// GUID_ContainerFormatPng
/// The PNG container format GUID.
///
/// -
/// GUID_ContainerFormatIco
/// The ICO container format GUID.
///
/// -
/// GUID_ContainerFormatJpeg
/// The JPEG container format GUID.
///
/// -
/// GUID_ContainerFormatTiff
/// The TIFF container format GUID.
///
/// -
/// GUID_ContainerFormatGif
/// The GIF container format GUID.
///
/// -
/// GUID_ContainerFormatWmp
/// The HD Photo container format GUID.
///
///
///
///
/// Type: const GUID*
/// The GUID for the preferred encoder vendor.
///
///
/// Value
/// Meaning
///
/// -
/// SafeGuidPtr.Null
/// No preferred codec vendor.
///
/// -
/// GUID_VendorMicrosoft
/// Prefer to use Microsoft encoder.
///
/// -
/// GUID_VendorMicrosoftBuiltIn
/// Prefer to use the native Microsoft encoder.
///
///
///
///
/// Type: IWICBitmapDecoder**
///
/// A pointer that receives a pointer to a new IWICBitmapDecoder. You must initialize this IWICBitmapDecoder on a stream
/// using the Initialize method later.
///
///
///
/// Other values may be available for both guidContainerFormat and pguidVendor depending on the installed WIC-enabled encoders.
/// The values listed are those that are natively supported by the operating system.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createdecoder HRESULT
// CreateDecoder( REFGUID guidContainerFormat, const GUID *pguidVendor, IWICBitmapDecoder **ppIDecoder );
new IWICBitmapDecoder CreateDecoder(in Guid guidContainerFormat, [In] SafeGuidPtr pguidVendor);
/// Creates a new instance of the IWICBitmapEncoder class.
///
/// Type: REFGUID
/// The GUID for the desired container format.
///
///
/// Value
/// Meaning
///
/// -
/// GUID_ContainerFormatBmp
/// The BMP container format GUID.
///
/// -
/// GUID_ContainerFormatPng
/// The PNG container format GUID.
///
/// -
/// GUID_ContainerFormatIco
/// The ICO container format GUID.
///
/// -
/// GUID_ContainerFormatJpeg
/// The JPEG container format GUID.
///
/// -
/// GUID_ContainerFormatTiff
/// The TIFF container format GUID.
///
/// -
/// GUID_ContainerFormatGif
/// The GIF container format GUID.
///
/// -
/// GUID_ContainerFormatWmp
/// The HD Photo container format GUID.
///
///
///
///
/// Type: const GUID*
/// The GUID for the preferred encoder vendor.
///
///
/// Value
/// Meaning
///
/// -
/// SafeGuidPtr.Null
/// No preferred codec vendor.
///
/// -
/// GUID_VendorMicrosoft
/// Prefer to use Microsoft encoder.
///
/// -
/// GUID_VendorMicrosoftBuiltIn
/// Prefer to use the native Microsoft encoder.
///
///
///
///
/// Type: IWICBitmapEncoder**
/// A pointer that receives a pointer to a new IWICBitmapEncoder.
///
///
/// Other values may be available for both guidContainerFormat and pguidVendor depending on the installed WIC-enabled encoders.
/// The values listed are those that are natively supported by the operating system.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createencoder HRESULT
// CreateEncoder( REFGUID guidContainerFormat, const GUID *pguidVendor, IWICBitmapEncoder **ppIEncoder );
new IWICBitmapDecoder CreateEncoder(in Guid guidContainerFormat, [In] SafeGuidPtr pguidVendor);
/// Creates a new instance of the IWICPalette class.
///
/// Type: IWICPalette**
/// A pointer that receives a pointer to a new IWICPalette.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createpalette HRESULT
// CreatePalette( IWICPalette **ppIPalette );
new IWICPalette CreatePalette();
/// Creates a new instance of the IWICFormatConverter class.
///
/// Type: IWICFormatConverter**
/// A pointer that receives a pointer to a new IWICFormatConverter.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createformatconverter HRESULT
// CreateFormatConverter( IWICFormatConverter **ppIFormatConverter );
new IWICFormatConverter CreateFormatConverter();
/// Creates a new instance of an IWICBitmapScaler.
///
/// Type: IWICBitmapScaler**
/// A pointer that receives a pointer to a new IWICBitmapScaler.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapscaler HRESULT
// CreateBitmapScaler( IWICBitmapScaler **ppIBitmapScaler );
new IWICBitmapScaler CreateBitmapScaler();
/// Creates a new instance of an IWICBitmapClipper object.
///
/// Type: IWICBitmapClipper**
/// A pointer that receives a pointer to a new IWICBitmapClipper.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapclipper HRESULT
// CreateBitmapClipper( IWICBitmapClipper **ppIBitmapClipper );
new IWICBitmapClipper CreateBitmapClipper();
/// Creates a new instance of an IWICBitmapFlipRotator object.
///
/// Type: IWICBitmapFlipRotator**
/// A pointer that receives a pointer to a new IWICBitmapFlipRotator.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfliprotator HRESULT
// CreateBitmapFlipRotator( IWICBitmapFlipRotator **ppIBitmapFlipRotator );
new IWICBitmapFlipRotator CreateBitmapFlipRotator();
/// Creates a new instance of the IWICStream class.
///
/// Type: IWICStream**
/// A pointer that receives a pointer to a new IWICStream.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createstream HRESULT CreateStream(
// IWICStream **ppIWICStream );
new IWICStream CreateStream();
/// Creates a new instance of the IWICColorContext class.
///
/// Type: IWICColorContext**
/// A pointer that receives a pointer to a new IWICColorContext.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcolorcontext HRESULT
// CreateColorContext( IWICColorContext **ppIWICColorContext );
new IWICColorContext CreateColorContext();
/// Creates a new instance of the IWICColorTransform class.
///
/// Type: IWICColorTransform**
/// A pointer that receives a pointer to a new IWICColorTransform.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcolortransformer HRESULT
// CreateColorTransformer( IWICColorTransform **ppIWICColorTransform );
new IWICColorTransform CreateColorTransformer();
/// Creates an IWICBitmap object.
///
/// Type: UINT
/// The width of the new bitmap .
///
///
/// Type: UINT
/// The height of the new bitmap.
///
///
/// Type: in Guid
/// The pixel format of the new bitmap.
///
///
/// Type: WICBitmapCreateCacheOption
/// The cache creation options of the new bitmap. This can be one of the values in the WICBitmapCreateCacheOption enumeration.
///
///
/// Value
/// Meaning
///
/// -
/// WICBitmapCacheOnDemand
/// Allocates system memory for the bitmap at initialization.
///
/// -
/// WICBitmapCacheOnLoad
/// Allocates system memory for the bitmap when the bitmap is first used.
///
/// -
/// WICBitmapNoCache
/// This option is not valid for this method and should not be used.
///
///
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmap HRESULT CreateBitmap(
// UINT uiWidth, UINT uiHeight, in Guid pixelFormat, WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap );
new IWICBitmap CreateBitmap(uint uiWidth, uint uiHeight, in Guid pixelFormat, WICBitmapCreateCacheOption option);
/// Creates a IWICBitmap from a IWICBitmapSource.
///
/// Type: IWICBitmapSource*
/// The IWICBitmapSource to create the bitmap from.
///
///
/// Type: WICBitmapCreateCacheOption
/// The cache options of the new bitmap. This can be one of the values in the WICBitmapCreateCacheOption enumeration.
///
///
/// Value
/// Meaning
///
/// -
/// WICBitmapNoCache
/// Do not create a system memory copy. Share the bitmap with the source.
///
/// -
/// WICBitmapCacheOnDemand
/// Create a system memory copy when the bitmap is first used.
///
/// -
/// WICBitmapCacheOnLoad
/// Create a system memory copy when this method is called.
///
///
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfromsource HRESULT
// CreateBitmapFromSource( IWICBitmapSource *pIBitmapSource, WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap );
new IWICBitmap CreateBitmapFromSource(IWICBitmapSource pIBitmapSource, WICBitmapCreateCacheOption option);
/// Creates an IWICBitmap from a specified rectangle of an IWICBitmapSource.
///
/// Type: IWICBitmapSource*
/// The IWICBitmapSource to create the bitmap from.
///
///
/// Type: UINT
/// The horizontal coordinate of the upper-left corner of the rectangle.
///
///
/// Type: UINT
/// The vertical coordinate of the upper-left corner of the rectangle.
///
///
/// Type: UINT
/// The width of the rectangle and the new bitmap.
///
///
/// Type: UINT
/// The height of the rectangle and the new bitmap.
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
///
/// Providing a rectangle that is larger than the source will produce undefined results.
/// This method always creates a separate copy of the source image, similar to the cache option WICBitmapCacheOnLoad.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfromsourcerect HRESULT
// CreateBitmapFromSourceRect( IWICBitmapSource *pIBitmapSource, UINT x, UINT y, UINT width, UINT height, IWICBitmap **ppIBitmap );
new IWICBitmap CreateBitmapFromSourceRect(IWICBitmapSource pIBitmapSource, uint x, uint y, uint width, uint height);
/// Creates an IWICBitmap from a memory block.
///
/// Type: UINT
/// The width of the new bitmap.
///
///
/// Type: UINT
/// The height of the new bitmap.
///
///
/// Type: in Guid
/// The pixel format of the new bitmap. For valid pixel formats, see Native Pixel Formats.
///
///
/// Type: UINT
/// The number of bytes between successive scanlines in pbBuffer.
///
///
/// Type: UINT
/// The size of pbBuffer.
///
///
/// Type: BYTE*
/// The buffer used to create the bitmap.
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
///
/// The size of the IWICBitmap to be created must be smaller than or equal to the size of the image in pbBuffer.
///
/// The stride of the destination bitmap will equal the stride of the source data, regardless of the width and height specified.
///
/// The pixelFormat parameter defines the pixel format for both the input data and the output bitmap.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfrommemory HRESULT
// CreateBitmapFromMemory( UINT uiWidth, UINT uiHeight, in Guid pixelFormat, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer,
// IWICBitmap **ppIBitmap );
new IWICBitmap CreateBitmapFromMemory(uint uiWidth, uint uiHeight, in Guid pixelFormat, uint cbStride, uint cbBufferSize, [In] IntPtr pbBuffer);
/// Creates an IWICBitmap from a bitmap handle.
///
/// Type: HBITMAP
/// A bitmap handle to create the bitmap from.
///
///
/// Type: HPALETTE
/// A palette handle used to create the bitmap.
///
///
/// Type: WICBitmapAlphaChannelOption
/// The alpha channel options to create the bitmap.
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
/// For a non-palletized bitmap, set NULL for the hPalette parameter.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfromhbitmap HRESULT
// CreateBitmapFromHBITMAP( HBITMAP hBitmap, HPALETTE hPalette, WICBitmapAlphaChannelOption options, IWICBitmap **ppIBitmap );
new IWICBitmap CreateBitmapFromHBITMAP(HBITMAP hBitmap, [Optional] HPALETTE hPalette, WICBitmapAlphaChannelOption options);
/// Creates an IWICBitmap from an icon handle.
///
/// Type: HICON
/// The icon handle to create the new bitmap from.
///
///
/// Type: IWICBitmap**
/// A pointer that receives a pointer to the new bitmap.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createbitmapfromhicon HRESULT
// CreateBitmapFromHICON( HICON hIcon, IWICBitmap **ppIBitmap );
new IWICBitmap CreateBitmapFromHICON(HICON hIcon);
/// Creates an IEnumUnknown object of the specified component types.
///
/// Type: DWORD
/// The types of WICComponentType to enumerate.
///
///
/// Type: DWORD
/// The WICComponentEnumerateOptions used to enumerate the given component types.
///
///
/// Type: IEnumUnknown**
/// A pointer that receives a pointer to a new component enumerator.
///
///
/// Component types must be enumerated seperately. Combinations of component types and WICAllComponents are unsupported.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcomponentenumerator HRESULT
// CreateComponentEnumerator( DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown );
new IEnumUnknown CreateComponentEnumerator(WICComponentType componentTypes, WICComponentEnumerateOptions options);
/// Creates a new instance of the fast metadata encoder based on the given IWICBitmapDecoder.
///
/// Type: IWICBitmapDecoder*
/// The decoder to create the fast metadata encoder from.
///
///
/// Type: IWICFastMetadataEncoder**
/// When this method returns, contains a pointer to the new IWICFastMetadataEncoder.
///
///
/// The Windows provided codecs do not support fast metadata encoding at the decoder level, and only support fast metadata
/// encoding at the frame level. To create a fast metadata encoder from a frame, see CreateFastMetadataEncoderFromFrameDecode.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createfastmetadataencoderfromdecoder
// HRESULT CreateFastMetadataEncoderFromDecoder( IWICBitmapDecoder *pIDecoder, IWICFastMetadataEncoder **ppIFastEncoder );
new IWICFastMetadataEncoder CreateFastMetadataEncoderFromDecoder(IWICBitmapDecoder pIDecoder);
/// Creates a new instance of the fast metadata encoder based on the given image frame.
///
/// Type: IWICBitmapFrameDecode*
/// The IWICBitmapFrameDecode to create the IWICFastMetadataEncoder from.
///
///
/// Type: IWICFastMetadataEncoder**
/// When this method returns, contains a pointer to a new fast metadata encoder.
///
///
/// For a list of support metadata formats for fast metadata encoding, see WIC Metadata Overview.
/// Examples
///
/// The following code demonstrates how to use the CreateFastMetadataEncoderFromFrameDecode method for fast metadata encoding.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createfastmetadataencoderfromframedecode
// HRESULT CreateFastMetadataEncoderFromFrameDecode( IWICBitmapFrameDecode *pIFrameDecoder, IWICFastMetadataEncoder
// **ppIFastEncoder );
new IWICFastMetadataEncoder CreateFastMetadataEncoderFromFrameDecode(IWICBitmapFrameDecode pIFrameDecoder);
/// Creates a new instance of a query writer.
///
/// Type: REFGUID
/// The GUID for the desired metadata format.
///
///
/// Type: const GUID*
/// The GUID for the preferred metadata writer vendor. Use NULL if no preferred vendor.
///
///
/// Type: IWICMetadataQueryWriter**
/// When this method returns, contains a pointer to a new IWICMetadataQueryWriter.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createquerywriter HRESULT
// CreateQueryWriter( REFGUID guidMetadataFormat, const GUID *pguidVendor, IWICMetadataQueryWriter **ppIQueryWriter );
new IWICMetadataQueryWriter CreateQueryWriter(in Guid guidMetadataFormat, [In] SafeGuidPtr pguidVendor);
///
/// Creates a new instance of a query writer based on the given query reader. The query writer will be pre-populated with
/// metadata from the query reader.
///
///
/// Type: IWICMetadataQueryReader*
/// The IWICMetadataQueryReader to create the IWICMetadataQueryWriter from.
///
///
/// Type: const GUID*
/// The GUID for the preferred metadata writer vendor. Use NULL if no preferred vendor.
///
///
/// Type: IWICMetadataQueryWriter**
/// When this method returns, contains a pointer to a new metadata writer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createquerywriterfromreader
// HRESULT CreateQueryWriterFromReader( IWICMetadataQueryReader *pIQueryReader, const GUID *pguidVendor, IWICMetadataQueryWriter
// **ppIQueryWriter );
new IWICMetadataQueryWriter CreateQueryWriterFromReader(IWICMetadataQueryReader pIQueryReader, [In] SafeGuidPtr pguidVendor);
/// Creates a new image encoder object.
/// The ID2D1Device object on which the corresponding image encoder is created.
///
/// A pointer to a variable that receives a pointer to the IWICImageEncoder interface for the encoder object that you can use to
/// encode Direct2D images.
///
///
/// You must create images to pass to the image encoder on the same Direct2D device that you pass to this method.
///
/// You are responsible for setting up the bitmap encoder itself through the existing IWICBitmapEncoder APIs. The
/// IWICBitmapEncoder or the IWICBitmapFrameEncode object is passed to each of the IWICImageEncoder methods:
/// WriteThumbnail, WriteFrame, and WriteFrameThumbnail.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory2-createimageencoder HRESULT
// CreateImageEncoder( ID2D1Device *pD2DDevice, IWICImageEncoder **ppWICImageEncoder );
IWICImageEncoder CreateImageEncoder(ID2D1Device pD2DDevice);
}
///
/// Exposes methods for decoding JPEG images. Provides access to the Start Of Frame (SOF) header, Start of Scan (SOS) header, the
/// Huffman and Quantization tables, and the compressed JPEG JPEG data. Also enables indexing for efficient random access.
///
///
/// Obtain this interface by calling IUnknown::QueryInterface on the Windows-provided IWICBitmapFrameDecoder interface for the JPEG decoder.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicjpegframedecode
[PInvokeData("wincodec.h", MSDNShortId = "E6310320-53A8-40F1-8964-D21D8054E1B8")]
[ComImport, Guid("8939F66E-C46A-4c21-A9D1-98B327CE1679"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICJpegFrameDecode
{
/// Retrieves a value indicating whether this decoder supports indexing for efficient random access.
///
/// Type: BOOL*
/// True if indexing is supported; otherwise, false.
///
/// Indexing is only supported for some JPEG types. Call this method
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframedecode-doessupportindexing HRESULT
// DoesSupportIndexing( BOOL *pfIndexingSupported );
[return: MarshalAs(UnmanagedType.Bool)]
bool DoesSupportIndexing();
/// Enables indexing of the JPEG for efficient random access.
///
/// Type: WICJpegIndexingOptions
/// A value specifying whether indexes should be generated immediately or deferred until a future call to IWICBitmapSource::CopyPixels.
///
///
/// Type: UINT
/// The granularity of the indexing, in pixels.
///
///
///
/// This method enables efficient random-access to the image pixels at the expense of memory usage. The amount of memory
/// required for indexing depends on the requested index granularity. Unless SetIndexing is called, it is much more
/// efficient to access a JPEG by progressing through its pixels top-down during calls to IWICBitmapSource::CopyPixels.
///
///
/// This method will fail if indexing is unsupported on the file. IWICJpegFrameDecode::DoesSupportIndexing should be called to
/// first determine whether indexing is supported. If this method is called multiple times, the final call changes the index
/// granularity to the requested size.
///
///
/// The provided interval size controls horizontal spacing of index entries. This value is internally rounded up according to
/// the JPEG’s MCU (minimum coded unit) size, which is typically either 8 or 16 unscaled pixels. The vertical size of the index
/// interval is always equal to one MCU size.
///
///
/// Indexes can be generated immediately, or during future calls to IWICBitmapSource::CopyPixels to reduce redundant
/// decompression work.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframedecode-setindexing HRESULT SetIndexing(
// WICJpegIndexingOptions options, UINT horizontalIntervalSize );
void SetIndexing(WICJpegIndexingOptions options, uint horizontalIntervalSize);
/// Removes the indexing from a JPEG that has been indexed using IWICJpegFrameDecode::SetIndexing.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframedecode-clearindexing HRESULT ClearIndexing();
void ClearIndexing();
/// Retrieves a copy of the AC Huffman table for the specified scan and table.
///
/// Type: UINT
/// The zero-based index of the scan for which data is retrieved.
///
///
/// Type: UINT
///
/// The index of the AC Huffman table to retrieve. Valid indices for a given scan can be determined by retrieving the scan
/// header with IWICJpegFrameDecode::GetScanHeader.
///
///
///
/// Type: DXGI_JPEG_AC_HUFFMAN_TABLE*
/// A pointer that receives the table data. This parameter must not be NULL.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframedecode-getachuffmantable HRESULT
// GetAcHuffmanTable( UINT scanIndex, UINT tableIndex, DXGI_JPEG_AC_HUFFMAN_TABLE *pAcHuffmanTable );
DXGI_JPEG_AC_HUFFMAN_TABLE GetAcHuffmanTable(uint scanIndex, uint tableIndex);
/// Retrieves a copy of the DC Huffman table for the specified scan and table.
///
/// Type: UINT
/// The zero-based index of the scan for which data is retrieved.
///
///
/// Type: UINT
///
/// The index of the DC Huffman table to retrieve. Valid indices for a given scan can be determined by retrieving the scan
/// header with IWICJpegFrameDecode::GetScanHeader.
///
///
///
/// Type: DXGI_JPEG_AC_HUFFMAN_TABLE*
/// A pointer that receives the table data. This parameter must not be NULL.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframedecode-getdchuffmantable HRESULT
// GetDcHuffmanTable( UINT scanIndex, UINT tableIndex, DXGI_JPEG_DC_HUFFMAN_TABLE *pDcHuffmanTable );
DXGI_JPEG_DC_HUFFMAN_TABLE GetDcHuffmanTable(uint scanIndex, uint tableIndex);
/// Retrieves a copy of the quantization table.
///
/// Type: UINT
/// The zero-based index of the scan for which data is retrieved.
///
///
/// Type: UINT
///
/// The index of the quantization table to retrieve. Valid indices for a given scan can be determined by retrieving the scan
/// header with IWICJpegFrameDecode::GetScanHeader.
///
///
///
/// Type: DXGI_JPEG_QUANTIZATION_TABLE*
/// A pointer that receives the table data. This parameter must not be NULL.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframedecode-getquantizationtable HRESULT
// GetQuantizationTable( UINT scanIndex, UINT tableIndex, DXGI_JPEG_QUANTIZATION_TABLE *pQuantizationTable );
DXGI_JPEG_QUANTIZATION_TABLE GetQuantizationTable(uint scanIndex, uint tableIndex);
///
/// Retrieves header data from the entire frame. The result includes parameters from the Start Of Frame (SOF) marker for the
/// scan as well as parameters derived from other metadata such as the color model of the compressed data.
///
///
/// Type: WICJpegFrameHeader*
/// A pointer that receives the frame header data.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframedecode-getframeheader HRESULT
// GetFrameHeader( WICJpegFrameHeader *pFrameHeader );
WICJpegFrameHeader GetFrameHeader();
/// Retrieves parameters from the Start Of Scan (SOS) marker for the scan with the specified index.
///
/// Type: UINT
/// The index of the scan for which header data is retrieved.
///
///
/// Type: WICJpegScanHeader*
/// A pointer that receives the frame header data.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframedecode-getscanheader HRESULT
// GetScanHeader( UINT scanIndex, WICJpegScanHeader *pScanHeader );
WICJpegScanHeader GetScanHeader(uint scanIndex);
/// Retrieves a copy of the compressed JPEG scan directly from the WIC decoder frame's output stream.
///
/// Type: UINT
/// The zero-based index of the scan for which data is retrieved.
///
///
/// Type: UINT
///
/// The byte position in the scan data to begin copying. Use 0 on the first call. If the output buffer size is insufficient to
/// store the entire scan, this offset allows you to resume copying from the end of the previous copy operation.
///
///
///
/// Type: UINT
/// The size, in bytes, of the pbScanData array.
///
///
/// Type: BYTE*
/// A pointer that receives the table data. This parameter must not be NULL.
///
///
/// Type: UINT*
///
/// A pointer that receives the size of the scan data actually copied into pbScanData. The size returned may be smaller that the
/// size of cbScanData. This parameter may be NULL.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframedecode-copyscan HRESULT CopyScan( UINT
// scanIndex, UINT scanOffset, UINT cbScanData, BYTE *pbScanData, UINT *pcbScanDataActual );
void CopyScan(uint scanIndex, uint scanOffset, uint cbScanData, [Out] IntPtr pbScanData, out uint pcbScanDataActual);
/// Undocumented
///
/// The byte position in the stream data to begin copying. Use 0 on the first call. If the output buffer size is insufficient to
/// store the entire stream, this offset allows you to resume copying from the end of the previous copy operation.
///
/// The size, in bytes, of the pbStreamData array..
/// A pointer that receives the stream data. This parameter must not be NULL.
///
/// A pointer that receives the size of the stream data actually copied into pbStreamData. The size returned may be smaller that
/// the size of cbStreamData. This parameter may be NULL.
///
void CopyMinimalStream(uint streamOffset, uint cbStreamData, [Out] IntPtr pbStreamData, out uint pcbStreamDataActual);
}
///
/// Exposes methods for writing compressed JPEG scan data directly to the WIC encoder's output stream. Also provides access to the
/// Huffman and quantization tables.
///
///
///
/// Obtain this interface by calling IUnknown::QueryInterface on the Windows-provided IWICBitmapFrameEncoder interface for the JPEG encoder.
///
/// The WIC JPEG encoder supports a smaller subset of JPEG features than the decoder does.
///
/// -
///
/// The encoder is limited to a single scan. It does not support encoding images that are multi-scan, either for progressive
/// encoding or planar component data.
///
///
/// -
///
/// The encoder supports two quantization tables, two AC Huffman tables, and two DC Huffman tables. The luma tables are used for the
/// Y channel and, in the case of YCCK, the black channel. The chroma tables are used for the CbCr channels.
///
///
/// -
/// The encoder supports encoding gray, YCbCr (RGB), and YCCK (CMYK).
///
/// -
/// The encoder supports 4 fixed compontent subsampling, 4:2:0, 4:2:2, 4:4:0, and 4:4:4. This subsamples chroma only.
///
/// -
/// The encoder does not support restart markers.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicjpegframeencode
[PInvokeData("wincodec.h", MSDNShortId = "631571A2-AA15-4A4B-B705-6CCC81392A6A")]
[ComImport, Guid("2F0C601F-D2C6-468C-ABFA-49495D983ED1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICJpegFrameEncode
{
/// Retrieves a copy of the AC Huffman table for the specified scan and table.
///
/// Type: UINT
/// The zero-based index of the scan for which data is retrieved.
///
///
/// Type: UINT
/// The index of the AC Huffman table to retrieve.
///
///
/// Type: DXGI_JPEG_AC_HUFFMAN_TABLE*
/// A pointer that receives the table data. This parameter must not be NULL.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframeencode-getachuffmantable HRESULT
// GetAcHuffmanTable( UINT scanIndex, UINT tableIndex, DXGI_JPEG_AC_HUFFMAN_TABLE *pAcHuffmanTable );
DXGI_JPEG_AC_HUFFMAN_TABLE GetAcHuffmanTable(uint scanIndex, uint tableIndex);
/// Retrieves a copy of the DC Huffman table for the specified scan and table.
/// The zero-based index of the scan for which data is retrieved.
/// The index of the DC Huffman table to retrieve.
/// A pointer that receives the table data. This parameter must not be NULL.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframeencode-getdchuffmantable HRESULT
// GetDcHuffmanTable( UINT scanIndex, UINT tableIndex, DXGI_JPEG_DC_HUFFMAN_TABLE *pDcHuffmanTable );
DXGI_JPEG_DC_HUFFMAN_TABLE GetDcHuffmanTable(uint scanIndex, uint tableIndex);
/// Retrieves a copy of the quantization table.
///
/// Type: UINT
/// The zero-based index of the scan for which data is retrieved.
///
///
/// Type: UINT
/// The index of the quantization table to retrieve.
///
///
/// Type: DXGI_JPEG_QUANTIZATION_TABLE*
/// A pointer that receives the table data. This parameter must not be NULL.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframeencode-getquantizationtable HRESULT
// GetQuantizationTable( UINT scanIndex, UINT tableIndex, DXGI_JPEG_QUANTIZATION_TABLE *pQuantizationTable );
DXGI_JPEG_QUANTIZATION_TABLE GetQuantizationTable(uint scanIndex, uint tableIndex);
/// Writes scan data to a JPEG frame.
///
/// Type: UINT
/// The size of the data in the pbScanData parameter.
///
///
/// Type: BYTE*
/// The scan data to write.
///
///
///
/// WriteScan may be called multiple times. Each call appends the scan data specified to any previous scan data. Complete
/// the scan by calling IWICBitmapFrameEncode::Commit.
///
///
/// Any calls to set encoder parameters or image metadata that will appear before the scan data in the resulting JPEG file must
/// be completed before the first call to this method. This includes calls to IWICBitmapFrameEncode::SetColorContexts ,
/// IWICBitmapFrameEncode::SetPalette, IWICBitmapFrameEncode::SetPixelFormat, IWICBitmapFrameEncode::SetResolution, and
/// IWICBitmapFrameEncode::SetThumbnail. IWICBitmapFrameEncode::SetSize is required as it has no default value for encoded image size.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicjpegframeencode-writescan HRESULT WriteScan( UINT
// cbScanData, const BYTE *pbScanData );
void WriteScan(uint cbScanData, [In] IntPtr pbScanData);
}
/// Exposes methods that provide access to all of the codec's top level metadata blocks.
///
///
/// IWICMetadataBlockReader and IWICMetadataBlockWriter operate at the root level only; that is, they provide read and write
/// access, respectively, to the top level metadata blocks. They are implemented by IWICBitmapFrameDecode and IWICBitmapFrameEncode,
/// respectively. To handle any metadata blocks that are not at the top level of the hierarchy, use IWICMetadataReader or IWICMetadataWriter.
///
///
/// Note The codec's decoder and encoder implement this interface to expose the enumeration of all top level metadata blocks.
/// While the codec parses the image stream, it calls services like CreateMetadataReaderFromContainer to instantiate metadata
/// readers for any block that is recognized as being able to be embedded in the decoder's container format. The collection of
/// metadata readers is exposed through this interface. For more info, see How to Write a WIC-Enabled CODEC.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nn-wincodecsdk-iwicmetadatablockreader
[PInvokeData("wincodecsdk.h", MSDNShortId = "09614b44-ebc2-44f4-9755-9df62f1b2178")]
[ComImport, Guid("FEAA2A8D-B3F3-43E4-B25C-D1DE990A1AE1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICMetadataBlockReader
{
/// Retrieves the container format of the decoder.
///
/// Type: GUID*
/// The container format of the decoder. The native container format GUIDs are listed in WIC GUIDs and CLSIDs.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockreader-getcontainerformat
// HRESULT GetContainerFormat( GUID *pguidContainerFormat );
Guid GetContainerFormat();
/// Retrieves the number of top level metadata blocks.
///
/// Type: UINT*
/// When this method returns, contains the number of top level metadata blocks.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockreader-getcount HRESULT
// GetCount( UINT *pcCount );
uint GetCount();
/// Retrieves an IWICMetadataReader for a specified top level metadata block.
///
/// Type: UINT
/// The index of the desired top level metadata block to retrieve.
///
///
/// Type: IWICMetadataReader**
/// When this method returns, contains a pointer to the IWICMetadataReader specified by nIndex.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockreader-getreaderbyindex
// HRESULT GetReaderByIndex( UINT nIndex, IWICMetadataReader **ppIMetadataReader );
IWICMetadataReader GetReaderByIndex(uint nIndex);
/// Retrieves an enumeration of IWICMetadataReader objects representing each of the top level metadata blocks.
///
/// Type: IEnumUnknown**
/// When this method returns, contains a pointer to an enumeration of IWICMetadataReader objects.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockreader-getenumerator HRESULT
// GetEnumerator( IEnumUnknown **ppIEnumMetadata );
IEnumUnknown GetEnumerator();
}
///
/// Exposes methods that enable the encoding of metadata. This interface is implemented by the decoder and its image frames.
///
///
/// When the encoder is told to commit, it goes through each metadata writer and serializes the metadata content into the encoding
/// stream. If the metadata block contains metadata important to the integrity of the file, such as the image width or height or
/// other intrinsic information about the image, the encoder must set the critical metadata items prior to serializing the metadata.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nn-wincodecsdk-iwicmetadatablockwriter
[PInvokeData("wincodecsdk.h", MSDNShortId = "d8e44c64-dd58-4d36-8add-0a0b2e2af5a4")]
[ComImport, Guid("08FB9676-B444-41E8-8DBE-6A53A542BFF1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICMetadataBlockWriter : IWICMetadataBlockReader
{
/// Retrieves the container format of the decoder.
///
/// Type: GUID*
/// The container format of the decoder. The native container format GUIDs are listed in WIC GUIDs and CLSIDs.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockreader-getcontainerformat
// HRESULT GetContainerFormat( GUID *pguidContainerFormat );
new Guid GetContainerFormat();
/// Retrieves the number of top level metadata blocks.
///
/// Type: UINT*
/// When this method returns, contains the number of top level metadata blocks.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockreader-getcount HRESULT
// GetCount( UINT *pcCount );
new uint GetCount();
/// Retrieves an IWICMetadataReader for a specified top level metadata block.
///
/// Type: UINT
/// The index of the desired top level metadata block to retrieve.
///
///
/// Type: IWICMetadataReader**
/// When this method returns, contains a pointer to the IWICMetadataReader specified by nIndex.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockreader-getreaderbyindex
// HRESULT GetReaderByIndex( UINT nIndex, IWICMetadataReader **ppIMetadataReader );
new IWICMetadataReader GetReaderByIndex(uint nIndex);
/// Retrieves an enumeration of IWICMetadataReader objects representing each of the top level metadata blocks.
///
/// Type: IEnumUnknown**
/// When this method returns, contains a pointer to an enumeration of IWICMetadataReader objects.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockreader-getenumerator HRESULT
// GetEnumerator( IEnumUnknown **ppIEnumMetadata );
new IEnumUnknown GetEnumerator();
///
/// Initializes an IWICMetadataBlockWriter from the given IWICMetadataBlockReader. This will prepopulate the metadata block
/// writer with all the metadata in the metadata block reader.
///
///
/// Type: IWICMetadataBlockReader*
/// Pointer to the IWICMetadataBlockReader used to initialize the block writer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockwriter-initializefromblockreader
// HRESULT InitializeFromBlockReader( IWICMetadataBlockReader *pIMDBlockReader );
void InitializeFromBlockReader(IWICMetadataBlockReader pIMDBlockReader);
/// Retrieves the IWICMetadataWriter that resides at the specified index.
///
/// Type: UINT
/// The index of the metadata writer to be retrieved. This index is zero-based.
///
///
/// Type: IWICMetadataWriter**
/// When this method returns, contains a pointer to the metadata writer that resides at the specified index.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockwriter-getwriterbyindex
// HRESULT GetWriterByIndex( UINT nIndex, IWICMetadataWriter **ppIMetadataWriter );
IWICMetadataWriter GetWriterByIndex(uint nIndex);
/// Adds a top-level metadata block by adding a IWICMetadataWriter for it.
///
/// Type: IWICMetadataWriter*
/// A pointer to the metadata writer to add to the image.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockwriter-addwriter HRESULT
// AddWriter( IWICMetadataWriter *pIMetadataWriter );
void AddWriter(IWICMetadataWriter pIMetadataWriter);
/// Replaces the metadata writer at the specified index location.
///
/// Type: UINT
/// The index position at which to place the metadata writer. This index is zero-based.
///
///
/// Type: IWICMetadataWriter*
/// A pointer to the IWICMetadataWriter.
///
///
///
/// Typically, the current metadata writer at the specified index will be replaced with the new writer. However, the App0
/// metadata writer cannot be replaced within a JPEG stream.
///
///
/// This function cannot be used to add metadata writers. If no metadata writer exists at the specified index, the function will fail.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockwriter-setwriterbyindex
// HRESULT SetWriterByIndex( UINT nIndex, IWICMetadataWriter *pIMetadataWriter );
void SetWriterByIndex(uint nIndex, IWICMetadataWriter pIMetadataWriter);
/// Removes the metadata writer from the specified index location.
///
/// Type: UINT
/// The index of the metadata writer to remove.
///
///
/// After removing a metadata writer, remaining metadata writers can be expected to move up to occupy the vacated location.
/// Indexes for remaining metadata items as well as the count will change.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatablockwriter-removewriterbyindex
// HRESULT RemoveWriterByIndex( UINT nIndex );
void RemoveWriterByIndex(uint nIndex);
}
/// Exposes methods that provide basic information about the registered metadata handler.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nn-wincodecsdk-iwicmetadatahandlerinfo
[ComImport, Guid("ABA958BF-C672-44D1-8D61-CE6DF2E682C2"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICMetadataHandlerInfo : IWICComponentInfo
{
/// Retrieves the component's WICComponentType.
///
/// Type: WICComponentType*
/// A pointer that receives the WICComponentType.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getcomponenttype HRESULT
// GetComponentType( WICComponentType *pType );
new WICComponentType GetComponentType();
/// Retrieves the component's class identifier (CLSID)
///
/// Type: CLSID*
/// A pointer that receives the component's CLSID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getclsid HRESULT GetCLSID( CLSID
// *pclsid );
new Guid GetCLSID();
/// Retrieves the signing status of the component.
///
/// Type: DWORD*
/// A pointer that receives the WICComponentSigning status of the component.
///
///
/// Signing is unused by WIC. Therefore, all components WICComponentSigned.
///
/// This function can be used to determine whether a component has no binary component or has been added to the disabled
/// components list in the registry.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getsigningstatus HRESULT
// GetSigningStatus( DWORD *pStatus );
new WICComponentSigning GetSigningStatus();
/// Retrieves the name of component's author.
///
/// Type: UINT
/// The size of the wzAuthor buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the name of the component's author. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's authors name. The author name is optional; if an author name is
/// not specified by the component, the length returned is 0.
///
///
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getauthor HRESULT GetAuthor( UINT
// cchAuthor, WCHAR *wzAuthor, UINT *pcchActual );
new void GetAuthor(uint cchAuthor, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAuthor, out uint pcchActual);
/// Retrieves the vendor GUID.
///
/// Type: GUID*
/// A pointer that receives the component's vendor GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getvendorguid HRESULT
// GetVendorGUID( GUID *pguidVendor );
new Guid GetVendorGUID();
/// Retrieves the component's version.
///
/// Type: UINT
/// The size of the wzVersion buffer.
///
///
/// Type: WCHAR*
/// A pointer that receives a culture invariant string of the component's version.
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's version. The version is optional; if a value is not specified
/// by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getversion HRESULT GetVersion( UINT
// cchVersion, WCHAR *wzVersion, UINT *pcchActual );
new void GetVersion(uint cchVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzVersion, out uint pcchActual);
/// Retrieves the component's specification version.
///
/// Type: UINT
/// The size of the wzSpecVersion buffer.
///
///
/// Type: WCHAR*
///
/// When this method returns, contain a culture invarient string of the component's specification version. The version form is NN.NN.NN.NN.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's specification version. The specification version is optional;
/// if a value is not specified by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a spec version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getspecversion HRESULT
// GetSpecVersion( UINT cchSpecVersion, WCHAR *wzSpecVersion, UINT *pcchActual );
new void GetSpecVersion(uint cchSpecVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzSpecVersion, out uint pcchActual);
/// Retrieves the component's friendly name, which is a human-readable display name for the component.
///
/// Type: UINT
/// The size of the wzFriendlyName buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the friendly name of the component. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
/// A pointer that receives the actual length of the component's friendly name.
///
/// If cchFriendlyName is 0 and wzFriendlyName is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getfriendlyname HRESULT
// GetFriendlyName( UINT cchFriendlyName, WCHAR *wzFriendlyName, UINT *pcchActual );
new void GetFriendlyName(uint cchFriendlyName, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFriendlyName, out uint pcchActual);
/// Retrieves the metadata format of the metadata handler.
///
/// Type: GUID*
/// Pointer that receives the metadata format GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getmetadataformat
// HRESULT GetMetadataFormat( GUID *pguidMetadataFormat );
Guid GetMetadataFormat();
/// Retrieves the container formats supported by the metadata handler.
///
/// Type: UINT
/// The size of the pguidContainerFormats array.
///
///
/// Type: GUID*
/// Pointer to an array that receives the container formats supported by the metadata handler.
///
///
/// Type: UINT*
/// The actual number of GUIDs added to the array.
/// To obtain the number of supported container formats, pass to pguidContainerFormats.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getcontainerformats
// HRESULT GetContainerFormats( UINT cContainerFormats, GUID *pguidContainerFormats, UINT *pcchActual );
void GetContainerFormats(uint cContainerFormats, [Out] Guid[] pguidContainerFormats, out uint pcchActual);
/// Retrieves the device manufacturer of the metadata handler.
///
/// Type: UINT
/// The size of the wzDeviceManufacturer buffer.
///
///
/// Type: WCHAR*
/// Pointer to the buffer that receives the name of the device manufacturer.
///
///
/// Type: UINT*
/// The actual string buffer length needed to obtain the entire name of the device manufacturer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getdevicemanufacturer
// HRESULT GetDeviceManufacturer( UINT cchDeviceManufacturer, WCHAR *wzDeviceManufacturer, UINT *pcchActual );
void GetDeviceManufacturer(uint cchDeviceManufacturer, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceManufacturer, out uint pcchActual);
/// Retrieves the device models that support the metadata handler.
///
/// Type: UINT
/// The length of the wzDeviceModels buffer.
///
///
/// Type: WCHAR*
/// Pointer that receives the device models supported by the metadata handler.
///
///
/// Type: UINT*
/// The actual length needed to retrieve the device models.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getdevicemodels HRESULT
// GetDeviceModels( UINT cchDeviceModels, WCHAR *wzDeviceModels, UINT *pcchActual );
void GetDeviceModels(uint cchDeviceModels, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceModels, out uint pcchActual);
/// Determines if the handler requires a full stream.
///
/// Type: BOOL*
/// Pointer that receives TRUE if a full stream is required; otherwise, FALSE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-doesrequirefullstream
// HRESULT DoesRequireFullStream( BOOL *pfRequiresFullStream );
[return: MarshalAs(UnmanagedType.Bool)]
bool DoesRequireFullStream();
/// Determines if the metadata handler supports padding.
///
/// Type: BOOL*
/// Pointer that receives TRUE if padding is supported; otherwise, FALSE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-doessupportpadding
// HRESULT DoesSupportPadding( BOOL *pfSupportsPadding );
[return: MarshalAs(UnmanagedType.Bool)]
bool DoesSupportPadding();
/// Determines if the metadata handler requires a fixed size.
///
/// Type: BOOL*
/// Pointer that receives TRUE if a fixed size is required; otherwise, FALSE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-doesrequirefixedsize
// HRESULT DoesRequireFixedSize( BOOL *pfFixedSize );
[return: MarshalAs(UnmanagedType.Bool)]
bool DoesRequireFixedSize();
}
///
/// Exposes methods for retrieving metadata blocks and items from a decoder or its image frames using a metadata query expression.
///
///
///
/// A metadata query reader uses metadata query expressions to access embedded metadata. For more information on the metadata query
/// language, see the Metadata Query Language Overview.
///
/// The benefit of the query reader is the ability to access a metadata item in a single step.
///
/// The query reader also provides the way to traverse the whole set of metadata hierarchy with the help of the GetEnumerator
/// method. However, it is not recommended to use this method since IWICMetadataBlockReader and IWICMetadataReader provide a more
/// convenient and cheaper way.
///
/// Examples
/// The following code demonstrates how to obtain a query reader and use it to retrieve a metadata item.
/// The following code demonstrates how to obtain query reader and use it to retrieve a nested metadata block.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicmetadataqueryreader
[PInvokeData("wincodec.h", MSDNShortId = "588e00d2-e166-4ce5-bd8a-50ad0d5a3db9")]
[ComImport, Guid("30989668-E1C9-4597-B395-458EEDB808DF"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICMetadataQueryReader
{
/// Gets the metadata query readers container format.
///
/// Type: GUID*
/// Pointer that receives the cointainer format GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicmetadataqueryreader-getcontainerformat HRESULT
// GetContainerFormat( GUID *pguidContainerFormat );
Guid GetContainerFormat();
/// Retrieves the current path relative to the root metadata block.
///
/// Type: UINT
/// The length of the wzNamespace buffer.
///
///
/// Type: WCHAR*
/// Pointer that receives the current namespace location.
///
///
/// Type: UINT*
/// The actual buffer length that was needed to retrieve the current namespace location.
///
///
///
/// If you pass NULL to wzNamespace, GetLocation ignores cchMaxLength and returns the required buffer length to
/// store the path in the variable that pcchActualLength points to.
///
/// If the query reader is relative to the top of the metadata hierarchy, it will return a single-char string.
///
/// If the query reader is relative to a nested metadata block, this method will return the path to the current query reader.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicmetadataqueryreader-getlocation HRESULT
// GetLocation( UINT cchMaxLength, WCHAR *wzNamespace, UINT *pcchActualLength );
void GetLocation(uint cchMaxLength, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzNamespace, out uint pcchActualLength);
/// Retrieves the metadata block or item identified by a metadata query expression.
///
/// Type: LPCWSTR
/// The query expression to the requested metadata block or item.
///
///
/// Type: PROPVARIANT*
/// When this method returns, contains the metadata block or item requested.
///
///
///
/// GetMetadataByName uses metadata query expressions to access embedded metadata. For more information on the metadata
/// query language, see the Metadata Query Language Overview.
///
///
/// If multiple blocks or items exist that are expressed by the same query expression, the first metadata block or item found
/// will be returned.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicmetadataqueryreader-getmetadatabyname HRESULT
// GetMetadataByName( LPCWSTR wzName, PROPVARIANT *pvarValue );
void GetMetadataByName([MarshalAs(UnmanagedType.LPWStr)] string wzName, [Out] PROPVARIANT pvarValue);
/// Gets an enumerator of all metadata items at the current relative location within the metadata hierarchy.
///
/// Type: IEnumString**
///
/// A pointer to a variable that receives a pointer to the IEnumString interface for the enumerator that contains query strings
/// that can be used in the current IWICMetadataQueryReader.
///
///
///
/// The retrieved enumerator only contains query strings for the metadata blocks and items in the current level of the hierarchy.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicmetadataqueryreader-getenumerator HRESULT
// GetEnumerator( IEnumString **ppIEnumString );
IEnumString GetEnumerator();
}
///
/// Exposes methods for setting or removing metadata blocks and items to an encoder or its image frames using a metadata query expression.
///
///
///
/// A metadata query writer uses metadata query expressions to set or remove metadata. For more information on the metadata query
/// language, see the Metadata Query Language Overview.
///
/// Examples
/// The following code demonstrates how to create an XMP query writer and add a new metadata item to it.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicmetadataquerywriter
[PInvokeData("wincodec.h", MSDNShortId = "065cccc3-778f-42c4-823a-354b08bbd1f1")]
[ComImport, Guid("A721791A-0DEF-4d06-BD91-2118BF1DB10B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICMetadataQueryWriter : IWICMetadataQueryReader
{
/// Gets the metadata query readers container format.
///
/// Type: GUID*
/// Pointer that receives the cointainer format GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicmetadataqueryreader-getcontainerformat HRESULT
// GetContainerFormat( GUID *pguidContainerFormat );
new Guid GetContainerFormat();
/// Retrieves the current path relative to the root metadata block.
///
/// Type: UINT
/// The length of the wzNamespace buffer.
///
///
/// Type: WCHAR*
/// Pointer that receives the current namespace location.
///
///
/// Type: UINT*
/// The actual buffer length that was needed to retrieve the current namespace location.
///
///
///
/// If you pass NULL to wzNamespace, GetLocation ignores cchMaxLength and returns the required buffer length to
/// store the path in the variable that pcchActualLength points to.
///
/// If the query reader is relative to the top of the metadata hierarchy, it will return a single-char string.
///
/// If the query reader is relative to a nested metadata block, this method will return the path to the current query reader.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicmetadataqueryreader-getlocation HRESULT
// GetLocation( UINT cchMaxLength, WCHAR *wzNamespace, UINT *pcchActualLength );
new void GetLocation(uint cchMaxLength, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzNamespace, out uint pcchActualLength);
/// Retrieves the metadata block or item identified by a metadata query expression.
///
/// Type: LPCWSTR
/// The query expression to the requested metadata block or item.
///
///
/// Type: PROPVARIANT*
/// When this method returns, contains the metadata block or item requested.
///
///
///
/// GetMetadataByName uses metadata query expressions to access embedded metadata. For more information on the metadata
/// query language, see the Metadata Query Language Overview.
///
///
/// If multiple blocks or items exist that are expressed by the same query expression, the first metadata block or item found
/// will be returned.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicmetadataqueryreader-getmetadatabyname HRESULT
// GetMetadataByName( LPCWSTR wzName, PROPVARIANT *pvarValue );
new void GetMetadataByName([MarshalAs(UnmanagedType.LPWStr)] string wzName, [Out] PROPVARIANT pvarValue);
/// Gets an enumerator of all metadata items at the current relative location within the metadata hierarchy.
///
/// Type: IEnumString**
///
/// A pointer to a variable that receives a pointer to the IEnumString interface for the enumerator that contains query strings
/// that can be used in the current IWICMetadataQueryReader.
///
///
///
/// The retrieved enumerator only contains query strings for the metadata blocks and items in the current level of the hierarchy.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicmetadataqueryreader-getenumerator HRESULT
// GetEnumerator( IEnumString **ppIEnumString );
new IEnumString GetEnumerator();
/// Sets a metadata item to a specific location.
///
/// Type: LPCWSTR
/// The name of the metadata item.
///
///
/// Type: const PROPVARIANT*
/// The metadata to set.
///
///
///
/// SetMetadataByName uses metadata query expressions to remove metadata. For more information on the metadata query
/// language, see the Metadata Query Language Overview.
///
///
/// If the value set is a nested metadata block then use variant type and pvarValue pointing to the IWICMetadataQueryWriter of
/// the new metadata block. The ordering of metadata items is at the discretion of the query writer since relative locations are
/// not specified.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicmetadataquerywriter-setmetadatabyname HRESULT
// SetMetadataByName( LPCWSTR wzName, const PROPVARIANT *pvarValue );
void SetMetadataByName([MarshalAs(UnmanagedType.LPWStr)] string wzName, [In] PROPVARIANT pvarValue);
/// Removes a metadata item from a specific location using a metadata query expression.
///
/// Type: LPCWSTR
/// The name of the metadata item to remove.
///
///
///
/// RemoveMetadataByName uses metadata query expressions to remove metadata. For more information on the metadata query
/// language, see the Metadata Query Language Overview.
///
/// If the metadata item is a metadata block, it is removed from the metadata hierarchy.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicmetadataquerywriter-removemetadatabyname HRESULT
// RemoveMetadataByName( LPCWSTR wzName );
void RemoveMetadataByName([MarshalAs(UnmanagedType.LPWStr)] string wzName);
}
///
/// Exposes methods that provide access to underlining metadata content. This interface is implemented by independent software
/// vendors (ISVs) to create new metadata readers.
///
///
/// A metadata reader can be used to access metadata blocks and items within a metadata block instead of using a query reader. To
/// directly access the metadata reader, query a decoder or its frames for the IWICMetadataBlockReader interface to enumerate each
/// metadata reader.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nn-wincodecsdk-iwicmetadatareader
[PInvokeData("wincodecsdk.h", MSDNShortId = "0495ecf1-128a-4576-8420-0e79f1454015")]
[ComImport, Guid("9204FE99-D8FC-4FD5-A001-9536B067A899"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICMetadataReader
{
/// Gets the metadata format associated with the reader.
///
/// Type: GUID*
/// Pointer that receives the metadata format GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getmetadataformat HRESULT
// GetMetadataFormat( GUID *pguidMetadataFormat );
Guid GetMetadataFormat();
/// Gets the metadata handler info associated with the reader.
///
/// Type: IWICMetadataHandlerInfo**
/// Pointer that receives a pointer to the IWICMetadataHandlerInfo.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getmetadatahandlerinfo
// HRESULT GetMetadataHandlerInfo( IWICMetadataHandlerInfo **ppIHandler );
IWICMetadataHandlerInfo GetMetadataHandlerInfo();
/// Gets the number of metadata items within the reader.
///
/// Type: UINT*
/// Pointer that receives the number of metadata items within the reader.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getcount HRESULT GetCount(
// UINT *pcCount );
uint GetCount();
/// Gets the metadata item at the given index.
///
/// Type: UINT
/// The index of the metadata item to retrieve.
///
///
/// Type: PROPVARIANT*
/// Pointer that receives the schema property.
///
///
/// Type: PROPVARIANT*
/// Pointer that receives the id property.
///
///
/// Type: PROPVARIANT*
/// Pointer that receives the metadata value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getvaluebyindex HRESULT
// GetValueByIndex( UINT nIndex, PROPVARIANT *pvarSchema, PROPVARIANT *pvarId, PROPVARIANT *pvarValue );
void GetValueByIndex(uint nIndex, [In, Out] PROPVARIANT pvarSchema, [In, Out] PROPVARIANT pvarId, [In, Out] PROPVARIANT pvarValue);
/// Gets the metadata item value.
///
/// Type: const PROPVARIANT*
/// Pointer to the metadata item's schema property.
///
///
/// Type: const PROPVARIANT*
/// Pointer to the metadata item's id.
///
///
/// Type: PROPVARIANT*
/// Pointer that receives the metadata value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getvalue HRESULT GetValue(
// const PROPVARIANT *pvarSchema, const PROPVARIANT *pvarId, PROPVARIANT *pvarValue );
void GetValue([In, Optional] PROPVARIANT pvarSchema, [In] PROPVARIANT pvarId, [In, Out, Optional] PROPVARIANT pvarValue);
/// Gets an enumerator of all the metadata items.
///
/// Type: IWICEnumMetadataItem**
/// Pointer that receives a pointer to the metadata enumerator.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getenumerator HRESULT
// GetEnumerator( IWICEnumMetadataItem **ppIEnumMetadata );
IWICEnumMetadataItem GetEnumerator();
}
/// Exposes methods that provide basic information about the registered metadata reader.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nn-wincodecsdk-iwicmetadatareaderinfo
[PInvokeData("wincodecsdk.h", MSDNShortId = "f72d9a06-0568-4e46-a904-202aad2f8859")]
[ComImport, Guid("EEBF1F5B-07C1-4447-A3AB-22ACAF78A804"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICMetadataReaderInfo : IWICMetadataHandlerInfo
{
/// Retrieves the component's WICComponentType.
///
/// Type: WICComponentType*
/// A pointer that receives the WICComponentType.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getcomponenttype HRESULT
// GetComponentType( WICComponentType *pType );
new WICComponentType GetComponentType();
/// Retrieves the component's class identifier (CLSID)
///
/// Type: CLSID*
/// A pointer that receives the component's CLSID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getclsid HRESULT GetCLSID( CLSID
// *pclsid );
new Guid GetCLSID();
/// Retrieves the signing status of the component.
///
/// Type: DWORD*
/// A pointer that receives the WICComponentSigning status of the component.
///
///
/// Signing is unused by WIC. Therefore, all components WICComponentSigned.
///
/// This function can be used to determine whether a component has no binary component or has been added to the disabled
/// components list in the registry.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getsigningstatus HRESULT
// GetSigningStatus( DWORD *pStatus );
new WICComponentSigning GetSigningStatus();
/// Retrieves the name of component's author.
///
/// Type: UINT
/// The size of the wzAuthor buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the name of the component's author. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's authors name. The author name is optional; if an author name is
/// not specified by the component, the length returned is 0.
///
///
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getauthor HRESULT GetAuthor( UINT
// cchAuthor, WCHAR *wzAuthor, UINT *pcchActual );
new void GetAuthor(uint cchAuthor, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAuthor, out uint pcchActual);
/// Retrieves the vendor GUID.
///
/// Type: GUID*
/// A pointer that receives the component's vendor GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getvendorguid HRESULT
// GetVendorGUID( GUID *pguidVendor );
new Guid GetVendorGUID();
/// Retrieves the component's version.
///
/// Type: UINT
/// The size of the wzVersion buffer.
///
///
/// Type: WCHAR*
/// A pointer that receives a culture invariant string of the component's version.
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's version. The version is optional; if a value is not specified
/// by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getversion HRESULT GetVersion( UINT
// cchVersion, WCHAR *wzVersion, UINT *pcchActual );
new void GetVersion(uint cchVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzVersion, out uint pcchActual);
/// Retrieves the component's specification version.
///
/// Type: UINT
/// The size of the wzSpecVersion buffer.
///
///
/// Type: WCHAR*
///
/// When this method returns, contain a culture invarient string of the component's specification version. The version form is NN.NN.NN.NN.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's specification version. The specification version is optional;
/// if a value is not specified by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a spec version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getspecversion HRESULT
// GetSpecVersion( UINT cchSpecVersion, WCHAR *wzSpecVersion, UINT *pcchActual );
new void GetSpecVersion(uint cchSpecVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzSpecVersion, out uint pcchActual);
/// Retrieves the component's friendly name, which is a human-readable display name for the component.
///
/// Type: UINT
/// The size of the wzFriendlyName buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the friendly name of the component. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
/// A pointer that receives the actual length of the component's friendly name.
///
/// If cchFriendlyName is 0 and wzFriendlyName is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getfriendlyname HRESULT
// GetFriendlyName( UINT cchFriendlyName, WCHAR *wzFriendlyName, UINT *pcchActual );
new void GetFriendlyName(uint cchFriendlyName, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFriendlyName, out uint pcchActual);
/// Retrieves the metadata format of the metadata handler.
///
/// Type: GUID*
/// Pointer that receives the metadata format GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getmetadataformat
// HRESULT GetMetadataFormat( GUID *pguidMetadataFormat );
new Guid GetMetadataFormat();
/// Retrieves the container formats supported by the metadata handler.
///
/// Type: UINT
/// The size of the pguidContainerFormats array.
///
///
/// Type: GUID*
/// Pointer to an array that receives the container formats supported by the metadata handler.
///
///
/// Type: UINT*
/// The actual number of GUIDs added to the array.
/// To obtain the number of supported container formats, pass to pguidContainerFormats.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getcontainerformats
// HRESULT GetContainerFormats( UINT cContainerFormats, GUID *pguidContainerFormats, UINT *pcchActual );
new void GetContainerFormats(uint cContainerFormats, [Out] Guid[] pguidContainerFormats, out uint pcchActual);
/// Retrieves the device manufacturer of the metadata handler.
///
/// Type: UINT
/// The size of the wzDeviceManufacturer buffer.
///
///
/// Type: WCHAR*
/// Pointer to the buffer that receives the name of the device manufacturer.
///
///
/// Type: UINT*
/// The actual string buffer length needed to obtain the entire name of the device manufacturer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getdevicemanufacturer
// HRESULT GetDeviceManufacturer( UINT cchDeviceManufacturer, WCHAR *wzDeviceManufacturer, UINT *pcchActual );
new void GetDeviceManufacturer(uint cchDeviceManufacturer, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceManufacturer, out uint pcchActual);
/// Retrieves the device models that support the metadata handler.
///
/// Type: UINT
/// The length of the wzDeviceModels buffer.
///
///
/// Type: WCHAR*
/// Pointer that receives the device models supported by the metadata handler.
///
///
/// Type: UINT*
/// The actual length needed to retrieve the device models.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getdevicemodels HRESULT
// GetDeviceModels( UINT cchDeviceModels, WCHAR *wzDeviceModels, UINT *pcchActual );
new void GetDeviceModels(uint cchDeviceModels, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceModels, out uint pcchActual);
/// Determines if the handler requires a full stream.
///
/// Type: BOOL*
/// Pointer that receives TRUE if a full stream is required; otherwise, FALSE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-doesrequirefullstream
// HRESULT DoesRequireFullStream( BOOL *pfRequiresFullStream );
[return: MarshalAs(UnmanagedType.Bool)]
new bool DoesRequireFullStream();
/// Determines if the metadata handler supports padding.
///
/// Type: BOOL*
/// Pointer that receives TRUE if padding is supported; otherwise, FALSE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-doessupportpadding
// HRESULT DoesSupportPadding( BOOL *pfSupportsPadding );
[return: MarshalAs(UnmanagedType.Bool)]
new bool DoesSupportPadding();
/// Determines if the metadata handler requires a fixed size.
///
/// Type: BOOL*
/// Pointer that receives TRUE if a fixed size is required; otherwise, FALSE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-doesrequirefixedsize
// HRESULT DoesRequireFixedSize( BOOL *pfFixedSize );
[return: MarshalAs(UnmanagedType.Bool)]
new bool DoesRequireFixedSize();
/// Gets the metadata patterns associated with the metadata reader.
///
/// Type: REFGUID
/// The cointainer format GUID.
///
///
/// Type: UINT
/// The size, in bytes, of the pPattern buffer.
///
///
/// Type: WICMetadataPattern*
/// Pointer that receives the metadata patterns.
///
///
/// Type: UINT*
/// Pointer that receives the number of metadata patterns.
///
///
/// Type: UINT*
/// Pointer that receives the size, in bytes, needed to obtain the metadata patterns.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareaderinfo-getpatterns HRESULT
// GetPatterns( REFGUID guidContainerFormat, UINT cbSize, WICMetadataPattern *pPattern, UINT *pcCount, UINT *pcbActual );
void GetPatterns(in Guid guidContainerFormat, uint cbSize, [Out, Optional] IntPtr pPattern, out uint pcCount, out uint pcbActual);
/// Determines if a stream contains a metadata item pattern.
///
/// Type: REFGUID
/// The container format of the metadata item.
///
///
/// Type: IStream*
/// The stream to search for the metadata pattern.
///
///
/// Type: BOOL*
/// Pointer that receives if the stream contains the pattern; otherwise, .
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareaderinfo-matchespattern HRESULT
// MatchesPattern( REFGUID guidContainerFormat, IStream *pIStream, BOOL *pfMatches );
[return: MarshalAs(UnmanagedType.Bool)]
bool MatchesPattern(in Guid guidContainerFormat, IStream pIStream);
/// Creates an instance of an IWICMetadataReader.
///
/// Type: IWICMetadataReader**
/// Pointer that receives a pointer to a metadata reader.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareaderinfo-createinstance HRESULT
// CreateInstance( IWICMetadataReader **ppIReader );
IWICMetadataReader CreateInstance();
}
///
/// Exposes methods that provide access to writing metadata content. This is implemented by independent software vendors (ISVs) to
/// create new metadata writers.
///
///
/// A metadata writer can be used to write metadata blocks and items within a metadata block instead of using a query writer. To
/// directly access the metadata writer, query an encoder or its frames for the IWICMetadataBlockWriter interface to enumerate each
/// metadata writer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nn-wincodecsdk-iwicmetadatawriter
[PInvokeData("wincodecsdk.h", MSDNShortId = "7e742a96-f9d0-49e1-80e4-31ec90680e60")]
[ComImport, Guid("F7836E16-3BE0-470B-86BB-160D0AECD7DE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICMetadataWriter : IWICMetadataReader
{
/// Gets the metadata format associated with the reader.
///
/// Type: GUID*
/// Pointer that receives the metadata format GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getmetadataformat HRESULT
// GetMetadataFormat( GUID *pguidMetadataFormat );
new Guid GetMetadataFormat();
/// Gets the metadata handler info associated with the reader.
///
/// Type: IWICMetadataHandlerInfo**
/// Pointer that receives a pointer to the IWICMetadataHandlerInfo.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getmetadatahandlerinfo
// HRESULT GetMetadataHandlerInfo( IWICMetadataHandlerInfo **ppIHandler );
new IWICMetadataHandlerInfo GetMetadataHandlerInfo();
/// Gets the number of metadata items within the reader.
///
/// Type: UINT*
/// Pointer that receives the number of metadata items within the reader.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getcount HRESULT GetCount(
// UINT *pcCount );
new uint GetCount();
/// Gets the metadata item at the given index.
///
/// Type: UINT
/// The index of the metadata item to retrieve.
///
///
/// Type: PROPVARIANT*
/// Pointer that receives the schema property.
///
///
/// Type: PROPVARIANT*
/// Pointer that receives the id property.
///
///
/// Type: PROPVARIANT*
/// Pointer that receives the metadata value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getvaluebyindex HRESULT
// GetValueByIndex( UINT nIndex, PROPVARIANT *pvarSchema, PROPVARIANT *pvarId, PROPVARIANT *pvarValue );
new void GetValueByIndex(uint nIndex, [In, Out] PROPVARIANT pvarSchema, [In, Out] PROPVARIANT pvarId, [In, Out] PROPVARIANT pvarValue);
/// Gets the metadata item value.
///
/// Type: const PROPVARIANT*
/// Pointer to the metadata item's schema property.
///
///
/// Type: const PROPVARIANT*
/// Pointer to the metadata item's id.
///
///
/// Type: PROPVARIANT*
/// Pointer that receives the metadata value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getvalue HRESULT GetValue(
// const PROPVARIANT *pvarSchema, const PROPVARIANT *pvarId, PROPVARIANT *pvarValue );
new void GetValue([In, Optional] PROPVARIANT pvarSchema, [In] PROPVARIANT pvarId, [In, Out, Optional] PROPVARIANT pvarValue);
/// Gets an enumerator of all the metadata items.
///
/// Type: IWICEnumMetadataItem**
/// Pointer that receives a pointer to the metadata enumerator.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatareader-getenumerator HRESULT
// GetEnumerator( IWICEnumMetadataItem **ppIEnumMetadata );
new IWICEnumMetadataItem GetEnumerator();
/// Sets the given metadata item.
///
/// Type: const PROPVARIANT*
/// Pointer to the schema property of the metadata item.
///
///
/// Type: const PROPVARIANT*
/// Pointer to the id property of the metadata item.
///
///
/// Type: const PROPVARIANT*
/// Pointer to the metadata value to set
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatawriter-setvalue HRESULT SetValue(
// const PROPVARIANT *pvarSchema, const PROPVARIANT *pvarId, const PROPVARIANT *pvarValue );
void SetValue([In, Optional] PROPVARIANT pvarSchema, [In] PROPVARIANT pvarId, [In] PROPVARIANT pvarValue);
/// Sets the metadata item to the specified index.
///
/// Type: UINT
/// The index to place the metadata item.
///
///
/// Type: const PROPVARIANT*
/// Pointer to the schema property of the metadata item.
///
///
/// Type: const PROPVARIANT*
/// Pointer to the id property of the metadata item.
///
///
/// Type: const PROPVARIANT*
/// Pointer to the metadata value to set at the given index.
///
///
/// After removing an item, expect the remaining metadata items to move up to occupy the vacated metadata item location.
/// Therefore indices for remaining metadata items as well as the count will change.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatawriter-setvaluebyindex HRESULT
// SetValueByIndex( UINT nIndex, const PROPVARIANT *pvarSchema, const PROPVARIANT *pvarId, const PROPVARIANT *pvarValue );
void SetValueByIndex(uint nIndex, [In, Optional] PROPVARIANT pvarSchema, [In] PROPVARIANT pvarId, [In] PROPVARIANT pvarValue);
/// Removes the metadata item that matches the given parameters.
///
/// Type: const PROPVARIANT*
/// Pointer to the metadata schema property.
///
///
/// Type: const PROPVARIANT*
/// Pointer to the metadata id property.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatawriter-removevalue HRESULT
// RemoveValue( const PROPVARIANT *pvarSchema, const PROPVARIANT *pvarId );
void RemoveValue([In, Optional] PROPVARIANT pvarSchema, [In] PROPVARIANT pvarId);
/// Removes the metadata item at the specified index.
///
/// Type: UINT
/// The index of the metadata item to remove.
///
///
/// After removing an item, expect the remaining metadata items to move up to occupy the vacated metadata item location.
/// Therefore indices for remaining metadata items as well as the count will change.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatawriter-removevaluebyindex HRESULT
// RemoveValueByIndex( UINT nIndex );
void RemoveValueByIndex(uint nIndex);
}
/// Exposes methods that provide basic information about the registered metadata writer.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nn-wincodecsdk-iwicmetadatawriterinfo
[PInvokeData("wincodecsdk.h", MSDNShortId = "467200e7-9b08-4372-9a01-660e56a15bfe")]
[ComImport, Guid("B22E3FBA-3925-4323-B5C1-9EBFC430F236"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICMetadataWriterInfo : IWICMetadataHandlerInfo
{
/// Retrieves the component's WICComponentType.
///
/// Type: WICComponentType*
/// A pointer that receives the WICComponentType.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getcomponenttype HRESULT
// GetComponentType( WICComponentType *pType );
new WICComponentType GetComponentType();
/// Retrieves the component's class identifier (CLSID)
///
/// Type: CLSID*
/// A pointer that receives the component's CLSID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getclsid HRESULT GetCLSID( CLSID
// *pclsid );
new Guid GetCLSID();
/// Retrieves the signing status of the component.
///
/// Type: DWORD*
/// A pointer that receives the WICComponentSigning status of the component.
///
///
/// Signing is unused by WIC. Therefore, all components WICComponentSigned.
///
/// This function can be used to determine whether a component has no binary component or has been added to the disabled
/// components list in the registry.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getsigningstatus HRESULT
// GetSigningStatus( DWORD *pStatus );
new WICComponentSigning GetSigningStatus();
/// Retrieves the name of component's author.
///
/// Type: UINT
/// The size of the wzAuthor buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the name of the component's author. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's authors name. The author name is optional; if an author name is
/// not specified by the component, the length returned is 0.
///
///
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getauthor HRESULT GetAuthor( UINT
// cchAuthor, WCHAR *wzAuthor, UINT *pcchActual );
new void GetAuthor(uint cchAuthor, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAuthor, out uint pcchActual);
/// Retrieves the vendor GUID.
///
/// Type: GUID*
/// A pointer that receives the component's vendor GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getvendorguid HRESULT
// GetVendorGUID( GUID *pguidVendor );
new Guid GetVendorGUID();
/// Retrieves the component's version.
///
/// Type: UINT
/// The size of the wzVersion buffer.
///
///
/// Type: WCHAR*
/// A pointer that receives a culture invariant string of the component's version.
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's version. The version is optional; if a value is not specified
/// by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getversion HRESULT GetVersion( UINT
// cchVersion, WCHAR *wzVersion, UINT *pcchActual );
new void GetVersion(uint cchVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzVersion, out uint pcchActual);
/// Retrieves the component's specification version.
///
/// Type: UINT
/// The size of the wzSpecVersion buffer.
///
///
/// Type: WCHAR*
///
/// When this method returns, contain a culture invarient string of the component's specification version. The version form is NN.NN.NN.NN.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's specification version. The specification version is optional;
/// if a value is not specified by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a spec version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getspecversion HRESULT
// GetSpecVersion( UINT cchSpecVersion, WCHAR *wzSpecVersion, UINT *pcchActual );
new void GetSpecVersion(uint cchSpecVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzSpecVersion, out uint pcchActual);
/// Retrieves the component's friendly name, which is a human-readable display name for the component.
///
/// Type: UINT
/// The size of the wzFriendlyName buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the friendly name of the component. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
/// A pointer that receives the actual length of the component's friendly name.
///
/// If cchFriendlyName is 0 and wzFriendlyName is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getfriendlyname HRESULT
// GetFriendlyName( UINT cchFriendlyName, WCHAR *wzFriendlyName, UINT *pcchActual );
new void GetFriendlyName(uint cchFriendlyName, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFriendlyName, out uint pcchActual);
/// Retrieves the metadata format of the metadata handler.
///
/// Type: GUID*
/// Pointer that receives the metadata format GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getmetadataformat
// HRESULT GetMetadataFormat( GUID *pguidMetadataFormat );
new Guid GetMetadataFormat();
/// Retrieves the container formats supported by the metadata handler.
///
/// Type: UINT
/// The size of the pguidContainerFormats array.
///
///
/// Type: GUID*
/// Pointer to an array that receives the container formats supported by the metadata handler.
///
///
/// Type: UINT*
/// The actual number of GUIDs added to the array.
/// To obtain the number of supported container formats, pass to pguidContainerFormats.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getcontainerformats
// HRESULT GetContainerFormats( UINT cContainerFormats, GUID *pguidContainerFormats, UINT *pcchActual );
new void GetContainerFormats(uint cContainerFormats, [Out] Guid[] pguidContainerFormats, out uint pcchActual);
/// Retrieves the device manufacturer of the metadata handler.
///
/// Type: UINT
/// The size of the wzDeviceManufacturer buffer.
///
///
/// Type: WCHAR*
/// Pointer to the buffer that receives the name of the device manufacturer.
///
///
/// Type: UINT*
/// The actual string buffer length needed to obtain the entire name of the device manufacturer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getdevicemanufacturer
// HRESULT GetDeviceManufacturer( UINT cchDeviceManufacturer, WCHAR *wzDeviceManufacturer, UINT *pcchActual );
new void GetDeviceManufacturer(uint cchDeviceManufacturer, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceManufacturer, out uint pcchActual);
/// Retrieves the device models that support the metadata handler.
///
/// Type: UINT
/// The length of the wzDeviceModels buffer.
///
///
/// Type: WCHAR*
/// Pointer that receives the device models supported by the metadata handler.
///
///
/// Type: UINT*
/// The actual length needed to retrieve the device models.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-getdevicemodels HRESULT
// GetDeviceModels( UINT cchDeviceModels, WCHAR *wzDeviceModels, UINT *pcchActual );
new void GetDeviceModels(uint cchDeviceModels, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceModels, out uint pcchActual);
/// Determines if the handler requires a full stream.
///
/// Type: BOOL*
/// Pointer that receives TRUE if a full stream is required; otherwise, FALSE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-doesrequirefullstream
// HRESULT DoesRequireFullStream( BOOL *pfRequiresFullStream );
[return: MarshalAs(UnmanagedType.Bool)]
new bool DoesRequireFullStream();
/// Determines if the metadata handler supports padding.
///
/// Type: BOOL*
/// Pointer that receives TRUE if padding is supported; otherwise, FALSE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-doessupportpadding
// HRESULT DoesSupportPadding( BOOL *pfSupportsPadding );
[return: MarshalAs(UnmanagedType.Bool)]
new bool DoesSupportPadding();
/// Determines if the metadata handler requires a fixed size.
///
/// Type: BOOL*
/// Pointer that receives TRUE if a fixed size is required; otherwise, FALSE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatahandlerinfo-doesrequirefixedsize
// HRESULT DoesRequireFixedSize( BOOL *pfFixedSize );
[return: MarshalAs(UnmanagedType.Bool)]
new bool DoesRequireFixedSize();
/// Gets the metadata header for the metadata writer.
///
/// Type: REFGUID
/// The format container GUID to obtain the header for.
///
///
/// Type: UINT
/// The size of the pHeader buffer.
///
///
/// Type: WICMetadataHeader*
/// Pointer that receives the WICMetadataHeader.
///
///
/// Type: UINT*
/// The actual size of the header.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatawriterinfo-getheader HRESULT
// GetHeader( REFGUID guidContainerFormat, UINT cbSize, WICMetadataHeader *pHeader, UINT *pcbActual );
void GetHeader(in Guid guidContainerFormat, uint cbSize, [Out] IntPtr pHeader, out uint pcbActual);
/// Creates an instance of an IWICMetadataWriter.
///
/// Type: IWICMetadataWriter**
/// Pointer that receives a pointer to a metadata writer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicmetadatawriterinfo-createinstance HRESULT
// CreateInstance( IWICMetadataWriter **ppIWriter );
IWICMetadataWriter CreateInstance();
}
/// Exposes methods for accessing and building a color table, primarily for indexed pixel formats.
///
///
/// If the WICBitmapPaletteType is not WICBitmapPaletteCustom, then the colors are automatically generated based on the table
/// above. If the user subsequently changes a color palette entry the WICBitmapPalette is set to Custom by that action.
///
///
/// InitializeFromBitmap's fAddTransparentColor parameter will add a transparent color to the end of the color collection if its
/// size if less than 256, otherwise index 255 will be replaced with the transparent color. If a pre-defined palette type is used,
/// it will change to BitmapPaletteTypeCustom since it no longer matches the predefined palette.
///
///
/// The palette interface is an auxiliary imaging interface in that it does not directly concern bitmaps and pixels; rather it
/// provides indexed color translation for indexed bitmaps. For an indexed pixel format with M bits per pixels: (The number of
/// colors in the palette) greater than 2^M.
///
///
/// Traditionally the basic operation of the palette is to provide a translation from a byte (or smaller) index into a 32bpp color
/// value. This is often accomplished by a 256 entry table of color values.
///
/// Examples
/// In this example code, WICColor is defined as a UINT32 value with this layout:
/// The wincodec.h header type-defines WICColor as UINT32.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicpalette
[PInvokeData("wincodec.h", MSDNShortId = "cb0e4f92-4aff-48c7-af62-5f7154539289")]
[ComImport, Guid("00000040-a8f2-4877-ba0a-fd2b6645fb94"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICPalette
{
///
/// Initializes the palette to one of the pre-defined palettes specified by WICBitmapPaletteType and optionally adds a
/// transparent color.
///
///
/// Type: WICBitmapPaletteType
/// The desired pre-defined palette type.
///
///
/// Type: BOOL
///
/// The optional transparent color to add to the palette. If no transparent color is needed, use 0. When initializing to a
/// grayscale or black and white palette, set this parameter to FALSE.
///
///
///
/// If a transparent color is added to a palette, the palette is no longer predefined and is returned as
/// WICBitmapPaletteTypeCustom. For palettes with less than 256 entries, the transparent entry is added to the end of the
/// palette (that is, a 16-color palette becomes a 17-color palette). For palettes with 256 colors, the transparent palette
/// entry will replace the last entry in the pre-defined palette.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpalette-initializepredefined HRESULT
// InitializePredefined( WICBitmapPaletteType ePaletteType, BOOL fAddTransparentColor );
void InitializePredefined(WICBitmapPaletteType ePaletteType, [MarshalAs(UnmanagedType.Bool)] bool fAddTransparentColor);
/// Initializes a palette to the custom color entries provided.
///
/// Type: WICColor*
/// Pointer to the color array.
///
///
/// Type: UINT
/// The number of colors in pColors.
///
///
///
/// If a transparent color is required, provide it as part of the custom entries. To add a transparent value to the palette, its
/// alpha value must be 0 (0x00RRGGBB).
///
/// The entry count is limited to 256.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpalette-initializecustom HRESULT
// InitializeCustom( WICColor *pColors, UINT cCount );
void InitializeCustom([In] uint[] pColors, uint cCount);
/// Initializes a palette using a computed optimized values based on the reference bitmap.
///
/// Type: IWICBitmapSource*
/// Pointer to the source bitmap.
///
///
/// Type: UINT
/// The number of colors to initialize the palette with.
///
///
/// Type: BOOL
/// A value to indicate whether to add a transparent color.
///
///
/// The resulting palette contains the specified number of colors which best represent the colors present in the bitmap. The
/// algorithm operates on the opaque RGB color value of each pixel in the reference bitmap and hence ignores any alpha values.
/// If a transparent color is required, set the fAddTransparentColor parameter to TRUE and one fewer optimized color will
/// be computed, reducing the colorCount, and a fully transparent color entry will be added.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpalette-initializefrombitmap HRESULT
// InitializeFromBitmap( IWICBitmapSource *pISurface, UINT cCount, BOOL fAddTransparentColor );
void InitializeFromBitmap([Optional] IWICBitmapSource pISurface, uint cCount, [MarshalAs(UnmanagedType.Bool)] bool fAddTransparentColor);
/// Initialize the palette based on a given palette.
///
/// Type: IWICPalette*
/// Pointer to the source palette.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpalette-initializefrompalette HRESULT
// InitializeFromPalette( IWICPalette *pIPalette );
void InitializeFromPalette(IWICPalette pIPalette);
/// Retrieves the WICBitmapPaletteType that describes the palette.
///
/// Type: WICBitmapPaletteType*
/// Pointer that receives the palette type of the bimtap.
///
///
/// WICBitmapPaletteCustom is used for palettes initialized from both InitializeCustom and InitializeFromBitmap. There is
/// no distinction is made between optimized and custom palettes.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpalette-gettype HRESULT GetType(
// WICBitmapPaletteType *pePaletteType );
WICBitmapPaletteType GetType();
/// Retrieves the number of colors in the color table.
///
/// Type: UINT*
/// Pointer that receives the number of colors in the color table.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpalette-getcolorcount HRESULT GetColorCount( UINT
// *pcCount );
uint GetColorCount();
///
/// Fills out the supplied color array with the colors from the internal color table. The color array should be sized according
/// to the return results from GetColorCount.
///
///
/// Type: UINT
/// The size of the pColors array.
///
///
/// Type: WICColor*
/// Pointer that receives the colors of the palette.
///
///
/// Type: UINT*
/// The actual size needed to obtain the palette colors.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpalette-getcolors HRESULT GetColors( UINT cCount,
// WICColor *pColors, UINT *pcActualColors );
void GetColors(uint cCount, [In] uint[] pColors, out uint pcActualColors);
/// Retrieves a value that describes whether the palette is black and white.
///
/// Type: BOOL*
///
/// A pointer to a variable that receives a boolean value that indicates whether the palette is black and white. TRUE
/// indicates that the palette is black and white; otherwise, FALSE.
///
///
///
/// A palette is considered to be black and white only if it contains exactly two entries, one full black (0xFF000000) and one
/// full white (0xFFFFFFF).
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpalette-isblackwhite HRESULT IsBlackWhite( BOOL
// *pfIsBlackWhite );
[return: MarshalAs(UnmanagedType.Bool)]
bool IsBlackWhite();
/// Retrieves a value that describes whether a palette is grayscale.
///
/// Type: BOOL*
///
/// A pointer to a variable that receives a boolean value that indicates whether the palette is grayscale. TRUE indicates
/// that the palette is grayscale; otherwise FALSE.
///
///
///
/// A palette is considered grayscale only if, for every entry, the alpha value is 0xFF and the red, green and blue values match.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpalette-isgrayscale HRESULT IsGrayscale( BOOL
// *pfIsGrayscale );
[return: MarshalAs(UnmanagedType.Bool)]
bool IsGrayscale();
///
/// Indicates whether the palette contains an entry that is non-opaque (that is, an entry with an alpha that is less than 1).
///
///
/// Type: BOOL*
/// Pointer that receives if the palette contains a transparent color; otherwise, .
///
///
/// Various image formats support alpha in different ways. PNG has full alpha support by supporting partially transparent
/// palette entries. GIF stores colors as 24bpp, without alpha, but allows one palette entry to be specified as fully
/// transparent. If a palette has multiple fully transparent entries (0x00RRGGBB), GIF will use the last one as its transparent index.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpalette-hasalpha HRESULT HasAlpha( BOOL
// *pfHasAlpha );
[return: MarshalAs(UnmanagedType.Bool)]
bool HasAlpha();
}
/// Exposes methods that provide additional load and save methods that take WICPersistOptions.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nn-wincodecsdk-iwicpersiststream
[PInvokeData("wincodecsdk.h", MSDNShortId = "9381cc2c-9554-4071-b9b5-3464d857c02d")]
[ComImport, Guid("00675040-6908-45F8-86A3-49C7DFD6D9AD"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICPersistStream : IPersistStream
{
/// Retrieves the class identifier (CLSID) of the object.
///
///
/// A pointer to the location that receives the CLSID on return. The CLSID is a globally unique identifier (GUID) that uniquely
/// represents an object class that defines the code that can manipulate the object's data.
///
/// If the method succeeds, the return value is S_OK. Otherwise, it is E_FAIL.
///
///
///
/// The GetClassID method retrieves the class identifier (CLSID) for an object, used in later operations to load
/// object-specific code into the caller's context.
///
/// Notes to Callers
///
/// A container application might call this method to retrieve the original CLSID of an object that it is treating as a
/// different class. Such a call would be necessary if a user performed an editing operation that required the object to be
/// saved. If the container were to save it using the treat-as CLSID, the original application would no longer be able to edit
/// the object. Typically, in this case, the container calls the OleSave helper function, which performs all the necessary
/// steps. For this reason, most container applications have no need to call this method directly.
///
///
/// The exception would be a container that provides an object handler for certain objects. In particular, a container
/// application should not get an object's CLSID and then use it to retrieve class specific information from the registry.
/// Instead, the container should use IOleObject and IDataObject interfaces to retrieve such class-specific information directly
/// from the object.
///
/// Notes to Implementers
///
/// Typically, implementations of this method simply supply a constant CLSID for an object. If, however, the object's
/// TreatAs registry key has been set by an application that supports emulation (and so is treating the object as one of
/// a different class), a call to GetClassID must supply the CLSID specified in the TreatAs key. For more
/// information on emulation, see CoTreatAsClass.
///
///
/// When an object is in the running state, the default handler calls an implementation of GetClassID that delegates the
/// call to the implementation in the object. When the object is not running, the default handler instead calls the ReadClassStg
/// function to read the CLSID that is saved in the object's storage.
///
///
/// If you are writing a custom object handler for your object, you might want to simply delegate this method to the default
/// handler implementation (see OleCreateDefaultHandler).
///
/// URL Moniker Notes
/// This method returns CLSID_StdURLMoniker.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersist-getclassid HRESULT GetClassID( CLSID *pClassID );
new Guid GetClassID();
/// Determines whether an object has changed since it was last saved to its stream.
/// This method returns S_OK to indicate that the object has changed. Otherwise, it returns S_FALSE.
///
///
/// Use this method to determine whether an object should be saved before closing it. The dirty flag for an object is
/// conditionally cleared in the IPersistStream::Save method.
///
/// Notes to Callers
///
/// You should treat any error return codes as an indication that the object has changed. Unless this method explicitly returns
/// S_FALSE, assume that the object must be saved.
///
///
/// Note that the OLE-provided implementations of the IPersistStream::IsDirty method in the OLE-provided moniker
/// interfaces always return S_FALSE because their internal state never changes.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-isdirty HRESULT IsDirty( );
[PreserveSig]
new HRESULT IsDirty();
/// Initializes an object from the stream where it was saved previously.
/// The PSTM.
///
///
/// This method loads an object from its associated stream. The seek pointer is set as it was in the most recent
/// IPersistStream::Save method. This method can seek and read from the stream, but cannot write to it.
///
/// Notes to Callers
///
/// Rather than calling IPersistStream::Load directly, you typically call the OleLoadFromStream function does the following:
///
///
/// -
/// Calls the ReadClassStm function to get the class identifier from the stream.
///
/// -
/// Calls the CoCreateInstance function to create an instance of the object.
///
/// -
/// Queries the instance for IPersistStream.
///
/// -
/// Calls IPersistStream::Load.
///
///
///
/// The OleLoadFromStream function assumes that objects are stored in the stream with a class identifier followed by the object
/// data. This storage pattern is used by the generic, composite-moniker implementation provided by OLE.
///
/// If the objects are not stored using this pattern, you must call the methods separately yourself.
/// URL Moniker Notes
///
/// Initializes an URL moniker from data within a stream, usually stored there previously using its IPersistStream::Save (using
/// OleSaveToStream). The binary format of the URL moniker is its URL string in Unicode (may be a full or partial URL string,
/// see CreateURLMonikerEx for details). This is represented as a ULONG count of characters followed by that many Unicode characters.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-load HRESULT Load( IStream *pStm );
new void Load([In, MarshalAs(UnmanagedType.Interface)] IStream pstm);
/// Saves an object to the specified stream.
/// The PSTM.
///
/// Indicates whether to clear the dirty flag after the save is complete. If TRUE, the flag should be cleared. If
/// FALSE, the flag should be left unchanged.
///
///
///
/// IPersistStream::Save saves an object into the specified stream and indicates whether the object should reset its
/// dirty flag.
///
///
/// The seek pointer is positioned at the location in the stream at which the object should begin writing its data. The object
/// calls the ISequentialStream::Write method to write its data.
///
///
/// On exit, the seek pointer must be positioned immediately past the object data. The position of the seek pointer is undefined
/// if an error returns.
///
/// Notes to Callers
///
/// Rather than calling IPersistStream::Save directly, you typically call the OleSaveToStream helper function which does
/// the following:
///
///
/// -
/// Calls GetClassID to get the object's CLSID.
///
/// -
/// Calls the WriteClassStm function to write the object's CLSID to the stream.
///
/// -
/// Calls IPersistStream::Save.
///
///
/// If you call these methods directly, you can write other data into the stream after the CLSID before calling IPersistStream::Save.
/// The OLE-provided implementation of IPersistStream follows this same pattern.
/// Notes to Implementers
///
/// The IPersistStream::Save method does not write the CLSID to the stream. The caller is responsible for writing the CLSID.
///
///
/// The IPersistStream::Save method can read from, write to, and seek in the stream; but it must not seek to a location
/// in the stream before that of the seek pointer on entry.
///
/// URL Moniker Notes
///
/// Saves an URL moniker to a stream. The binary format of URL moniker is its URL string in Unicode (may be a full or partial
/// URL string, see CreateURLMonikerEx for details). This is represented as a ULONG count of characters followed by that
/// many Unicode characters.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-save HRESULT Save( IStream *pStm, BOOL
// fClearDirty );
new void Save([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In, MarshalAs(UnmanagedType.Bool)] bool fClearDirty);
/// Retrieves the size of the stream needed to save the object.
/// The size in bytes of the stream needed to save this object, in bytes.
///
///
/// This method returns the size needed to save an object. You can call this method to determine the size and set the necessary
/// buffers before calling the IPersistStream::Save method.
///
/// Notes to Implementers
///
/// The GetSizeMax implementation should return a conservative estimate of the necessary size because the caller might
/// call the IPersistStream::Save method with a non-growable stream.
///
/// URL Moniker Notes
///
/// This method retrieves the maximum number of bytes in the stream that will be required by a subsequent call to
/// IPersistStream::Save. This value is sizeof(ULONG)==4 plus sizeof(WCHAR)*n where n is the length of the full or partial URL
/// string, including the NULL terminator.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-getsizemax HRESULT GetSizeMax(
// ULARGE_INTEGER *pcbSize );
new ulong GetSizeMax();
/// Loads data from an input stream using the given parameters.
///
/// Type: IStream*
/// Pointer to the input stream.
///
///
/// Type: const GUID*
/// Pointer to the GUID of the preferred vendor .
///
///
/// Type: DWORD
/// The WICPersistOptions used to load the stream.
///
/// NULL can be passed in for pguidPreferredVendor to indicate no preference.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicpersiststream-loadex HRESULT LoadEx(
// IStream *pIStream, const GUID *pguidPreferredVendor, DWORD dwPersistOptions );
void LoadEx([In, Optional] IStream pIStream, [In] SafeGuidPtr pguidPreferredVendor, WICPersistOptions dwPersistOptions);
/// Saves the IWICPersistStream to the given input IStream using the given parameters.
///
/// Type: IStream*
/// The stream to save to.
///
///
/// Type: DWORD
/// The WICPersistOptions to use when saving.
///
///
/// Type: BOOL
/// Indicates whether the "dirty" value will be cleared from all metadata after saving.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicpersiststream-saveex HRESULT SaveEx(
// IStream *pIStream, DWORD dwPersistOptions, BOOL fClearDirty );
void SaveEx([In, Optional] IStream pIStream, WICPersistOptions dwPersistOptions, [MarshalAs(UnmanagedType.Bool)] bool fClearDirty);
}
/// Exposes methods that provide information about a pixel format.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicpixelformatinfo
[PInvokeData("wincodec.h", MSDNShortId = "d5853b27-4329-40d8-bfd0-b4b0f39ba6d5")]
[ComImport, Guid("E8EDA601-3D48-431a-AB44-69059BE88BBE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICPixelFormatInfo : IWICComponentInfo
{
/// Retrieves the component's WICComponentType.
///
/// Type: WICComponentType*
/// A pointer that receives the WICComponentType.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getcomponenttype HRESULT
// GetComponentType( WICComponentType *pType );
new WICComponentType GetComponentType();
/// Retrieves the component's class identifier (CLSID)
///
/// Type: CLSID*
/// A pointer that receives the component's CLSID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getclsid HRESULT GetCLSID( CLSID
// *pclsid );
new Guid GetCLSID();
/// Retrieves the signing status of the component.
///
/// Type: DWORD*
/// A pointer that receives the WICComponentSigning status of the component.
///
///
/// Signing is unused by WIC. Therefore, all components WICComponentSigned.
///
/// This function can be used to determine whether a component has no binary component or has been added to the disabled
/// components list in the registry.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getsigningstatus HRESULT
// GetSigningStatus( DWORD *pStatus );
new WICComponentSigning GetSigningStatus();
/// Retrieves the name of component's author.
///
/// Type: UINT
/// The size of the wzAuthor buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the name of the component's author. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's authors name. The author name is optional; if an author name is
/// not specified by the component, the length returned is 0.
///
///
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getauthor HRESULT GetAuthor( UINT
// cchAuthor, WCHAR *wzAuthor, UINT *pcchActual );
new void GetAuthor(uint cchAuthor, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAuthor, out uint pcchActual);
/// Retrieves the vendor GUID.
///
/// Type: GUID*
/// A pointer that receives the component's vendor GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getvendorguid HRESULT
// GetVendorGUID( GUID *pguidVendor );
new Guid GetVendorGUID();
/// Retrieves the component's version.
///
/// Type: UINT
/// The size of the wzVersion buffer.
///
///
/// Type: WCHAR*
/// A pointer that receives a culture invariant string of the component's version.
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's version. The version is optional; if a value is not specified
/// by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getversion HRESULT GetVersion( UINT
// cchVersion, WCHAR *wzVersion, UINT *pcchActual );
new void GetVersion(uint cchVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzVersion, out uint pcchActual);
/// Retrieves the component's specification version.
///
/// Type: UINT
/// The size of the wzSpecVersion buffer.
///
///
/// Type: WCHAR*
///
/// When this method returns, contain a culture invarient string of the component's specification version. The version form is NN.NN.NN.NN.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's specification version. The specification version is optional;
/// if a value is not specified by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a spec version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getspecversion HRESULT
// GetSpecVersion( UINT cchSpecVersion, WCHAR *wzSpecVersion, UINT *pcchActual );
new void GetSpecVersion(uint cchSpecVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzSpecVersion, out uint pcchActual);
/// Retrieves the component's friendly name, which is a human-readable display name for the component.
///
/// Type: UINT
/// The size of the wzFriendlyName buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the friendly name of the component. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
/// A pointer that receives the actual length of the component's friendly name.
///
/// If cchFriendlyName is 0 and wzFriendlyName is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getfriendlyname HRESULT
// GetFriendlyName( UINT cchFriendlyName, WCHAR *wzFriendlyName, UINT *pcchActual );
new void GetFriendlyName(uint cchFriendlyName, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFriendlyName, out uint pcchActual);
/// Gets the pixel format GUID.
///
/// Type: GUID*
/// Pointer that receives the pixel format GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo-getformatguid HRESULT
// GetFormatGUID( GUID *pFormat );
Guid GetFormatGUID();
/// Gets the pixel format's IWICColorContext.
///
/// Type: IWICColorContext**
/// Pointer that receives the pixel format's color context.
///
///
/// The returned color context is the default color space for the pixel format. However, if an IWICBitmapSource specifies its
/// own color context, the source's context should be preferred over the pixel format's default.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo-getcolorcontext HRESULT
// GetColorContext( IWICColorContext **ppIColorContext );
IWICColorContext GetColorContext();
/// Gets the bits per pixel (BPP) of the pixel format.
///
/// Type: UINT*
/// Pointer that receives the BPP of the pixel format.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo-getbitsperpixel HRESULT
// GetBitsPerPixel( UINT *puiBitsPerPixel );
uint GetBitsPerPixel();
/// Gets the number of channels the pixel format contains.
///
/// Type: UINT*
/// Pointer that receives the channel count.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo-getchannelcount HRESULT
// GetChannelCount( UINT *puiChannelCount );
uint GetChannelCount();
/// Gets the pixel format's channel mask.
///
/// Type: UINT
/// The index to the channel mask to retrieve.
///
///
/// Type: UINT
/// The size of the pbMaskBuffer buffer.
///
///
/// Type: BYTE*
/// Pointer to the mask buffer.
///
///
/// Type: UINT*
/// The actual buffer size needed to obtain the channel mask.
///
///
/// If 0 and NULL are passed in for cbMaskBuffer and pbMaskBuffer, respectively, the required buffer size will be returned
/// through pcbActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo-getchannelmask HRESULT
// GetChannelMask( UINT uiChannelIndex, UINT cbMaskBuffer, BYTE *pbMaskBuffer, UINT *pcbActual );
void GetChannelMask(uint uiChannelIndex, uint cbMaskBuffer, [Out] IntPtr pbMaskBuffer, out uint pcbActual);
}
/// Extends IWICPixelFormatInfo by providing additional information about a pixel format.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicpixelformatinfo2
[PInvokeData("wincodec.h", MSDNShortId = "6c36fb08-f0c7-4654-bd8e-ef8ef737bc41")]
[ComImport, Guid("A9DB33A2-AF5F-43C7-B679-74F5984B5AA4"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICPixelFormatInfo2 : IWICPixelFormatInfo
{
/// Retrieves the component's WICComponentType.
///
/// Type: WICComponentType*
/// A pointer that receives the WICComponentType.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getcomponenttype HRESULT
// GetComponentType( WICComponentType *pType );
new WICComponentType GetComponentType();
/// Retrieves the component's class identifier (CLSID)
///
/// Type: CLSID*
/// A pointer that receives the component's CLSID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getclsid HRESULT GetCLSID( CLSID
// *pclsid );
new Guid GetCLSID();
/// Retrieves the signing status of the component.
///
/// Type: DWORD*
/// A pointer that receives the WICComponentSigning status of the component.
///
///
/// Signing is unused by WIC. Therefore, all components WICComponentSigned.
///
/// This function can be used to determine whether a component has no binary component or has been added to the disabled
/// components list in the registry.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getsigningstatus HRESULT
// GetSigningStatus( DWORD *pStatus );
new WICComponentSigning GetSigningStatus();
/// Retrieves the name of component's author.
///
/// Type: UINT
/// The size of the wzAuthor buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the name of the component's author. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's authors name. The author name is optional; if an author name is
/// not specified by the component, the length returned is 0.
///
///
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getauthor HRESULT GetAuthor( UINT
// cchAuthor, WCHAR *wzAuthor, UINT *pcchActual );
new void GetAuthor(uint cchAuthor, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAuthor, out uint pcchActual);
/// Retrieves the vendor GUID.
///
/// Type: GUID*
/// A pointer that receives the component's vendor GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getvendorguid HRESULT
// GetVendorGUID( GUID *pguidVendor );
new Guid GetVendorGUID();
/// Retrieves the component's version.
///
/// Type: UINT
/// The size of the wzVersion buffer.
///
///
/// Type: WCHAR*
/// A pointer that receives a culture invariant string of the component's version.
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's version. The version is optional; if a value is not specified
/// by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getversion HRESULT GetVersion( UINT
// cchVersion, WCHAR *wzVersion, UINT *pcchActual );
new void GetVersion(uint cchVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzVersion, out uint pcchActual);
/// Retrieves the component's specification version.
///
/// Type: UINT
/// The size of the wzSpecVersion buffer.
///
///
/// Type: WCHAR*
///
/// When this method returns, contain a culture invarient string of the component's specification version. The version form is NN.NN.NN.NN.
///
///
///
/// Type: UINT*
///
/// A pointer that receives the actual length of the component's specification version. The specification version is optional;
/// if a value is not specified by the component, the length returned is 0.
///
///
///
/// All built-in components return "1.0.0.0", except for pixel formats, which do not have a spec version.
/// If cchAuthor is 0 and wzAuthor is NULL, the required buffer size is returned in pccchActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getspecversion HRESULT
// GetSpecVersion( UINT cchSpecVersion, WCHAR *wzSpecVersion, UINT *pcchActual );
new void GetSpecVersion(uint cchSpecVersion, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzSpecVersion, out uint pcchActual);
/// Retrieves the component's friendly name, which is a human-readable display name for the component.
///
/// Type: UINT
/// The size of the wzFriendlyName buffer.
///
///
/// Type: WCHAR*
///
/// A pointer that receives the friendly name of the component. The locale of the string depends on the value that the codec
/// wrote to the registry at install time. For built-in components, these strings are always in English.
///
///
///
/// Type: UINT*
/// A pointer that receives the actual length of the component's friendly name.
///
/// If cchFriendlyName is 0 and wzFriendlyName is NULL, the required buffer size is returned in pccchActual.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwiccomponentinfo-getfriendlyname HRESULT
// GetFriendlyName( UINT cchFriendlyName, WCHAR *wzFriendlyName, UINT *pcchActual );
new void GetFriendlyName(uint cchFriendlyName, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFriendlyName, out uint pcchActual);
/// Gets the pixel format GUID.
///
/// Type: GUID*
/// Pointer that receives the pixel format GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo-getformatguid HRESULT
// GetFormatGUID( GUID *pFormat );
new Guid GetFormatGUID();
/// Gets the pixel format's IWICColorContext.
///
/// Type: IWICColorContext**
/// Pointer that receives the pixel format's color context.
///
///
/// The returned color context is the default color space for the pixel format. However, if an IWICBitmapSource specifies its
/// own color context, the source's context should be preferred over the pixel format's default.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo-getcolorcontext HRESULT
// GetColorContext( IWICColorContext **ppIColorContext );
new IWICColorContext GetColorContext();
/// Gets the bits per pixel (BPP) of the pixel format.
///
/// Type: UINT*
/// Pointer that receives the BPP of the pixel format.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo-getbitsperpixel HRESULT
// GetBitsPerPixel( UINT *puiBitsPerPixel );
new uint GetBitsPerPixel();
/// Gets the number of channels the pixel format contains.
///
/// Type: UINT*
/// Pointer that receives the channel count.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo-getchannelcount HRESULT
// GetChannelCount( UINT *puiChannelCount );
new uint GetChannelCount();
/// Gets the pixel format's channel mask.
///
/// Type: UINT
/// The index to the channel mask to retrieve.
///
///
/// Type: UINT
/// The size of the pbMaskBuffer buffer.
///
///
/// Type: BYTE*
/// Pointer to the mask buffer.
///
///
/// Type: UINT*
/// The actual buffer size needed to obtain the channel mask.
///
///
/// If 0 and NULL are passed in for cbMaskBuffer and pbMaskBuffer, respectively, the required buffer size will be returned
/// through pcbActual.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo-getchannelmask HRESULT
// GetChannelMask( UINT uiChannelIndex, UINT cbMaskBuffer, BYTE *pbMaskBuffer, UINT *pcbActual );
new void GetChannelMask(uint uiChannelIndex, uint cbMaskBuffer, [Out] IntPtr pbMaskBuffer, out uint pcbActual);
/// Returns whether the format supports transparent pixels.
///
/// Type: BOOL*
/// Returns TRUE if the pixel format supports transparency; otherwise, FALSE.
///
/// An indexed pixel format will not return TRUE even though it may have some transparency support.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo2-supportstransparency HRESULT
// SupportsTransparency( BOOL *pfSupportsTransparency );
[return: MarshalAs(UnmanagedType.Bool)]
bool SupportsTransparency();
/// Retrieves the WICPixelFormatNumericRepresentation of the pixel format.
///
/// Type: WICPixelFormatNumericRepresentation*
///
/// The address of a WICPixelFormatNumericRepresentation variable that you've defined. On successful completion, the function
/// sets your variable to the WICPixelFormatNumericRepresentation of the pixel format.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicpixelformatinfo2-getnumericrepresentation HRESULT
// GetNumericRepresentation( WICPixelFormatNumericRepresentation *pNumericRepresentation );
WICPixelFormatNumericRepresentation GetNumericRepresentation();
}
///
///
/// Allows planar component image pixels to be written to an encoder. When supported by the encoder, this allows an application to
/// encode planar component image data without first converting to an interleaved pixel format.
///
/// You can use
///
/// QueryInterface to obtain this interface from the Windows provided implementation of IWICBitmapFrameEncode for the JPEG encoder.
///
///
///
/// Encoding YCbCr data using IWICPlanarBitmapFrameEncode is similar but not identical to encoding interleaved data using
/// IWICBitmapFrameEncode. The planar interface only exposes the ability to write planar frame image data, and you should continue
/// to use the frame encode interface to set metadata or a thumbnail and to commit at the end of the operation.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicplanarbitmapframeencode
[PInvokeData("wincodec.h", MSDNShortId = "7ACA58CC-E132-4836-B955-322375ADDAA1")]
[ComImport, Guid("F928B7B8-2221-40C1-B72E-7E82F1974D1A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICPlanarBitmapFrameEncode
{
/// Writes lines from the source planes to the encoded format.
///
/// Type: UINT
/// The number of lines to encode. See the Remarks section for WIC Jpeg specific line count restrictions.
///
///
/// Type: WICBitmapPlane*
/// Specifies the source buffers for each component plane encoded.
///
///
/// Type: UINT
/// The number of component planes specified by the pPlanes parameter.
///
///
///
/// Successive WritePixels calls are assumed sequentially add scanlines to the output image.
/// IWICBitmapFrameEncode::Initialize, IWICBitmapFrameEncode::SetSize and IWICBitmapFrameEncode::SetPixelFormat must be called
/// before this method or it will fail.
///
///
/// The interleaved pixel format set via IWICBitmapFrameEncode::SetPixelFormat and the codec specific encode parameters
/// determine the supported planar formats.
///
///
/// WIC JPEG Encoder: QueryInterface can be used to obtain this interface from the WIC JPEG IWICBitmapFrameEncode
/// implementation. When using this method to encode Y’CbCr data with the WIC JPEG encoder, chroma subsampling can be configured
/// with encoder options during frame creation. See the Encoding Overview and IWICBitmapEncoder::CreateNewFrame for more details.
///
/// Depending upon the configured chroma subsampling, the lineCount parameter has the following restrictions:
///
///
/// Chroma Subsampling
/// Line Count Restriction
/// Chroma Plane Width
/// Chroma Plane Height
///
/// -
/// 4:2:0
/// Multiple of 2, unless the call covers the last scanline of the image
/// lumaWidth / 2 Rounded up to the nearest integer.
/// lumaHeight / 2 Rounded up to the nearest integer.
///
/// -
/// 4:2:2
/// Any
/// lumaWidth / 2 Rounded up to the nearest integer.
/// Any
///
/// -
/// 4:4:4
/// Any
/// Any
/// Any
///
/// -
/// 4:4:0
/// Multiple of 2, unless the call covers the last scanline of the image
/// Any
/// llumaHeight / 2 Rounded up to the nearest integer.
///
///
/// The full scanline width must be encoded, and the width of the bitmap sources must match their planar configuration.
/// Additionally, if a pixel format is set via IWICBitmapFrameEncode::SetPixelFormat, it must be GUID_WICPixelFormat24bppBGR.
/// The supported pixel formats of the bitmap sources passed into this method are as follows:
///
///
/// Plane Count
/// Plane 1
/// Plane 2
/// Plane 3
///
/// -
/// 3
/// GUID_WICPixelFormat8bppY
/// GUID_WICPixelFormat8bppCb
/// GUID_WICPixelFormat8bppCr
///
/// -
/// 2
/// GUID_WICPixelFormat8bppY
/// GUID_WICPixelFormat16bppCbCr
/// N/A
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicplanarbitmapframeencode-writepixels HRESULT
// WritePixels( UINT lineCount, WICBitmapPlane *pPlanes, UINT cPlanes );
void WritePixels(uint lineCount, [In] WICBitmapPlane[] pPlanes, uint cPlanes);
/// Writes lines from the source planes to the encoded format.
///
/// Type: IWICBitmapSource**
/// Specifies an array of IWICBitmapSource that represent image planes.
///
///
/// Type: UINT
/// The number of component planes specified by the planes parameter.
///
///
/// Type: WICRect*
///
/// The source rectangle of pixels to encode from the IWICBitmapSource planes. Null indicates the entire source. The source rect
/// width must match the width set through SetSize. Repeated WriteSource calls can be made as long as the total
/// accumulated source rect height is the same as set through SetSize.
///
///
///
///
/// Successive WriteSource calls are assumed sequentially add scanlines to the output image.
/// IWICBitmapFrameEncode::Initialize, IWICBitmapFrameEncode::SetSize and IWICBitmapFrameEncode::SetPixelFormat must be called
/// before this method or it will fail.
///
///
/// The interleaved pixel format set via IWICBitmapFrameEncode::SetPixelFormat and the codec specific encode parameters
/// determine the supported planar formats.
///
///
/// WIC JPEG Encoder: QueryInterface can be used to obtain this interface from the WIC JPEG IWICBitmapFrameEncode
/// implementation. When using this method to encode Y’CbCr data with the WIC JPEG encoder, chroma subsampling can be configured
/// with encoder options during frame creation. See the Encoding Overview and IWICBitmapEncoder::CreateNewFrame for more details.
///
/// Depending upon the configured chroma subsampling, the lineCount parameter has the following restrictions:
///
///
/// Chroma Subsampling
/// X Coordinate
/// Y Coordinate
/// Chroma Width
/// Chroma Height
///
/// -
/// 4:2:0
/// Multiple of 2
/// Multiple of 2
/// lumaWidth / 2 Rounded up to the nearest integer.
/// lumaHeight / 2 Rounded up to the nearest integer.
///
/// -
/// 4:2:2
/// Multiple of 2
/// Any
/// lumaWidth / 2 Rounded up to the nearest integer.
/// Any
///
/// -
/// 4:4:4
/// Any
/// Any
/// Any
/// Any
///
/// -
/// 4:4:0
/// Any
/// Multiple of 2
/// lumaWidth
/// llumaHeight / 2 Rounded up to the nearest integer.
///
///
/// The full scanline width must be encoded, and the width of the bitmap sources must match their planar configuration.
/// Additionally, if a pixel format is set via IWICBitmapFrameEncode::SetPixelFormat, it must be GUID_WICPixelFormat24bppBGR.
/// The supported pixel formats of the bitmap sources passed into this method are as follows:
///
///
/// Plane Count
/// Plane 1
/// Plane 2
/// Plane 3
///
/// -
/// 3
/// GUID_WICPixelFormat8bppY
/// GUID_WICPixelFormat8bppCb
/// GUID_WICPixelFormat8bppCr
///
/// -
/// 2
/// GUID_WICPixelFormat8bppY
/// GUID_WICPixelFormat16bppCbCr
/// N/A
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicplanarbitmapframeencode-writesource HRESULT
// WriteSource( IWICBitmapSource **ppPlanes, UINT cPlanes, WICRect *prcSource );
void WriteSource([In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 1)] IWICBitmapSource[] ppPlanes, uint cPlanes, [In] PWICRect prcSource);
}
///
///
/// Provides access to planar Y’CbCr pixel formats where pixel components are stored in separate component planes. This interface
/// also allows access to other codec optimizations for flip/rotate, scale, and format conversion to other Y’CbCr planar formats;
/// this is similar to the pre-existing IWICBitmapSourceTransform interface.
///
///
/// QueryInterface can be used to obtain this interface from the Windows provided implementations of IWICBitmapFrameDecode for the
/// JPEG decoder, IWICBitmapScaler, IWICBitmapFlipRotator, and IWICColorTransform.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicplanarbitmapsourcetransform
[ComImport, Guid("3AFF9CCE-BE95-4303-B927-E7D16FF4A613"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICPlanarBitmapSourceTransform
{
///
///
/// Use this method to determine if a desired planar output is supported and allow the caller to choose an optimized code path
/// if it is. Otherwise, callers should fall back to IWICBitmapSourceTransform or IWICBitmapSource and retrieve interleaved pixels.
///
/// The following transforms can be checked:
///
/// -
/// Determine if the flip/rotate option specified via WICBitmapTransformOptions is supported.
///
/// -
/// Determine if the requested planar pixel format configuration is supported.
///
/// -
/// Determine the closest dimensions the implementation can natively scale to given the desired dimensions.
///
///
///
/// When a transform is supported, this method returns the description of the resulting planes in the pPlaneDescriptions parameter.
///
///
///
/// Type: UINT*
///
/// On input, the desired width. On output, the closest supported width to the desired width; this is the same size or larger
/// than the desired width.
///
///
///
/// Type: UINT*
///
/// On input, the desired height. On output, the closest supported height to the desired height; this is the same size or larger
/// than the desired width.
///
///
///
/// Type: WICBitmapTransformOptions
///
/// The desired rotation or flip operation. Multiple WICBitmapTransformOptions can be combined in this flag parameter, see WICBitmapTransformOptions.
///
///
///
/// Type: WICPlanarOptions
/// Used to specify additional configuration options for the transform. See WICPlanarOptions for more detail.
/// WIC JPEG Decoder:
///
/// WICPlanarOptionsPreserveSubsampling can be specified to retain the subsampling ratios when downscaling. By default, the JPEG
/// decoder attempts to preserve quality by downscaling only the Y plane in some cases, changing the image to 4:4:4 chroma subsampling.
///
///
///
/// Type: const WICPixelFormatGUID*
/// The requested pixel formats of the respective planes.
///
///
/// Type: WICBitmapPlaneDescription*
/// When *pfIsSupported == TRUE, the array of plane descriptions contains the size and format of each of the planes.
///
/// WIC JPEG Decoder: The Cb and Cr planes can be a different size from the values returned by puiWidth and puiHeight due to
/// chroma subsampling.
///
///
///
/// Type: UINT
/// The number of component planes requested.
///
///
/// Type: BOOL*
/// Set to TRUE if the requested transforms are natively supported.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicplanarbitmapsourcetransform-doessupporttransform
// HRESULT DoesSupportTransform( UINT *puiWidth, UINT *puiHeight, WICBitmapTransformOptions dstTransform, WICPlanarOptions
// dstPlanarOptions, const WICPixelFormatGUID *pguidDstFormats, WICBitmapPlaneDescription *pPlaneDescriptions, UINT cPlanes,
// BOOL *pfIsSupported );
[return: MarshalAs(UnmanagedType.Bool)]
bool DoesSupportTransform(ref uint puiWidth, ref uint puiHeight, WICBitmapTransformOptions dstTransform, WICPlanarOptions dstPlanarOptions, [In] Guid[] pguidDstFormats, [Out] WICBitmapPlaneDescription[] pPlaneDescriptions, uint cPlanes);
///
/// Copies pixels into the destination planes. Configured by the supplied input parameters.
///
/// If a dstTransform, scale, or format conversion is specified, cbStride is the transformed stride and is based on the
/// destination pixel format of the pDstPlanes parameter, not the original source's pixel format.
///
///
///
/// Type: const WICRect*
/// The source rectangle of pixels to copy.
///
///
/// Type: UINT
///
/// The width to scale the source bitmap. This parameter must be equal to a value obtainable through
/// IWICPlanarBitmapSourceTransform:: DoesSupportTransform.
///
///
///
/// Type: UINT
///
/// The height to scale the source bitmap. This parameter must be equal to a value obtainable through
/// IWICPlanarBitmapSourceTransform:: DoesSupportTransform.
///
///
///
/// Type: WICBitmapTransformOptions
///
/// The desired rotation or flip to perform prior to the pixel copy. A rotate can be combined with a flip horizontal or a flip
/// vertical, see WICBitmapTransformOptions.
///
///
///
/// Type: const WICPlanarOptions
/// Used to specify additional configuration options for the transform. See WICPlanarOptions for more detail.
///
/// WIC JPEG Decoder: WICPlanarOptionsPreserveSubsampling can be specified to retain the subsampling ratios when downscaling. By
/// default, the JPEG decoder attempts to preserve quality by downscaling only the Y plane in some cases, changing the image to
/// 4:4:4 chroma subsampling.
///
///
///
/// Type: WICBitmapPlane
///
/// Specifies the pixel format and output buffer for each component plane. The number of planes and pixel format of each plane
/// must match values obtainable through IWICPlanarBitmapSourceTransform::DoesSupportTransform.
///
///
///
/// Type: UINT
/// The number of component planes specified by the pDstPlanes parameter.
///
///
///
/// WIC JPEG Decoder: Depending on the configured chroma subsampling of the image, the source rectangle has the following restrictions:
///
///
///
/// Chroma Subsampling
/// X Coordinate
/// Y Coordinate
/// Chroma Width
/// Chroma Height
///
/// -
/// 4:2:0
/// Multiple of 2
/// Multiple of 2
/// lumaWidth / 2 Rounded up to the nearest integer.
/// lumaHeight / 2 Rounded up to the nearest integer.
///
/// -
/// 4:2:2
/// Multiple of 2
/// Any
/// lumaWidth / 2 Rounded up to the nearest integer.
/// lumaHeight
///
/// -
/// 4:4:4
/// Any
/// Any
/// llumaWidth
/// llumaHeight
///
/// -
/// 4:4:0
/// Any
/// Multiple of 2
/// lumaWidth
/// llumaHeight / 2 Rounded up to the nearest integer.
///
///
/// The pDstPlanes parameter supports the following pixel formats.
///
///
/// Plane Count
/// Plane 1
/// Plane 2
/// Plane 3
///
/// -
/// 3
/// GUID_WICPixelFormat8bppY
/// GUID_WICPixelFormat8bppCb
/// GUID_WICPixelFormat8bppCr
///
/// -
/// 2
/// GUID_WICPixelFormat8bppY
/// GUID_WICPixelFormat16bppCbCr
/// N/A
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicplanarbitmapsourcetransform-copypixels HRESULT
// CopyPixels( const WICRect *prcSource, UINT uiWidth, UINT uiHeight, WICBitmapTransformOptions dstTransform, WICPlanarOptions
// dstPlanarOptions, const WICBitmapPlane *pDstPlanes, UINT cPlanes );
void CopyPixels([In] PWICRect prcSource, uint uiWidth, uint uiHeight, WICBitmapTransformOptions dstTransform, WICPlanarOptions dstPlanarOptions, [In] WICBitmapPlane[] pDstPlanes, uint cPlanes);
}
///
/// Allows a format converter to be initialized with a planar source. You can use QueryInterface to obtain this interface from the
/// Windows provided implementation of IWICFormatConverter.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicplanarformatconverter
[PInvokeData("wincodec.h", MSDNShortId = "07258A07-84AA-4DC2-B2E3-14A43AED5617")]
[ComImport, Guid("BEBEE9CB-83B0-4DCC-8132-B0AAA55EAC96"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICPlanarFormatConverter : IWICBitmapSource
{
/// Retrieves the pixel width and height of the bitmap.
///
/// Type: UINT*
/// A pointer that receives the pixel width of the bitmap.
///
///
/// Type: UINT*
/// A pointer that receives the pixel height of the bitmap
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapsource-getsize HRESULT GetSize( UINT
// *puiWidth, UINT *puiHeight );
new void GetSize(out uint puiWidth, out uint puiHeight);
/// Retrieves the pixel format of the bitmap source..
///
/// Receives the pixel format GUID the bitmap is stored in. For a list of available pixel formats, see the Native Pixel Formats topic.
///
///
/// The pixel format returned by this method is not necessarily the pixel format the image is stored as. The codec may perform a
/// format conversion from the storage pixel format to an output pixel format.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapsource-getpixelformat HRESULT
// GetPixelFormat( Guid *pPixelFormat );
new Guid GetPixelFormat();
/// Retrieves the sampling rate between pixels and physical world measurements.
///
/// Type: double*
/// A pointer that receives the x-axis dpi resolution.
///
///
/// Type: double*
/// A pointer that receives the y-axis dpi resolution.
///
///
///
/// Some formats, such as GIF and ICO, do not have full DPI support. For GIF, this method calculates the DPI values from the
/// aspect ratio, using a base DPI of (96.0, 96.0). The ICO format does not support DPI at all, and the method always returns
/// (96.0,96.0) for ICO images.
///
///
/// Additionally, WIC itself does not transform images based on the DPI values in an image. It is up to the caller to transform
/// an image based on the resolution returned.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapsource-getresolution HRESULT GetResolution(
// double *pDpiX, double *pDpiY );
new void GetResolution(out double pDpiX, out double pDpiY);
/// Retrieves the color table for indexed pixel formats.
///
/// Type: IWICPalette*
/// An IWICPalette. A palette can be created using the CreatePalette method.
///
///
/// Type: HRESULT
/// Returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// WINCODEC_ERR_PALETTEUNAVAILABLE
/// The palette was unavailable.
///
/// -
/// S_OK
/// The palette was successfully copied.
///
///
///
///
/// If the IWICBitmapSource is an IWICBitmapFrameDecode, the function may return the image's global palette if a frame-level
/// palette is not available. The global palette may also be retrieved using the CopyPalette method.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapsource-copypalette HRESULT CopyPalette(
// IWICPalette *pIPalette );
[PreserveSig]
new HRESULT CopyPalette(IWICPalette pIPalette);
/// Instructs the object to produce pixels.
///
/// Type: const WICRect*
/// The rectangle to copy. A NULL value specifies the entire bitmap.
///
///
/// Type: UINT
/// The stride of the bitmap
///
///
/// Type: UINT
/// The size of the buffer.
///
///
/// Type: BYTE*
/// A pointer to the buffer.
///
///
/// Type: HRESULT
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing.
/// It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored
/// on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent
/// on the object implementing the interface.
///
///
/// The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must
/// be fully contained in the bounds of the bitmap. Specifying a NULL ROI implies that the whole bitmap should be returned.
///
///
/// The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along
/// with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent
/// pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width,
/// height and pixel format of the bitmap and the sub-rectangle provided to the copy method.
///
///
/// If the caller needs to perform numerous copies of an expensive IWICBitmapSource such as a JPEG, it is recommended to create
/// an in-memory IWICBitmap first.
///
/// Codec Developer Remarks
///
/// The callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this
/// case, a line is a consecutive string of cbStride bytes).
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapsource-copypixels HRESULT CopyPixels( const
// WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer );
new void CopyPixels([In, Optional] PWICRect prc, uint cbStride, uint cbBufferSize, [In, Out] IntPtr pbBuffer);
/// Initializes a format converter with a planar source, and specifies the interleaved output pixel format.
///
/// Type: IWICBitmapSource**
/// An array of IWICBitmapSource that represents image planes.
///
///
/// Type: UINT
/// The number of component planes specified by the planes parameter.
///
///
/// Type: REFWICPixelFormatGUID
/// The destination interleaved pixel format.
///
///
/// Type: WICBitmapDitherType
/// The WICBitmapDitherType used for conversion.
///
///
/// Type: IWICPalette*
/// The palette to use for conversion.
///
///
/// Type: double
/// The alpha threshold to use for conversion.
///
///
/// Type: WICBitmapPaletteType
/// The palette translation type to use for conversion.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicplanarformatconverter-initialize HRESULT
// Initialize( IWICBitmapSource **ppPlanes, UINT cPlanes, REFWICPixelFormatGUID dstFormat, WICBitmapDitherType dither,
// IWICPalette *pIPalette, double alphaThresholdPercent, WICBitmapPaletteType paletteTranslate );
void Initialize([In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 1)] IWICBitmapSource[] ppPlanes, uint cPlanes,
in Guid dstFormat, WICBitmapDitherType dither, [Optional] IWICPalette pIPalette, double alphaThresholdPercent, WICBitmapPaletteType paletteTranslate);
/// Query if the format converter can convert from one format to another.
/// An array of WIC pixel formats that represents source image planes.
/// The number of source pixel formats specified by the pSrcFormats parameter.
/// The destination interleaved pixel format.
/// True if the conversion is supported.
/// To specify an interleaved input pixel format, provide a length 1 array to pSrcPixelFormats.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicplanarformatconverter-canconvert HRESULT
// CanConvert( const WICPixelFormatGUID *pSrcPixelFormats, UINT cSrcPlanes, REFWICPixelFormatGUID dstPixelFormat, BOOL
// *pfCanConvert );
[return: MarshalAs(UnmanagedType.Bool)]
bool CanConvert([In] Guid[] pSrcPixelFormats, uint cSrcPlanes, in Guid dstPixelFormat);
}
///
/// IWICProgressCallback interface is documented only for compliance; its use is not recommended and may be altered or
/// unavailable in the future. Instead, and use RegisterProgressNotification.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicprogresscallback
[PInvokeData("wincodec.h", MSDNShortId = "cd94e0a1-c275-458e-ae7f-85b703fc660e")]
[ComImport, Guid("4776F9CD-9517-45FA-BF24-E89C5EC5C60C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICProgressCallback
{
///
/// Notify method is documented only for compliance; its use is not recommended and may be altered or unavailable in the
/// future. Instead, and use RegisterProgressNotification.
///
///
/// Type: ULONG
/// The current frame number.
///
///
/// Type: WICProgressOperation
/// The operation on which progress is being reported.
///
///
/// Type: double
///
/// The progress value ranging from is 0.0 to 1.0. 0.0 indicates the beginning of the operation. 1.0 indicates the end of the operation.
///
///
///
/// Type: HRESULT
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicprogresscallback-notify HRESULT Notify( ULONG
// uFrameNum, WICProgressOperation operation, double dblProgress );
[PreserveSig]
HRESULT Notify(uint uFrameNum, WICProgressOperation operation, double dblProgress);
}
/// Exposes methods for obtaining information about and controlling progressive decoding.
///
///
/// Images can only be progressively decoded if they were progressively encoded. Progressive images automatically start at the
/// highest (best quality) progressive level. The caller must manually set the decoder to a lower progressive level.
///
/// E_NOTIMPL is returned if the codec does not support progressive level decoding.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicprogressivelevelcontrol
[PInvokeData("wincodec.h", MSDNShortId = "d77244bc-b9d4-4b7d-b718-4ee38de46614")]
[ComImport, Guid("DAAC296F-7AA5-4dbf-8D15-225C5976F891"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICProgressiveLevelControl
{
/// Gets the number of levels of progressive decoding supported by the CODEC.
///
/// Type: UINT*
/// Indicates the number of levels supported by the CODEC.
///
///
///
/// Users should not use this function to iterate through the progressive levels of a progressive JPEG image. JPEG progressive
/// levels are determined by the image and do not have a fixed level count. Using this method will force the application to wait
/// for all progressive levels to be downloaded before it can return. Instead, applications should use the following code to
/// iterate through the progressive levels of a progressive JPEG image.
///
/// Examples
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicprogressivelevelcontrol-getlevelcount HRESULT
// GetLevelCount( UINT *pcLevels );
uint GetLevelCount();
/// Gets the decoder's current progressive level.
///
/// Type: UINT*
/// Indicates the current level specified.
///
///
/// The level always defaults to the highest progressive level. In order to decode a lower progressive level, SetCurrentLevel
/// must first be called.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicprogressivelevelcontrol-getcurrentlevel HRESULT
// GetCurrentLevel( UINT *pnLevel );
uint GetCurrentLevel();
/// Specifies the level to retrieve on the next call to CopyPixels.
///
/// Type: UINT
/// Specifies which level to return next. If greater than the total number of levels supported, an error will be returned.
///
///
///
/// A call does not have to request every level supported. If a caller requests level 1, without having previously requested
/// level 0, the bits returned by the next call to CopyPixels will include both levels.
///
/// If the requested level is invalid, the error returned is WINCODEC_ERR_INVALIDPROGRESSIVELEVEL.
/// Examples
///
/// Users should use this method to iterate through the progressive levels of a progressive JPEG image rather than the
/// GetCurrentLevel method. JPEG progressive levels are determined by the image and do not have a fixed level count. Using
/// GetCurrentLevel method will force the application to wait for all progressive levels to be downloaded before it can
/// return. Instead, applications should use the following code to iterate through the progressive levels of a progressive JPEG image.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicprogressivelevelcontrol-setcurrentlevel HRESULT
// SetCurrentLevel( UINT nLevel );
void SetCurrentLevel(uint nLevel);
}
/// Represents a Windows Imaging Component (WIC) stream for referencing imaging and metadata content.
///
///
/// Decoders and metadata handlers are expected to create sub streams of whatever stream they hold when handing off control for
/// embedded metadata to another metadata handler. If the stream is not restricted then use MAXLONGLONG as the max size and offset 0.
///
///
/// The IWICStream interface methods do not enable you to provide a file sharing option. To create a file stream for an
/// image, use the SHCreateStreamOnFileEx function. This stream can then be used to create an IWICBitmapDecoder using the
/// CreateDecoderFromStream method.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicstream
[PInvokeData("wincodec.h", MSDNShortId = "bc398732-037d-4f48-940f-c70975447972")]
[ComImport, Guid("135FF860-22B7-4ddf-B0F6-218F4F299A43"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICStream : IStream
{
///
new void Read(byte[] pv, int cb, IntPtr pcbRead);
///
new void Write(byte[] pv, int cb, IntPtr pcbWritten);
///
new void Seek(long dlibMove, int dwOrigin, IntPtr plibNewPosition);
///
new void SetSize(long libNewSize);
///
new void CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten);
///
new void Commit(int grfCommitFlags);
///
new void Revert();
///
new void LockRegion(long libOffset, long cb, int dwLockType);
///
new void UnlockRegion(long libOffset, long cb, int dwLockType);
///
new void Stat(out System.Runtime.InteropServices.ComTypes.STATSTG pstatstg, int grfStatFlag);
///
new void Clone(out IStream ppstm);
/// Initializes a stream from another stream. Access rights are inherited from the underlying stream.
///
/// Type: IStream*
/// The initialize stream.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicstream-initializefromistream HRESULT
// InitializeFromIStream( IStream *pIStream );
void InitializeFromIStream(IStream pIStream);
/// Initializes a stream from a particular file.
///
/// Type: LPCWSTR
/// The file used to initialize the stream.
///
///
/// Type: DWORD
/// The desired file access mode.
///
///
/// Value
/// Meaning
///
/// -
/// GENERIC_READ
/// Read access.
///
/// -
/// GENERIC_WRITE
/// Write access.
///
///
///
///
///
/// The IWICStream interface methods do not enable you to provide a file sharing option. To create a shared file stream for an
/// image, use the SHCreateStreamOnFileEx function. This stream can then be used to create an IWICBitmapDecoder using the
/// CreateDecoderFromStream method.
///
/// Examples
/// This example demonstrates the use of the InitializeFromFilename to create an image decoder.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicstream-initializefromfilename HRESULT
// InitializeFromFilename( LPCWSTR wzFileName, DWORD dwDesiredAccess );
void InitializeFromFilename([MarshalAs(UnmanagedType.LPWStr)] string wzFileName, ACCESS_MASK dwDesiredAccess);
/// Initializes a stream to treat a block of memory as a stream. The stream cannot grow beyond the buffer size.
///
/// Type: BYTE*
/// Pointer to the buffer used to initialize the stream.
///
///
/// Type: DWORD
/// The size of buffer.
///
///
///
/// This method should be avoided whenever possible. The caller is responsible for ensuring the memory block is valid for the
/// lifetime of the stream when using InitializeFromMemory. A workaround for this behavior is to create an IStream and
/// use InitializeFromIStream to create the IWICStream.
///
/// If you require a growable memory stream, use CreateStreamOnHGlobal.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicstream-initializefrommemory HRESULT
// InitializeFromMemory( WICInProcPointer pbBuffer, DWORD cbBufferSize );
void InitializeFromMemory([In] IntPtr pbBuffer, uint cbBufferSize);
/// Initializes the stream as a substream of another stream.
///
/// Type: IStream*
/// Pointer to the input stream.
///
///
/// Type: ULARGE_INTEGER
/// The stream offset used to create the new stream.
///
///
/// Type: ULARGE_INTEGER
/// The maximum size of the stream.
///
///
/// The stream functions with its own stream position, independent of the underlying stream but restricted to a region. All seek
/// positions are relative to the sub region. It is allowed, though not recommended, to have multiple writable sub streams
/// overlapping the same range.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicstream-initializefromistreamregion HRESULT
// InitializeFromIStreamRegion( IStream *pIStream, ULARGE_INTEGER ulOffset, ULARGE_INTEGER ulMaxSize );
void InitializeFromIStreamRegion(IStream pIStream, ulong ulOffset, ulong ulMaxSize);
}
/// Exposes methods for a stream provider.
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nn-wincodecsdk-iwicstreamprovider
[PInvokeData("wincodecsdk.h", MSDNShortId = "fdcaf668-a5c3-4852-8bc9-5535f0756592")]
[ComImport, Guid("449494BC-B468-4927-96D7-BA90D31AB505"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWICStreamProvider
{
/// Gets the stream held by the component.
///
/// Type: IStream**
/// Pointer that receives a pointer to the stream held by the component.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicstreamprovider-getstream HRESULT GetStream(
// IStream **ppIStream );
IStream GetStream();
/// Gets the persist options used when initializing the component with a stream.
///
/// Type: DWORD*
///
/// Pointer that receives the persist options used when initializing the component with a stream. If none were provided,
/// WICPersistOptionDefault is returned.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicstreamprovider-getpersistoptions HRESULT
// GetPersistOptions( DWORD *pdwPersistOptions );
WICPersistOptions GetPersistOptions();
/// Gets the preferred vendor GUID.
///
/// Type: GUID*
/// Pointer that receives the preferred vendor GUID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicstreamprovider-getpreferredvendorguid
// HRESULT GetPreferredVendorGUID( GUID *pguidPreferredVendor );
Guid GetPreferredVendorGUID();
///
/// Informs the component that the content of the stream it's holding onto may have changed. The component should respond by
/// dirtying any cached information from the stream.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wincodecsdk/nf-wincodecsdk-iwicstreamprovider-refreshstream HRESULT RefreshStream();
void RefreshStream();
}
private static T[] GetArray(GetArrayAction action)
{
action(0, null, out var sz);
var a = new T[(int)sz];
action(sz, a, out _);
return a;
}
private static string GetString(GetStringAction action)
{
action(0, null, out var sz);
var sb = new StringBuilder((int)sz);
action(sz, sb, out _);
return sb.ToString();
}
}
}