#pragma warning disable IDE1006 // Naming Styles
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Vanara.InteropServices;
using static Vanara.PInvoke.Gdi32;
namespace Vanara.PInvoke
{
/// Items from the Msvfw32.dll
public static partial class Msvfw32
{
private const uint DRV_USER = 0x4000;
private const uint ICM_RESERVED = ICM_RESERVED_LOW;
private const uint ICM_RESERVED_HIGH = DRV_USER + 0x2000;
private const uint ICM_RESERVED_LOW = DRV_USER + 0x1000;
private const uint ICM_USER = DRV_USER + 0x0000;
private const string Lib_Msvfw32 = "msvfw32.dll";
/// Applicable flags for the function.
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibBegin")]
[Flags]
public enum DDF : uint
{
///
/// Last buffered bitmap needs to be redrawn. If drawing fails with this value, a buffered image is not available and a new
/// image needs to be specified before the display can be updated.
///
DDF_UPDATE = 0x0002,
/// Use the current DC handle and the palette currently associated with the DC.
DDF_SAME_HDC = 0x0004,
///
/// Use the current drawing parameters for DrawDibDraw. Use this value only if lpbi, dxDest, dyDest, dxSrc, and dySrc have not
/// changed since using DrawDibDraw or DrawDibBegin. This flag supersedes the DDF_SAME_DIB and DDF_SAME_SIZE flags.
///
DDF_SAME_DRAW = 0x0008,
///
/// Current image is not drawn, but is decompressed. DDF_UPDATE can be used later to draw the image. This flag supersedes the
/// DDF_PREROLL flag.
///
DDF_DONTDRAW = 0x0010,
///
/// Allows palette animation. If this value is present, DrawDib reserves as many entries as possible by setting PC_RESERVED in
/// the palPalEntry array entries of the LOGPALETTE structure, and the palette can be animated by using the DrawDibChangePalette
/// function. If your application uses the DrawDibBegin function with the DrawDibDraw function, set this value with DrawDibBegin
/// rather than DrawDibDraw.
///
DDF_ANIMATE = 0x0020,
///
/// Causes DrawDib to try to use an off-screen buffer so DDF_UPDATE can be used. This disables decompression and drawing
/// directly to the screen. If DrawDib is unable to create an off-screen buffer, it will decompress or draw directly to the
/// screen. For more information, see the DDF_UPDATE and DDF_DONTDRAW values described for DrawDibDraw.
///
DDF_BUFFER = 0x0040,
///
/// Draws the image by using GDI. Prohibits DrawDib functions from decompressing, stretching, or dithering the image. This
/// strips DrawDib of capabilities that differentiate it from the StretchDIBits function.
///
DDF_JUSTDRAWIT = 0x0080,
/// Not supported.
DDF_FULLSCREEN = 0x0100,
///
/// Realizes the palette used for drawing as a background task, leaving the current palette used for the display unchanged.
/// (This value is mutually exclusive of DDF_SAME_HDC.)
///
DDF_BACKGROUNDPAL = 0x0200,
/// this is a partial frame update, hint
DDF_NOTKEYFRAME = 0x0400,
/// hurry up please!
DDF_HURRYUP = 0x0800,
///
/// Always dithers the DIB to a standard palette regardless of the palette of the DIB. If your application uses DrawDibBegin
/// with DrawDibDraw, set this value with DrawDibBegin rather than DrawDibDraw.
///
DDF_HALFTONE = 0x1000,
}
/// Flags used for compression.
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_2")]
[Flags]
public enum ICCOMPRESSF : uint
{
/// Input data should be treated as a key frame.
ICCOMPRESS_KEYFRAME = 0x00000001
}
/// Applicable flags.
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_3")]
[Flags]
public enum ICCOMPRESSFRAMESF : uint
{
/// Padding is used with the frame.
ICCOMPRESSFRAMES_PADDING = 1
}
/// Applicable flags.
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_5")]
[Flags]
public enum ICDECOMPRESSF : uint
{
///
/// Tries to decompress at a faster rate. When an application uses this flag, the driver should buffer the decompressed data but
/// not draw the image.
///
ICDECOMPRESS_HURRYUP = 0x80000000,
/// Screen is being updated or refreshed.
ICDECOMPRESS_UPDATE = 0x40000000,
/// Current frame precedes the point in the movie where playback starts and, therefore, will not be drawn.
ICDECOMPRESS_PREROLL = 0x20000000,
/// Current frame does not contain data and the decompressed image should be left the same.
ICDECOMPRESS_NULLFRAME = 0x10000000,
/// Current frame is not a key frame.
ICDECOMPRESS_NOTKEYFRAME = 0x08000000,
}
/// Flags from the AVI file index.
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_8")]
[Flags]
public enum ICDRAWF : uint
{
/// Determines if the decompressor can handle the decompression. The driver does not actually decompress the data.
ICDRAW_QUERY = 0x00000001,
/// Draws the decompressed data on the full screen.
ICDRAW_FULLSCREEN = 0x00000002,
/// Draws the decompressed data to a window or a DC.
ICDRAW_HDC = 0x00000004,
/// Application can animate the palette.
ICDRAW_ANIMATE = 0x00000008,
/// Drawing is a continuation of the previous frame.
ICDRAW_CONTINUE = 0x00000010,
/// DC is off-screen.
ICDRAW_MEMORYDC = 0x00000020,
/// Current frame is being updated rather than played.
ICDRAW_UPDATING = 0x00000040,
/// Renders but does not draw the data.
ICDRAW_RENDER = 0x00000080,
/// Buffers this data off-screen; it will need to be updated.
ICDRAW_BUFFER = 0x00000100,
/// Data is buffered and not drawn to the screen. Use this flag for fastest decompression.
ICDRAW_HURRYUP = 0x80000000,
/// Updates the screen based on data previously received. In this case, lpData should be ignored.
ICDRAW_UPDATE = 0x40000000,
///
/// Current frame of video occurs before playback should start. For example, if playback will begin on frame 10, and frame 0 is
/// the nearest previous key frame, frames 0 through 9 are sent to the driver with this flag set. The driver needs this data to
/// display frame 10 properly.
///
ICDRAW_PREROLL = 0x20000000,
/// Current frame does not contain any data, and the previous frame should be redrawn.
ICDRAW_NULLFRAME = 0x10000000,
/// Current frame is not a key frame.
ICDRAW_NOTKEYFRAME = 0x08000000,
}
/// Error values returns by some IC* functions.
[PInvokeData("vfw.h")]
public enum ICERR
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
ICERR_OK = 0,
ICERR_DONTDRAW = 1,
ICERR_NEWPALETTE = 2,
ICERR_GOTOKEYFRAME = 3,
ICERR_STOPDRAWING = 4,
ICERR_UNSUPPORTED = -1,
ICERR_BADFORMAT = -2,
ICERR_MEMORY = -3,
ICERR_INTERNAL = -4,
ICERR_BADFLAGS = -5,
ICERR_BADPARAM = -6,
ICERR_BADSIZE = -7,
ICERR_BADHANDLE = -8,
ICERR_CANTUPDATE = -9,
ICERR_ABORT = -10,
ICERR_ERROR = -100,
ICERR_BADBITDEPTH = -200,
ICERR_BADIMAGESIZE = -201,
ICERR_CUSTOM = -400,
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
}
/// Flags defining the contents of lParam in .
[Flags]
public enum ICINSTALL : uint
{
///
ICINSTALL_UNICODE = 0x8000,
///
/// The lParam parameter contains the address of a compressor function. This function should be structured like the DriverProc
/// entry point function used by compressors.
///
ICINSTALL_FUNCTION = 0x0001,
/// The lParam parameter contains the address of a null-terminated string that names the compressor to install.
ICINSTALL_DRIVER = 0x0002,
/// lParam is a HDRVR (driver handle)
ICINSTALL_HDRV = 0x0004,
/// lParam is a unicode driver name
ICINSTALL_DRIVERW = 0x8002,
}
/// Message codes for .
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSendMessage")]
public enum ICM_Message : uint
{
/// Get compressor state
ICM_GETSTATE = ICM_RESERVED + 0,
/// Set compressor state
ICM_SETSTATE = ICM_RESERVED + 1,
/// Query info about the compressor
ICM_GETINFO = ICM_RESERVED + 2,
/// show the configure dialog
ICM_CONFIGURE = ICM_RESERVED + 10,
/// show the about box
ICM_ABOUT = ICM_RESERVED + 11,
/// get error text TBD ;Internal
ICM_GETERRORTEXT = ICM_RESERVED + 12,
/// get a name for a format ;Internal
ICM_GETFORMATNAME = ICM_RESERVED + 20,
/// cycle through formats ;Internal
ICM_ENUMFORMATS = ICM_RESERVED + 21,
/// get the default value for quality
ICM_GETDEFAULTQUALITY = ICM_RESERVED + 30,
/// get the current value for quality
ICM_GETQUALITY = ICM_RESERVED + 31,
/// set the default value for quality
ICM_SETQUALITY = ICM_RESERVED + 32,
/// Tell the driver something
ICM_SET = ICM_RESERVED + 40,
/// Ask the driver something
ICM_GET = ICM_RESERVED + 41,
/// get compress format or size
ICM_COMPRESS_GET_FORMAT = ICM_USER + 4,
/// get output size
ICM_COMPRESS_GET_SIZE = ICM_USER + 5,
/// query support for compress
ICM_COMPRESS_QUERY = ICM_USER + 6,
/// begin a series of compress calls.
ICM_COMPRESS_BEGIN = ICM_USER + 7,
/// compress a frame
ICM_COMPRESS = ICM_USER + 8,
/// end of a series of compress calls.
ICM_COMPRESS_END = ICM_USER + 9,
///
///
/// The ICM_DECOMPRESS_GET_FORMAT message requests the output format of the decompressed data from a video decompression
/// driver. You can send this message explicitly or by using the ICDecompressGetFormat macro.
///
/// lpbiInput - Pointer to a BITMAPINFO structure containing the input format.
///
/// lpbiOutput - Pointer to a BITMAPINFO structure to contain the output format. You can specify zero to request
/// only the size of the output format, as in the ICDecompressGetFormatSize macro.
///
///
///
/// If lpbiOutput is zero, returns the size of the structure.
/// If lpbiOutput is nonzero, returns ICERR_OK if successful or an error otherwise.
///
///
/// If lpbiOutput is nonzero, the driver should fill the BITMAPINFO structure with the default output format
/// corresponding to the input format specified for lpbiInput. If the compressor can produce several formats, the default format
/// should be the one that preserves the greatest amount of information.
///
// https://docs.microsoft.com/en-us/windows/win32/multimedia/icm-decompress-get-format
ICM_DECOMPRESS_GET_FORMAT = ICM_USER + 10,
/// query support for dempress
ICM_DECOMPRESS_QUERY = ICM_USER + 11,
/// start a series of decompress calls
ICM_DECOMPRESS_BEGIN = ICM_USER + 12,
/// decompress a frame
ICM_DECOMPRESS = ICM_USER + 13,
/// end a series of decompress calls
ICM_DECOMPRESS_END = ICM_USER + 14,
/// fill in the DIB color table
ICM_DECOMPRESS_SET_PALETTE = ICM_USER + 29,
/// fill in the DIB color table
ICM_DECOMPRESS_GET_PALETTE = ICM_USER + 30,
/// query support for dempress
ICM_DRAW_QUERY = ICM_USER + 31,
/// start a series of draw calls
ICM_DRAW_BEGIN = ICM_USER + 15,
/// get the palette needed for drawing
ICM_DRAW_GET_PALETTE = ICM_USER + 16,
/// update screen with current frame ;Internal
ICM_DRAW_UPDATE = ICM_USER + 17,
/// start decompress clock
ICM_DRAW_START = ICM_USER + 18,
/// stop decompress clock
ICM_DRAW_STOP = ICM_USER + 19,
/// decompress a frame to screen ;Internal
ICM_DRAW_BITS = ICM_USER + 20,
/// end a series of draw calls
ICM_DRAW_END = ICM_USER + 21,
/// get value of decompress clock
ICM_DRAW_GETTIME = ICM_USER + 32,
/// generalized "render" message
ICM_DRAW = ICM_USER + 33,
/// drawing window has moved or hidden
ICM_DRAW_WINDOW = ICM_USER + 34,
/// set correct value for decompress clock
ICM_DRAW_SETTIME = ICM_USER + 35,
/// realize palette for drawing
ICM_DRAW_REALIZE = ICM_USER + 36,
/// clear out buffered frames
ICM_DRAW_FLUSH = ICM_USER + 37,
/// draw undrawn things in queue
ICM_DRAW_RENDERBUFFER = ICM_USER + 38,
/// start of a play
ICM_DRAW_START_PLAY = ICM_USER + 39,
/// end of a play
ICM_DRAW_STOP_PLAY = ICM_USER + 40,
/// Like ICGetDisplayFormat
ICM_DRAW_SUGGESTFORMAT = ICM_USER + 50,
/// for animating palette
ICM_DRAW_CHANGEPALETTE = ICM_USER + 51,
/// send each frame time ;Internal
ICM_DRAW_IDLE = ICM_USER + 52,
/// ask about prebuffering
ICM_GETBUFFERSWANTED = ICM_USER + 41,
/// get the default value for key frames
ICM_GETDEFAULTKEYFRAMERATE = ICM_USER + 42,
/// start a series of decompress calls
ICM_DECOMPRESSEX_BEGIN = ICM_USER + 60,
/// start a series of decompress calls
ICM_DECOMPRESSEX_QUERY = ICM_USER + 61,
/// decompress a frame
ICM_DECOMPRESSEX = ICM_USER + 62,
/// end a series of decompress calls
ICM_DECOMPRESSEX_END = ICM_USER + 63,
/// tell about compress to come
ICM_COMPRESS_FRAMES_INFO = ICM_USER + 70,
/// compress a bunch of frames ;Internal
ICM_COMPRESS_FRAMES = ICM_USER + 71,
/// set status callback
ICM_SET_STATUS_PROC = ICM_USER + 72,
}
/// Applicable flags.
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompressorChoose")]
[Flags]
public enum ICMF_CHOOSE : uint
{
/// Displays a check box and edit box to enter the frequency of key frames.
ICMF_CHOOSE_KEYFRAME = 0x0001,
/// Displays a check box and edit box to enter the data rate for the movie.
ICMF_CHOOSE_DATARATE = 0x0002,
///
/// Displays a button to expand the dialog box to include a preview window. The preview window shows how frames of your movie
/// will appear when compressed with the current settings.
///
ICMF_CHOOSE_PREVIEW = 0x0004,
///
/// All compressors should appear in the selection list. If this flag is not specified, only the compressors that can handle the
/// input format appear in the selection list.
///
ICMF_CHOOSE_ALLCOMPRESSORS = 0x0008,
}
/// Applicable flags.
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_11")]
public enum ICMF_COMPVARS
{
///
/// Data in this structure is valid and has been manually entered. Set this flag before you call any function if you fill this
/// structure manually. Do not set this flag if you let ICCompressorChoose initialize this structure.
///
ICMF_COMPVARS_VALID = 0x00000001
}
/// Applicable flags indicating why the driver is opened.
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_0")]
public enum ICMODE : ushort
{
/// Driver is opened to compress data.
ICMODE_COMPRESS = 1,
/// Driver is opened to decompress data.
ICMODE_DECOMPRESS = 2,
///
ICMODE_FASTDECOMPRESS = 3,
/// Driver is opened for informational purposes, rather than for compression.
ICMODE_QUERY = 4,
///
ICMODE_FASTCOMPRESS = 5,
/// Device driver is opened to decompress data directly to hardware.
ICMODE_DRAW = 8,
}
/// Applicable flags.
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_1")]
[Flags]
public enum VIDCF : uint
{
/// Driver supports quality values.
VIDCF_QUALITY = 0x0001,
/// Driver supports compressing to a frame size.
VIDCF_CRUNCH = 0x0002,
/// Driver supports inter-frame compression.
VIDCF_TEMPORAL = 0x0004,
///
/// Driver is requesting to compress all frames. For information about compressing all frames, see the ICM_COMPRESS_FRAMES_INFO message.
///
VIDCF_COMPRESSFRAMES = 0x0008,
/// Driver supports drawing.
VIDCF_DRAW = 0x0010,
///
/// Driver can perform temporal compression and maintains its own copy of the current frame. When compressing a stream of frame
/// data, the driver doesn't need image data from the previous frame.
///
VIDCF_FASTTEMPORALC = 0x0020,
///
/// Driver can perform temporal decompression and maintains its own copy of the current frame. When decompressing a stream of
/// frame data, the driver doesn't need image data from the previous frame.
///
VIDCF_FASTTEMPORALD = 0x0080,
}
/// The DrawDib function changes parameters of a DrawDib DC or initializes a new DrawDib DC.
/// Handle to a DrawDib DC.
/// Handle to a DC for drawing. This parameter is optional.
/// Width, in MM_TEXT client units, of the destination rectangle.
/// Height, in MM_TEXT client units, of the destination rectangle.
///
/// Pointer to a BITMAPINFOHEADER structure containing the image format. The color table for the DIB follows the image format and
/// the biHeight member must be a positive value.
///
/// Width, in pixels, of the source rectangle.
/// Height, in pixels, of the source rectangle.
///
/// Applicable flags for the function. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// DDF_ANIMATE
///
/// Allows palette animation. If this value is present, DrawDib reserves as many entries as possible by setting PC_RESERVED in the
/// palPalEntry array entries of the LOGPALETTE structure, and the palette can be animated by using the DrawDibChangePalette
/// function. If your application uses the DrawDibBegin function with the DrawDibDraw function, set this value with DrawDibBegin
/// rather than DrawDibDraw.
///
///
/// -
/// DDF_BACKGROUNDPAL
///
/// Realizes the palette used for drawing as a background task, leaving the current palette used for the display unchanged. (This
/// value is mutually exclusive of DDF_SAME_HDC.)
///
///
/// -
/// DDF_BUFFER
///
/// Causes DrawDib to try to use an off-screen buffer so DDF_UPDATE can be used. This disables decompression and drawing directly to
/// the screen. If DrawDib is unable to create an off-screen buffer, it will decompress or draw directly to the screen. For more
/// information, see the DDF_UPDATE and DDF_DONTDRAW values described for DrawDibDraw.
///
///
/// -
/// DDF_DONTDRAW
///
/// Current image is not drawn, but is decompressed. DDF_UPDATE can be used later to draw the image. This flag supersedes the
/// DDF_PREROLL flag.
///
///
/// -
/// DDF_FULLSCREEN
/// Not supported.
///
/// -
/// DDF_HALFTONE
///
/// Always dithers the DIB to a standard palette regardless of the palette of the DIB. If your application uses DrawDibBegin with
/// DrawDibDraw, set this value with DrawDibBegin rather than DrawDibDraw.
///
///
/// -
/// DDF_JUSTDRAWIT
///
/// Draws the image by using GDI. Prohibits DrawDib functions from decompressing, stretching, or dithering the image. This strips
/// DrawDib of capabilities that differentiate it from the StretchDIBits function.
///
///
/// -
/// DDF_SAME_DRAW
///
/// Use the current drawing parameters for DrawDibDraw. Use this value only if lpbi, dxDest, dyDest, dxSrc, and dySrc have not
/// changed since using DrawDibDraw or DrawDibBegin. This flag supersedes the DDF_SAME_DIB and DDF_SAME_SIZE flags.
///
///
/// -
/// DDF_SAME_HDC
/// Use the current DC handle and the palette currently associated with the DC.
///
/// -
/// DDF_UPDATE
///
/// Last buffered bitmap needs to be redrawn. If drawing fails with this value, a buffered image is not available and a new image
/// needs to be specified before the display can be updated.
///
///
///
///
/// Returns TRUE if successful or FALSE otherwise.
///
///
/// This function prepares to draw a DIB specified by lpbi to the DC. The image is stretched to the size specified by dxDest and
/// dyDest. If dxDest and dyDest are set to −1, the DIB is drawn to a 1:1 scale without stretching.
///
///
/// You can update the flags of a DrawDib DC by reissuing DrawDibBegin, specifying the new flags, and changing at least one
/// of the following settings: dxDest, dyDest, lpbi, dxSrc, or dySrc.
///
/// If the parameters of DrawDibBegin have not changed, subsequent calls to the function have no effect.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibbegin BOOL VFWAPI DrawDibBegin( HDRAWDIB hdd, HDC hdc, int
// dxDst, int dyDst, LPBITMAPINFOHEADER lpbi, int dxSrc, int dySrc, UINT wFlags );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibBegin")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawDibBegin([In] HDRAWDIB hdd, [In, Optional] HDC hdc, int dxDst, int dyDst, in BITMAPINFOHEADER lpbi, int dxSrc, int dySrc, DDF wFlags);
/// The DrawDibChangePalette function sets the palette entries used for drawing DIBs.
/// Handle to a DrawDib DC.
/// Starting palette entry number.
/// Number of palette entries.
/// Pointer to an array of palette entries.
/// Returns TRUE if successful or FALSE otherwise.
///
///
/// This function changes the physical palette only if the current DrawDib palette is realized by calling the DrawDibRealize function.
///
///
/// If the color table is not changed, the next call to the DrawDibDraw function that does not specify DDF_SAME_DRAW calls the
/// DrawDibBegin function implicitly.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibchangepalette BOOL VFWAPI DrawDibChangePalette( HDRAWDIB
// hdd, int iStart, int iLen, LPPALETTEENTRY lppe );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibChangePalette")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawDibChangePalette([In] HDRAWDIB hdd, int iStart, int iLen, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] PALETTEENTRY[] lppe);
/// The DrawDibClose function closes a DrawDib DC and frees the resources DrawDib allocated for it.
/// Handle to a DrawDib DC.
/// Returns TRUE if successful or FALSE otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibclose BOOL VFWAPI DrawDibClose( HDRAWDIB hdd );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibClose")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawDibClose(HDRAWDIB hdd);
/// The DrawDibDraw function draws a DIB to the screen.
/// Handle to a DrawDib DC.
/// Handle to the DC.
/// The x-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
/// The y-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
///
/// Width, in MM_TEXT client coordinates, of the destination rectangle. If dxDst is −1, the width of the bitmap is used.
///
///
/// Height, in MM_TEXT client coordinates, of the destination rectangle. If dyDst is −1, the height of the bitmap is used.
///
///
/// Pointer to the BITMAPINFOHEADER structure containing the image format. The color table for the DIB within
/// BITMAPINFOHEADER follows the format and the biHeight member must be a positive value; DrawDibDraw will not
/// draw inverted DIBs.
///
/// Pointer to the buffer that contains the bitmap bits.
///
/// The x-coordinate, in pixels, of the upper left corner of the source rectangle. The coordinates (0,0) represent the upper left
/// corner of the bitmap.
///
///
/// The y-coordinate, in pixels, of the upper left corner of the source rectangle. The coordinates (0,0) represent the upper left
/// corner of the bitmap.
///
/// Width, in pixels, of the source rectangle.
/// Height, in pixels, of the source rectangle.
///
/// Applicable flags for drawing. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// DDF_BACKGROUNDPAL
///
/// Realizes the palette used for drawing in the background, leaving the actual palette used for display unchanged. This value is
/// valid only if DDF_SAME_HDC is not set.
///
///
/// -
/// DDF_DONTDRAW
/// Current image is decompressed but not drawn. This flag supersedes the DDF_PREROLL flag.
///
/// -
/// DDF_FULLSCREEN
/// Not supported.
///
/// -
/// DDF_HALFTONE
///
/// Always dithers the DIB to a standard palette regardless of the palette of the DIB. If your application uses the DrawDibBegin
/// function, set this value in DrawDibBegin rather than in DrawDibDraw.
///
///
/// -
/// DDF_HURRYUP
///
/// Data does not have to be drawn (that is, it can be dropped) and DDF_UPDATE will not be used to recall this information. DrawDib
/// checks this value only if it is required to build the next frame; otherwise, the value is ignored.This value is usually used to
/// synchronize video and audio. When synchronizing data, applications should send the image with this value in case the driver
/// needs to buffer the frame to decompress subsequent frames.
///
///
/// -
/// DDF_NOTKEYFRAME
/// DIB data is not a key frame.
///
/// -
/// DDF_SAME_HDC
/// Use the current DC handle and the palette currently associated with the DC.
///
/// -
/// DDF_SAME_DRAW
///
/// Use the current drawing parameters for DrawDibDraw. Use this value only if lpbi, dxDst, dyDst, dxSrc, and dySrc have not changed
/// since using DrawDibDraw or DrawDibBegin. DrawDibDraw typically checks the parameters, and if they have changed, DrawDibBegin
/// prepares the DrawDib DC for drawing. This flag supersedes the DDF_SAME_DIB and DDF_SAME_SIZE flags.
///
///
/// -
/// DDF_UPDATE
///
/// Last buffered bitmap is to be redrawn. If drawing fails with this value, a buffered image is not available and a new image needs
/// to be specified before the display can be updated.
///
///
///
///
/// Returns TRUE if successful or FALSE otherwise.
///
///
/// DDF_DONTDRAW causes DrawDibDraw to decompress but not display an image. A subsequent call to DrawDibDraw
/// specifying DDF_UPDATE displays the image.
///
///
/// If the DrawDib DC does not have an off-screen buffer specified, specifying DDF_DONTDRAW causes the frame to be drawn to
/// the screen immediately. Subsequent calls to DrawDibDraw specifying DDF_UPDATE fail.
///
///
/// Although they are set at different times, DDF_UPDATE and DDF_DONTDRAW can be used together to create composite
/// images off-screen. When the off-screen image is complete, you can display the image by calling DrawDibDraw.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibdraw BOOL VFWAPI DrawDibDraw( HDRAWDIB hdd, HDC hdc, int
// xDst, int yDst, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi, LPVOID lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, UINT
// wFlags );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibDraw")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawDibDraw([In] HDRAWDIB hdd, [In] HDC hdc, int xDst, int yDst, int dxDst, int dyDst, in BITMAPINFOHEADER lpbi, [In, Optional] IntPtr lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, DDF wFlags);
/// The DrawDibDraw function draws a DIB to the screen.
/// Handle to a DrawDib DC.
/// Handle to the DC.
/// The x-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
/// The y-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
///
/// Width, in MM_TEXT client coordinates, of the destination rectangle. If dxDst is −1, the width of the bitmap is used.
///
///
/// Height, in MM_TEXT client coordinates, of the destination rectangle. If dyDst is −1, the height of the bitmap is used.
///
///
/// Pointer to the BITMAPINFOHEADER structure containing the image format. The color table for the DIB within
/// BITMAPINFOHEADER follows the format and the biHeight member must be a positive value; DrawDibDraw will not
/// draw inverted DIBs.
///
/// Pointer to the buffer that contains the bitmap bits.
///
/// The x-coordinate, in pixels, of the upper left corner of the source rectangle. The coordinates (0,0) represent the upper left
/// corner of the bitmap.
///
///
/// The y-coordinate, in pixels, of the upper left corner of the source rectangle. The coordinates (0,0) represent the upper left
/// corner of the bitmap.
///
/// Width, in pixels, of the source rectangle.
/// Height, in pixels, of the source rectangle.
///
/// Applicable flags for drawing. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// DDF_BACKGROUNDPAL
///
/// Realizes the palette used for drawing in the background, leaving the actual palette used for display unchanged. This value is
/// valid only if DDF_SAME_HDC is not set.
///
///
/// -
/// DDF_DONTDRAW
/// Current image is decompressed but not drawn. This flag supersedes the DDF_PREROLL flag.
///
/// -
/// DDF_FULLSCREEN
/// Not supported.
///
/// -
/// DDF_HALFTONE
///
/// Always dithers the DIB to a standard palette regardless of the palette of the DIB. If your application uses the DrawDibBegin
/// function, set this value in DrawDibBegin rather than in DrawDibDraw.
///
///
/// -
/// DDF_HURRYUP
///
/// Data does not have to be drawn (that is, it can be dropped) and DDF_UPDATE will not be used to recall this information. DrawDib
/// checks this value only if it is required to build the next frame; otherwise, the value is ignored.This value is usually used to
/// synchronize video and audio. When synchronizing data, applications should send the image with this value in case the driver
/// needs to buffer the frame to decompress subsequent frames.
///
///
/// -
/// DDF_NOTKEYFRAME
/// DIB data is not a key frame.
///
/// -
/// DDF_SAME_HDC
/// Use the current DC handle and the palette currently associated with the DC.
///
/// -
/// DDF_SAME_DRAW
///
/// Use the current drawing parameters for DrawDibDraw. Use this value only if lpbi, dxDst, dyDst, dxSrc, and dySrc have not changed
/// since using DrawDibDraw or DrawDibBegin. DrawDibDraw typically checks the parameters, and if they have changed, DrawDibBegin
/// prepares the DrawDib DC for drawing. This flag supersedes the DDF_SAME_DIB and DDF_SAME_SIZE flags.
///
///
/// -
/// DDF_UPDATE
///
/// Last buffered bitmap is to be redrawn. If drawing fails with this value, a buffered image is not available and a new image needs
/// to be specified before the display can be updated.
///
///
///
///
/// Returns TRUE if successful or FALSE otherwise.
///
///
/// DDF_DONTDRAW causes DrawDibDraw to decompress but not display an image. A subsequent call to DrawDibDraw
/// specifying DDF_UPDATE displays the image.
///
///
/// If the DrawDib DC does not have an off-screen buffer specified, specifying DDF_DONTDRAW causes the frame to be drawn to
/// the screen immediately. Subsequent calls to DrawDibDraw specifying DDF_UPDATE fail.
///
///
/// Although they are set at different times, DDF_UPDATE and DDF_DONTDRAW can be used together to create composite
/// images off-screen. When the off-screen image is complete, you can display the image by calling DrawDibDraw.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibdraw BOOL VFWAPI DrawDibDraw( HDRAWDIB hdd, HDC hdc, int
// xDst, int yDst, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi, LPVOID lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, UINT
// wFlags );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibDraw")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawDibDraw([In] HDRAWDIB hdd, [In] HDC hdc, int xDst, int yDst, int dxDst, int dyDst, [In, Optional] IntPtr lpbi, [In, Optional] IntPtr lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, DDF wFlags);
///
/// The DrawDibEnd function clears the flags and other settings of a DrawDib DC that are set by the DrawDibBegin or
/// DrawDibDraw functions.
///
/// Handle to the DrawDib DC to free.
/// Returns TRUE if successful or FALSE otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibend BOOL VFWAPI DrawDibEnd( HDRAWDIB hdd );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibEnd")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawDibEnd([In] HDRAWDIB hdd);
/// The DrawDibGetBuffer function retrieves the location of the buffer used by DrawDib for decompression.
/// Handle to a DrawDib DC.
///
/// Pointer to a BITMAPINFO structure. This structure is made up of a BITMAPINFOHEADER structure and a 256-entry table defining the
/// colors used by the bitmap.
///
/// Size, in bytes, of the BITMAPINFO structure pointed to by lpbi
/// Reserved; must be zero.
///
/// Returns the address of the buffer or NULL if no buffer is used. if lpbr is not NULL, it is filled with a copy of
/// the BITMAPINFO structure describing the buffer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibgetbuffer LPVOID VFWAPI DrawDibGetBuffer( HDRAWDIB hdd,
// LPBITMAPINFOHEADER lpbi, DWORD dwSize, DWORD dwFlags );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibGetBuffer")]
public static extern IntPtr DrawDibGetBuffer([In] HDRAWDIB hdd, out BITMAPINFOHEADER lpbi, uint dwSize, uint dwFlags = 0);
/// The DrawDibGetPalette function retrieves the palette used by a DrawDib DC.
/// Handle to a DrawDib DC.
/// Returns a handle to the palette if successful or NULL otherwise.
///
///
/// This function assumes the DrawDib DC contains a valid palette entry, implying that a call to this function must follow calls to
/// the DrawDibDraw or DrawDibBegin functions.
///
///
/// You should rarely need to call this function because you can realize the correct palette in response to a window message by
/// using the DrawDibRealize function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibgetpalette HPALETTE VFWAPI DrawDibGetPalette( HDRAWDIB hdd );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibGetPalette")]
public static extern SafeHPALETTE DrawDibGetPalette([In] HDRAWDIB hdd);
/// The DrawDibOpen function opens the DrawDib library for use and creates a DrawDib DC for drawing.
/// Returns a handle to a DrawDib DC if successful or NULL otherwise.
///
/// When drawing multiple DIBs simultaneously, create a DrawDib DC for each of the images that will be simultaneously on-screen.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibopen HDRAWDIB VFWAPI DrawDibOpen();
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibOpen")]
public static extern SafeHDRAWDIB DrawDibOpen();
/// The DrawDibProfileDisplay function determines settings for the display system when using DrawDib functions.
///
/// Pointer to a BITMAPINFOHEADER structure that contains bitmap information. You can also specify NULL to verify that the
/// profile information is current. If the profile information is not current, DrawDib will rerun the profile tests to obtain a
/// current set of information. When you call DrawDibProfileDisplay with this parameter set to NULL, the return value
/// is meaningless.
///
///
///
/// Returns a value that indicates the fastest drawing and stretching capabilities of the display system. This value can be zero if
/// the bitmap format is not supported or one or more of the following values.
///
///
///
/// Return code
/// Description
///
/// -
/// PD_CAN_DRAW_DIB
/// DrawDib can draw images using this format. Stretching might or might not also be supported.
///
/// -
/// PD_CAN_STRETCHDIB
/// DrawDib can stretch and draw images using this format.
///
/// -
/// PD_STRETCHDIB_1_1_OK
/// StretchDIBits draws unstretched images using this format faster than an alternative method.
///
/// -
/// PD_STRETCHDIB_1_2_OK
/// StretchDIBits draws stretched images (in a 1:2 ratio) using this format faster than an alternative method.
///
/// -
/// PD_STRETCHDIB_1_N_OK
/// StretchDIBits draws stretched images (in a 1:N ratio) using this format faster than an alternative method.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibprofiledisplay LRESULT VFWAPI DrawDibProfileDisplay(
// LPBITMAPINFOHEADER lpbi );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibProfileDisplay")]
public static extern IntPtr DrawDibProfileDisplay(in BITMAPINFOHEADER lpbi);
/// The DrawDibRealize function realizes the palette of the DrawDib DC for use with the specified DC.
/// Handle to a DrawDib DC.
/// Handle to the DC containing the palette.
///
/// Background palette flag. If this value is nonzero, the palette is a background palette. If this value is zero and the DC is
/// attached to a window, the logical palette becomes the foreground palette when the window has the input focus. (A DC is attached
/// to a window when the window class style is CS_OWNDC or when the DC is obtained by using the GetDC function.)
///
///
/// Returns the number of entries in the logical palette mapped to different values in the system palette. If an error occurs or no
/// colors were updated, it returns zero.
///
///
/// To select the palette of the DrawDib DC as a background palette, use the DrawDibDraw function and specify the DDF_BACKGROUNDPAL flag.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibrealize UINT VFWAPI DrawDibRealize( HDRAWDIB hdd, HDC hdc,
// BOOL fBackground );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibRealize")]
public static extern uint DrawDibRealize([In] HDRAWDIB hdd, [In] HDC hdc, [MarshalAs(UnmanagedType.Bool)] bool fBackground);
/// The DrawDibSetPalette function sets the palette used for drawing DIBs.
/// Handle to a DrawDib DC.
/// Handle to the palette. Specify NULL to use the default palette.
/// Returns TRUE if successful or FALSE otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibsetpalette BOOL VFWAPI DrawDibSetPalette( HDRAWDIB hdd,
// HPALETTE hpal );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibSetPalette")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawDibSetPalette([In] HDRAWDIB hdd, [In, Optional] HPALETTE hpal);
/// The DrawDibStart function prepares a DrawDib DC for streaming playback.
/// Handle to a DrawDib DC.
/// Playback rate, in microseconds per frame.
/// Returns TRUE if successful or FALSE otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibstart BOOL VFWAPI DrawDibStart( HDRAWDIB hdd, DWORD rate );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibStart")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawDibStart([In] HDRAWDIB hdd, uint rate);
/// The DrawDibStop function frees the resources used by a DrawDib DC for streaming playback.
/// Handle to a DrawDib DC.
/// Returns TRUE if successful or FALSE otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibstop BOOL VFWAPI DrawDibStop( HDRAWDIB hdd );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibStop")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawDibStop([In] HDRAWDIB hdd);
///
/// The DrawDibTime function retrieves timing information about the drawing operation and is used during debug operations.
///
/// Handle to a DrawDib DC.
/// Pointer to a DRAWDIBTIME structure.
/// Returns TRUE if successful or FALSE otherwise.
/// This function is present only in the debug version of the Microsoft Windows Software Development Kit (SDK) libraries.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibtime BOOL VFWAPI DrawDibTime( HDRAWDIB hdd, LPDRAWDIBTIME
// lpddtime );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibTime")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawDibTime([In] HDRAWDIB hdd, out DRAWDIBTIME lpddtime);
/// The DrawDibUpdate macro draws the last frame in the DrawDib off-screen buffer.
/// Handle to a DrawDib DC.
/// Handle of the DC.
/// The x-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
/// The y-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
/// Returns TRUE if successful or FALSE otherwise.
///
/// The DrawDibUpdate macro is defined as follows:
///
/// #define DrawDibUpdate( hdd, hdc, x, y) \ DrawDibDraw( hdd, hdc, x, y, 0, 0, NULL, NULL, 0, 0, \ 0, 0, DDF_UPDATE)
///
/// This macro can be used to refresh an image or a portion of an image displayed by your application.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibupdate void DrawDibUpdate( hdd, hdc, x, y );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibUpdate")]
public static bool DrawDibUpdate([In] HDRAWDIB hdd, [In] HDC hdc, int x, int y) => DrawDibDraw(hdd, hdc, x, y, 0, 0, default, default, 0, 0, 0, 0, DDF.DDF_UPDATE);
///
/// The GetOpenFileNamePreview function selects a file by using the Open dialog box. The dialog box also allows the user to
/// preview the currently specified AVI file. This function augments the capability found in the GetOpenFileName function.
///
///
/// Pointer to an OPENFILENAME structure used to initialize the dialog box. On return, the structure contains information
/// about the user's file selection.
///
/// Returns a handle to the selected file.
///
/// Note
///
/// The vfw.h header defines GetOpenFileNamePreview as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-getopenfilenamepreviewa BOOL VFWAPI GetOpenFileNamePreviewA(
// LPOPENFILENAMEA lpofn );
[DllImport(Lib_Msvfw32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.GetOpenFileNamePreviewA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetOpenFileNamePreview(ref ComDlg32.OPENFILENAME lpofn);
///
/// The GetSaveFileNamePreview function selects a file by using the Save As dialog box. The dialog box also allows the user
/// to preview the currently specified file. This function augments the capability found in the GetSaveFileName function.
///
///
/// Pointer to an OPENFILENAME structure used to initialize the dialog box. On return, the structure contains information
/// about the user's file selection.
///
/// Returns a handle to the selected file.
///
/// Note
///
/// The vfw.h header defines GetSaveFileNamePreview as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-getsavefilenamepreviewa BOOL VFWAPI GetSaveFileNamePreviewA(
// LPOPENFILENAMEA lpofn );
[DllImport(Lib_Msvfw32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.GetSaveFileNamePreviewA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetSaveFileNamePreview(ref ComDlg32.OPENFILENAME lpofn);
///
/// The ICAbout macro notifies a video compression driver to display its About dialog box. You can use this macro or
/// explicitly call the ICM_ABOUT message.
///
/// Handle of the compressor.
///
/// Handle of the parent window of the displayed dialog box.
///
/// You can also determine if a driver has an About dialog box by specifying -1 in this parameter, as in the ICQueryAbout macro. The
/// driver returns ICERR_OK if it has an About dialog box or ICERR_UNSUPPORTED otherwise.
///
///
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icabout void ICAbout( hic, hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICAbout")]
public static ICERR ICAbout(HIC hic, HWND hwnd) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_ABOUT, (IntPtr)hwnd).ToInt32();
/// The ICClose function closes a compressor or decompressor.
/// Handle to a compressor or decompressor.
/// Returns ICERR_OK if successful or an error otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icclose LRESULT VFWAPI ICClose( HIC hic );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICClose")]
public static extern IntPtr ICClose(HIC hic);
/// The ICCompress function compresses a single video image.
/// Handle to the compressor to use.
///
/// Compression flag. The following value is defined:
/// ICCOMPRESS_KEYFRAME
/// Compressor should make this frame a key frame.
///
/// Pointer to a BITMAPINFOHEADER structure containing the output format.
/// Pointer to an output buffer large enough to contain a compressed frame.
/// Pointer to a BITMAPINFOHEADER structure containing the input format.
/// Pointer to the input buffer.
/// Reserved; do not use.
///
/// Pointer to the return flags used in the AVI index. The following value is defined:
/// AVIIF_KEYFRAME
/// Current frame is a key frame.
///
/// Frame number.
///
///
/// Requested frame size, in bytes. Specify a nonzero value if the compressor supports a suggested frame size, as indicated by the
/// presence of the VIDCF_CRUNCH flag returned by the ICGetInfo function. If this flag is not set or a data rate for the
/// frame is not specified, specify zero for this parameter.
///
///
/// A compressor might have to sacrifice image quality or make some other trade-off to obtain the size goal specified in this parameter.
///
///
///
/// Requested quality value for the frame. Specify a nonzero value if the compressor supports a suggested quality value, as
/// indicated by the presence of the VIDCF_QUALITY flag returned by ICGetInfo. Otherwise, specify zero for this parameter.
///
/// Pointer to a BITMAPINFOHEADER structure containing the format of the previous frame.
///
/// Pointer to the uncompressed image of the previous frame. This parameter is not used for fast temporal compression. Specify
/// NULL for this parameter when compressing a key frame, if the compressor does not support temporal compression, or if the
/// compressor does not require an external buffer to store the format and data of the previous image.
///
/// Returns ICERR_OK if successful or an error otherwise.
///
///
/// You can obtain the required by size of the output buffer by sending the ICM_COMPRESS_GET_SIZE message (or by using the
/// ICCompressGetSize macro).
///
///
/// The compressor sets the contents of lpdwFlags to AVIIF_KEYFRAME when it creates a key frame. If your application creates
/// AVI files, it should save the information returned for lpckid and lpdwFlags in the file.
///
///
/// Compressors use lpbiPrev and lpPrev to perform temporal compression and require an external buffer to store the format and data
/// of the previous frame. Specify NULL for lpbiPrev and lpPrev when compressing a key frame, when performing fast
/// compression, or if the compressor has its own buffer to store the format and data of the previous image. Specify non-
/// NULL values for these parameters if ICGetInfo returns the VIDCF_TEMPORAL flag, the compressor is performing normal
/// compression, and the frame to compress is not a key frame.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iccompress DWORD VFWAPIV ICCompress( HIC hic, DWORD dwFlags,
// LPBITMAPINFOHEADER lpbiOutput, LPVOID lpData, LPBITMAPINFOHEADER lpbiInput, LPVOID lpBits, LPDWORD lpckid, LPDWORD lpdwFlags,
// LONG lFrameNum, DWORD dwFrameSize, DWORD dwQuality, LPBITMAPINFOHEADER lpbiPrev, LPVOID lpPrev );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompress")]
public static extern ICERR ICCompress([In] HIC hic, ICCOMPRESSF dwFlags, in BITMAPINFOHEADER lpbiOutput, [Out] IntPtr lpData,
in BITMAPINFOHEADER lpbiInput, [In] IntPtr lpBits, [Out, Optional] IntPtr lpckid, out AviFil32.AVIIF lpdwFlags, int lFrameNum, uint dwFrameSize,
uint dwQuality, in BITMAPINFOHEADER lpbiPrev, [In, Optional] IntPtr lpPrev);
/// The ICCompress function compresses a single video image.
/// Handle to the compressor to use.
///
/// Compression flag. The following value is defined:
/// ICCOMPRESS_KEYFRAME
/// Compressor should make this frame a key frame.
///
/// Pointer to a BITMAPINFOHEADER structure containing the output format.
/// Pointer to an output buffer large enough to contain a compressed frame.
/// Pointer to a BITMAPINFOHEADER structure containing the input format.
/// Pointer to the input buffer.
/// Reserved; do not use.
///
/// Pointer to the return flags used in the AVI index. The following value is defined:
/// AVIIF_KEYFRAME
/// Current frame is a key frame.
///
/// Frame number.
///
///
/// Requested frame size, in bytes. Specify a nonzero value if the compressor supports a suggested frame size, as indicated by the
/// presence of the VIDCF_CRUNCH flag returned by the ICGetInfo function. If this flag is not set or a data rate for the
/// frame is not specified, specify zero for this parameter.
///
///
/// A compressor might have to sacrifice image quality or make some other trade-off to obtain the size goal specified in this parameter.
///
///
///
/// Requested quality value for the frame. Specify a nonzero value if the compressor supports a suggested quality value, as
/// indicated by the presence of the VIDCF_QUALITY flag returned by ICGetInfo. Otherwise, specify zero for this parameter.
///
/// Pointer to a BITMAPINFOHEADER structure containing the format of the previous frame.
///
/// Pointer to the uncompressed image of the previous frame. This parameter is not used for fast temporal compression. Specify
/// NULL for this parameter when compressing a key frame, if the compressor does not support temporal compression, or if the
/// compressor does not require an external buffer to store the format and data of the previous image.
///
/// Returns ICERR_OK if successful or an error otherwise.
///
///
/// You can obtain the required by size of the output buffer by sending the ICM_COMPRESS_GET_SIZE message (or by using the
/// ICCompressGetSize macro).
///
///
/// The compressor sets the contents of lpdwFlags to AVIIF_KEYFRAME when it creates a key frame. If your application creates
/// AVI files, it should save the information returned for lpckid and lpdwFlags in the file.
///
///
/// Compressors use lpbiPrev and lpPrev to perform temporal compression and require an external buffer to store the format and data
/// of the previous frame. Specify NULL for lpbiPrev and lpPrev when compressing a key frame, when performing fast
/// compression, or if the compressor has its own buffer to store the format and data of the previous image. Specify non-
/// NULL values for these parameters if ICGetInfo returns the VIDCF_TEMPORAL flag, the compressor is performing normal
/// compression, and the frame to compress is not a key frame.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iccompress DWORD VFWAPIV ICCompress( HIC hic, DWORD dwFlags,
// LPBITMAPINFOHEADER lpbiOutput, LPVOID lpData, LPBITMAPINFOHEADER lpbiInput, LPVOID lpBits, LPDWORD lpckid, LPDWORD lpdwFlags,
// LONG lFrameNum, DWORD dwFrameSize, DWORD dwQuality, LPBITMAPINFOHEADER lpbiPrev, LPVOID lpPrev );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompress")]
public static extern ICERR ICCompress([In] HIC hic, ICCOMPRESSF dwFlags, in BITMAPINFOHEADER lpbiOutput, [Out] IntPtr lpData,
in BITMAPINFOHEADER lpbiInput, [In] IntPtr lpBits, [Out, Optional] IntPtr lpckid, out AviFil32.AVIIF lpdwFlags, int lFrameNum, uint dwFrameSize,
uint dwQuality, [In, Optional] IntPtr lpbiPrev, [In, Optional] IntPtr lpPrev);
///
/// The ICCompressBegin macro notifies a video compression driver to prepare to compress data. You can use this macro or explicitly
/// call the ICM_COMPRESS_BEGIN message.
///
/// Handle to a compressor.
/// Pointer to a BITMAPINFO structure containing the input format.
/// Pointer to a BITMAPINFO structure containing the output format.
/// None
///
///
/// The driver should allocate and initialize any tables or memory that it needs for compressing the data formats when it receives
/// the ICM_COMPRESS message.
///
///
/// VCM saves the settings of the most recent ICCompressBegin macro. The ICCompressBegin and ICCompressEnd
/// messages do not nest. If your driver receives ICM_COMPRESS_BEGIN before compression is stopped with
/// ICM_COMPRESS_END, it should restart compression with new parameters.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iccompressbegin void ICCompressBegin( hic, lpbiInput, lpbiOutput );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompressBegin")]
public static ICERR ICCompressBegin(HIC hic, in BITMAPINFO lpbiInput, in BITMAPINFO lpbiOutput) =>
(ICERR)ICSendMessage(hic, ICM_Message.ICM_COMPRESS_BEGIN, lpbiInput, lpbiOutput).ToInt32();
///
/// The ICCompressEnd macro notifies a video compression driver to end compression and free resources allocated for
/// compression. You can use this macro or explicitly call the ICM_COMPRESS_END message.
///
/// Handle of the compressor.
/// None
///
/// VCM saves the settings of the most recent ICCompressBegin macro. ICCompressBegin and ICCompressEnd do not
/// nest. If your driver receives the ICM_COMPRESS_BEGIN message before compression is stopped with the
/// ICM_COMPRESS_END message, it should restart compression with new parameters.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iccompressend void ICCompressEnd( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompressEnd")]
public static ICERR ICCompressEnd(HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_COMPRESS_END).ToInt32();
///
/// The ICCompressGetFormat macro requests the output format of the compressed data from a video compression driver. You can
/// use this macro or explicitly call the ICM_COMPRESS_GET_FORMAT message.
///
/// Handle of the compressor.
/// Pointer to a BITMAPINFO structure containing the input format.
/// Pointer to a BITMAPINFO structure containing the output format.
/// None
///
/// If lpbiOutput is nonzero, the driver should fill the BITMAPINFO structure with the default output format corresponding to
/// the input format specified for lpbiInput. If the compressor can produce several formats, the default format should be the one
/// that preserves the greatest amount of information.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iccompressgetformat void ICCompressGetFormat( hic, lpbiInput,
// lpbiOutput );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompressGetFormat")]
public static ICERR ICCompressGetFormat(HIC hic, in BITMAPINFO lpbiInput, in BITMAPINFO lpbiOutput)
{
using var dw1 = SafeCoTaskMemHandle.CreateFromStructure(lpbiInput);
using var dw2 = SafeCoTaskMemHandle.CreateFromStructure(lpbiOutput);
return (ICERR)ICSendMessage(hic, ICM_Message.ICM_COMPRESS_GET_FORMAT, dw1, dw2).ToInt32();
}
///
/// The ICCompressGetFormatSize macro requests the size of the output format of the compressed data from a video compression
/// driver. You can use this macro or explicitly call the ICM_COMPRESS_GET_FORMAT message.
///
/// Handle of the compressor.
/// Pointer to a BITMAPINFO structure containing the input format.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iccompressgetformatsize void ICCompressGetFormatSize( hic, lpbi );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompressGetFormatSize")]
public static int ICCompressGetFormatSize(HIC hic, in BITMAPINFO lpbi)
{
using var dw1 = SafeCoTaskMemHandle.CreateFromStructure(lpbi);
return ICSendMessage(hic, ICM_Message.ICM_COMPRESS_GET_FORMAT, dw1).ToInt32();
}
///
/// The ICCompressGetSize macro requests that the video compression driver supply the maximum size of one frame of data when
/// compressed into the specified output format. You can use this macro or explicitly call the ICM_COMPRESS_GET_SIZE message.
///
/// Handle to a compressor.
/// Pointer to a BITMAPINFO structure containing the input format.
/// Pointer to a BITMAPINFO structure containing the output format.
/// None
///
/// Typically, applications send this message to determine how large a buffer to allocate for the compressed frame.
/// The driver should calculate the size of the largest possible frame based on the input and output formats.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iccompressgetsize void ICCompressGetSize( hic, lpbiInput,
// lpbiOutput );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompressGetSize")]
public static int ICCompressGetSize(HIC hic, in BITMAPINFO lpbiInput, in BITMAPINFO lpbiOutput)
{
using var dw1 = SafeCoTaskMemHandle.CreateFromStructure(lpbiInput);
using var dw2 = SafeCoTaskMemHandle.CreateFromStructure(lpbiOutput);
return ICSendMessage(hic, ICM_Message.ICM_COMPRESS_GET_SIZE, dw1, dw2).ToInt32();
}
///
/// The ICCompressorChoose function displays a dialog box in which a user can select a compressor. This function can display
/// all registered compressors or list only the compressors that support a specific format.
///
/// Handle to a parent window for the dialog box.
///
/// Applicable flags. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// ICMF_CHOOSE_ALLCOMPRESSORS
///
/// All compressors should appear in the selection list. If this flag is not specified, only the compressors that can handle the
/// input format appear in the selection list.
///
///
/// -
/// ICMF_CHOOSE_DATARATE
/// Displays a check box and edit box to enter the data rate for the movie.
///
/// -
/// ICMF_CHOOSE_KEYFRAME
/// Displays a check box and edit box to enter the frequency of key frames.
///
/// -
/// ICMF_CHOOSE_PREVIEW
///
/// Displays a button to expand the dialog box to include a preview window. The preview window shows how frames of your movie will
/// appear when compressed with the current settings.
///
///
///
///
///
/// Uncompressed data input format. Only compressors that support the specified data input format are included in the compressor
/// list. This parameter is optional.
///
///
/// Pointer to an AVI stream interface to use in the preview window. You must specify a video stream. This parameter is optional.
///
/// Pointer to a COMPVARS structure. The information returned initializes the structure for use with other functions.
/// Pointer to a null-terminated string containing a title for the dialog box. This parameter is optional.
///
/// Returns TRUE if the user chooses a compressor and presses OK. Returns FALSE on error or if the user presses CANCEL.
///
///
/// Before using this function, set the cbSize member of the COMPVARS structure to the size of the structure. Initialize the
/// rest of the structure to zeros unless you want to specify some valid defaults for the dialog box. If specifying defaults, set
/// the dwFlags member to ICMF_COMPVARS_VALID and initialize the other members of the structure. For more information about
/// initializing the structure, see the ICSeqCompressFrameStart function and COMPVARS.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iccompressorchoose BOOL VFWAPI ICCompressorChoose( HWND hwnd, UINT
// uiFlags, LPVOID pvIn, LPVOID lpData, PCOMPVARS pc, LPSTR lpszTitle );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompressorChoose")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ICCompressorChoose([In, Optional] HWND hwnd, ICMF_CHOOSE uiFlags, [In, Optional] IntPtr pvIn, [In, Optional] IntPtr lpData,
ref COMPVARS pc, [Optional, MarshalAs(UnmanagedType.LPStr)] string lpszTitle);
/// The ICCompressorFree function frees the resources in the COMPVARS structure used by other VCM functions.
/// Pointer to the COMPVARS structure containing the resources to be freed.
/// This function does not return a value.
///
/// Use this function to release the resources in the COMPVARS structure after using the ICCompressorChoose,
/// ICSeqCompressFrameStart, ICSeqCompressFrame, and ICSeqCompressFrameEnd functions.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iccompressorfree void VFWAPI ICCompressorFree( PCOMPVARS pc );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompressorFree")]
public static extern void ICCompressorFree(in COMPVARS pc);
///
/// The ICCompressQuery macro queries a video compression driver to determine if it supports a specific input format or if it
/// can compress a specific input format to a specific output format. You can use this macro or explicitly call the
/// ICM_COMPRESS_QUERY message.
///
/// Handle to a compressor.
/// Pointer to a BITMAPINFO structure containing the input format.
///
/// Pointer to a BITMAPINFO structure containing the output format. You can specify zero for this parameter to indicate any output
/// format is acceptable.
///
/// None
///
/// When a driver receives this message, it should examine the BITMAPINFO structure associated with lpbiInput to determine if it can
/// compress the input format.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iccompressquery void ICCompressQuery( hic, lpbiInput, lpbiOutput );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICCompressQuery")]
public static ICERR ICCompressQuery(HIC hic, in BITMAPINFO lpbiInput, in BITMAPINFO lpbiOutput)
{
using var dw1 = SafeCoTaskMemHandle.CreateFromStructure(lpbiInput);
using var dw2 = SafeCoTaskMemHandle.CreateFromStructure(lpbiOutput);
return (ICERR)ICSendMessage(hic, ICM_Message.ICM_COMPRESS_QUERY, dw1, dw2).ToInt32();
}
///
/// The ICConfigure macro notifies a video compression driver to display its configuration dialog box. You can use this macro
/// or explicitly send the ICM_CONFIGURE message.
///
/// Handle of the compressor.
/// Handle of the parent window of the displayed dialog box.
/// None
///
/// The ICM_CONFIGURE message is different from the DRV_CONFIGURE message used for hardware configuration. The dialog box for this
/// message should let the user set and edit the internal state referenced by the ICGetState and ICSetState macros. For example,
/// this dialog box can let the user change parameters affecting the quality level and other similar compression options.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icconfigure void ICConfigure( hic, hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICConfigure")]
public static ICERR ICConfigure(HIC hic, HWND hwnd) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_CONFIGURE, (IntPtr)hwnd).ToInt32();
/// The ICDecompress function decompresses a single video frame.
/// Handle to the decompressor to use.
///
/// Applicable decompression flags. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// ICDECOMPRESS_HURRYUP
///
/// Tries to decompress at a faster rate. When an application uses this flag, the driver should buffer the decompressed data but not
/// draw the image.
///
///
/// -
/// ICDECOMPRESS_NOTKEYFRAME
/// Current frame is not a key frame.
///
/// -
/// ICDECOMPRESS_NULLFRAME
/// Current frame does not contain data and the decompressed image should be left the same.
///
/// -
/// ICDECOMPRESS_PREROLL
/// Current frame precedes the point in the movie where playback starts and, therefore, will not be drawn.
///
/// -
/// ICDECOMPRESS_UPDATE
/// Screen is being updated or refreshed.
///
///
///
/// Pointer to a BITMAPINFOHEADER structure containing the format of the compressed data.
/// Pointer to the input data.
/// Pointer to a BITMAPINFOHEADER structure containing the output format.
/// Pointer to a buffer that is large enough to contain the decompressed data.
/// Returns ICERR_OK if successful or an error otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompress DWORD VFWAPIV ICDecompress( HIC hic, DWORD dwFlags,
// LPBITMAPINFOHEADER lpbiFormat, LPVOID lpData, LPBITMAPINFOHEADER lpbi, LPVOID lpBits );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompress")]
public static extern ICERR ICDecompress([In] HIC hic, ICDECOMPRESSF dwFlags, in BITMAPINFOHEADER lpbiFormat, [In] IntPtr lpData, in BITMAPINFOHEADER lpbi, [Out] IntPtr lpBits);
///
/// The ICDecompressBegin macro notifies a video decompression driver to prepare to decompress data. You can use this macro
/// or explicitly call the ICM_DECOMPRESS_BEGIN message.
///
/// Handle to a decompressor.
/// Pointer to a BITMAPINFO structure containing the input format.
/// Pointer to a BITMAPINFO structure containing the output format.
/// None
///
///
/// When the driver receives this message, it should allocate buffers and do any time-consuming operations so that it can process
/// ICM_DECOMPRESS messages efficiently.
///
///
/// The ICDecompressBegin and ICDecompressEnd macros do not nest. If your driver receives ICM_DECOMPRESS_BEGIN before
/// decompression is stopped with ICM_DECOMPRESS_END, it should restart decompression with new parameters.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressbegin void ICDecompressBegin( hic, lpbiInput,
// lpbiOutput );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressBegin")]
public static ICERR ICDecompressBegin([In] HIC hic, in BITMAPINFOHEADER lpbiInput, in BITMAPINFOHEADER lpbiOutput) =>
(ICERR)ICSendMessage(hic, ICM_Message.ICM_DECOMPRESS_BEGIN, lpbiInput, lpbiOutput).ToInt32();
///
/// The ICDecompressEnd macro notifies a video decompression driver to end decompression and free resources allocated for
/// decompression. You can use this macro or explicitly call the ICM_DECOMPRESS_END message.
///
/// Handle to a decompressor.
/// None
///
/// The driver should free any resources allocated for the ICM_DECOMPRESS_BEGIN message.
///
/// The ICDecompressBegin and ICDecompressEnd macros do not nest. If your driver receives ICM_DECOMPRESS_BEGIN before
/// decompression is stopped with ICM_DECOMPRESS_END, it should restart decompression with new parameters.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressend void ICDecompressEnd( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressEnd")]
public static ICERR ICDecompressEnd([In] HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_DECOMPRESS_END).ToInt32();
/// The ICDecompressEx function decompresses a single video frame.
/// Handle to the decompressor.
///
/// Decompression flags. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// ICDECOMPRESS_HURRYUP
///
/// Tries to decompress at a faster rate. When an application uses this flag, the driver should buffer the decompressed data but not
/// draw the image.
///
///
/// -
/// ICDECOMPRESS_NOTKEYFRAME
/// Current frame is not a key frame.
///
/// -
/// ICDECOMPRESS_NULLFRAME
/// Current frame does not contain data and the decompressed image should be left the same.
///
/// -
/// ICDECOMPRESS_PREROLL
/// Current frame precedes the point in the movie where playback starts and, therefore, will not be drawn.
///
/// -
/// ICDECOMPRESS_UPDATE
/// Screen is being updated or refreshed.
///
///
///
/// Pointer to a BITMAPINFOHEADER structure containing the format of the compressed data.
/// Pointer to the input data.
/// The x-coordinate of the source rectangle for the DIB specified by lpbiSrc.
/// The y-coordinate of the source rectangle for the DIB specified by lpbiSrc.
/// Width of the source rectangle.
/// Height of the source rectangle.
/// Pointer to a BITMAPINFOHEADER structure containing the output format.
/// Pointer to a buffer that is large enough to contain the decompressed data.
/// The x-coordinate of the destination rectangle for the DIB specified by lpbiDst.
/// The y-coordinate of the destination rectangle for the DIB specified by lpbiDst.
/// Width of the destination rectangle.
/// Height of the destination rectangle.
/// Returns ICERR_OK if successful or an error otherwise.
///
/// Typically, applications use the ICDECOMPRESS_PREROLL flag to seek to a key frame in a compressed stream. The flag is sent
/// with the key frame and with subsequent frames required to decompress the desired frame.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressex LRESULT VFWAPI_INLINE ICDecompressEx( HIC hic, DWORD
// dwFlags, LPBITMAPINFOHEADER lpbiSrc, LPVOID lpSrc, int xSrc, int ySrc, int dxSrc, int dySrc, LPBITMAPINFOHEADER lpbiDst, LPVOID
// lpDst, int xDst, int yDst, int dxDst, int dyDst );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressEx")]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ICERR ICDecompressEx([In] HIC hic, ICDECOMPRESSF dwFlags, in BITMAPINFOHEADER lpbiSrc, [In] IntPtr lpSrc, int xSrc, int ySrc,
int dxSrc, int dySrc, in BITMAPINFOHEADER lpbiDst, [Out] IntPtr lpDst, int xDst, int yDst, int dxDst, int dyDst)
{
unsafe
{
fixed (void* pIn = &lpbiSrc, pOut = &lpbiDst)
{
ICDECOMPRESSEX ic = new ICDECOMPRESSEX
{
dwFlags = dwFlags,
lpbiSrc = (IntPtr)pIn,
lpSrc = lpSrc,
xSrc = xSrc,
ySrc = ySrc,
dxSrc = dxSrc,
dySrc = dySrc,
lpbiDst = (IntPtr)pOut,
lpDst = lpDst,
xDst = xDst,
yDst = yDst,
dxDst = dxDst,
dyDst = dyDst
};
// note that ICM swaps round the length and pointer length in lparam2, pointer in lparam1
return (ICERR)ICSendMessage(hic, ICM_Message.ICM_DECOMPRESSEX, (IntPtr)(void*)&ic, (IntPtr)Marshal.SizeOf(ic)).ToInt32();
}
}
}
/// The ICDecompressExBegin function prepares a decompressor for decompressing data.
/// Handle to the decompressor to use.
///
/// Decompression flags. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// ICDECOMPRESS_HURRYUP
///
/// Tries to decompress at a faster rate. When an application uses this flag, the driver should buffer the decompressed data but not
/// draw the image.
///
///
/// -
/// ICDECOMPRESS_NOTKEYFRAME
/// Current frame is not a key frame.
///
/// -
/// ICDECOMPRESS_NULLFRAME
/// Current frame does not contain data and the decompressed image should be left the same.
///
/// -
/// ICDECOMPRESS_PREROLL
/// Current frame precedes the point in the movie where playback starts and, therefore, will not be drawn.
///
/// -
/// ICDECOMPRESS_UPDATE
/// Screen is being updated or refreshed.
///
///
///
/// Pointer to a BITMAPINFOHEADER structure containing the format of the compressed data.
/// Pointer to the input data.
/// The x-coordinate of the source rectangle for the DIB specified by lpbiSrc.
/// The y-coordinate of the source rectangle for the DIB specified by lpbiSrc.
/// Width of the source rectangle.
/// Height of the source rectangle.
/// Pointer to a BITMAPINFOHEADER structure containing the output format.
/// Pointer to a buffer that is large enough to contain the decompressed data.
/// The x-coordinate of the destination rectangle for the DIB specified by lpbiDst.
/// The y-coordinate of the destination rectangle for the DIB specified by lpbiDst.
/// Width of the destination rectangle.
/// Height of the destination rectangle.
/// Returns ICERR_OK if successful or an error otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressexbegin LRESULT VFWAPI_INLINE ICDecompressExBegin( HIC
// hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiSrc, LPVOID lpSrc, int xSrc, int ySrc, int dxSrc, int dySrc, LPBITMAPINFOHEADER
// lpbiDst, LPVOID lpDst, int xDst, int yDst, int dxDst, int dyDst );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressExBegin")]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ICERR ICDecompressExBegin([In] HIC hic, ICDECOMPRESSF dwFlags, in BITMAPINFOHEADER lpbiSrc, [In] IntPtr lpSrc, int xSrc, int ySrc,
int dxSrc, int dySrc, in BITMAPINFOHEADER lpbiDst, [Out] IntPtr lpDst, int xDst, int yDst, int dxDst, int dyDst)
{
unsafe
{
fixed (void* pIn = &lpbiSrc, pOut = &lpbiDst)
{
ICDECOMPRESSEX ic = new ICDECOMPRESSEX
{
dwFlags = dwFlags,
lpbiSrc = (IntPtr)pIn,
lpSrc = lpSrc,
xSrc = xSrc,
ySrc = ySrc,
dxSrc = dxSrc,
dySrc = dySrc,
lpbiDst = (IntPtr)pOut,
lpDst = lpDst,
xDst = xDst,
yDst = yDst,
dxDst = dxDst,
dyDst = dyDst
};
// note that ICM swaps round the length and pointer length in lparam2, pointer in lparam1
return (ICERR)ICSendMessage(hic, ICM_Message.ICM_DECOMPRESSEX_BEGIN, (IntPtr)(void*)&ic, (IntPtr)Marshal.SizeOf(ic)).ToInt32();
}
}
}
///
/// The ICDecompressExEnd macro notifies a video decompression driver to end decompression and free resources allocated for
/// decompression. You can use this macro or explicitly call the ICM_DECOMPRESSEX_END message.
///
/// Handle to a decompressor.
/// None
///
/// The driver frees any resources allocated for the ICM_DECOMPRESSEX_BEGIN message.
///
/// ICM_DECOMPRESSEX_BEGIN and ICM_DECOMPRESSEX_END do not nest. If your driver receives ICM_DECOMPRESSEX_BEGIN before decompression
/// is stopped with ICM_DECOMPRESSEX_END, it should restart decompression with new parameters.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressexend void ICDecompressExEnd( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressExEnd")]
public static ICERR ICDecompressExEnd([In] HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_DECOMPRESSEX_END).ToInt32();
/// The ICDecompressExQuery function determines if a decompressor can decompress data with a specific format.
/// Handle to the decompressor to use.
/// Pointer to a BITMAPINFOHEADER structure containing the format of the compressed data to decompress.
/// The x-coordinate of the source rectangle for the DIB specified by lpbiSrc.
/// The y-coordinate of the source rectangle for the DIB specified by lpbiSrc.
/// Width of the source rectangle.
/// Height of the source rectangle.
///
/// Pointer to a BITMAPINFOHEADER structure containing the output format. If the value of this parameter is NULL, the
/// function determines whether the input format is supported and this parameter is ignored.
///
/// Pointer to a buffer that is large enough to contain the decompressed data.
/// The x-coordinate of the destination rectangle for the DIB specified by lpbiDst.
/// The y-coordinate of the destination rectangle for the DIB specified by lpbiDst.
/// Width of the destination rectangle.
/// Height of the destination rectangle.
/// Returns ICERR_OK if successful or an error otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressexquery LRESULT VFWAPI_INLINE ICDecompressExQuery( HIC
// hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiSrc, LPVOID lpSrc, int xSrc, int ySrc, int dxSrc, int dySrc, LPBITMAPINFOHEADER
// lpbiDst, LPVOID lpDst, int xDst, int yDst, int dxDst, int dyDst );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressExQuery")]
public static ICERR ICDecompressExQuery([In] HIC hic, in BITMAPINFOHEADER lpbiSrc, int xSrc, int ySrc,
int dxSrc, int dySrc, in BITMAPINFOHEADER lpbiDst, [Out] IntPtr lpDst, int xDst, int yDst, int dxDst, int dyDst)
{
unsafe
{
fixed (void* pIn = &lpbiSrc, pOut = &lpbiDst)
{
ICDECOMPRESSEX ic = new ICDECOMPRESSEX
{
dwFlags = 0,
lpbiSrc = (IntPtr)pIn,
lpSrc = IntPtr.Zero,
xSrc = xSrc,
ySrc = ySrc,
dxSrc = dxSrc,
dySrc = dySrc,
lpbiDst = (IntPtr)pOut,
lpDst = lpDst,
xDst = xDst,
yDst = yDst,
dxDst = dxDst,
dyDst = dyDst
};
// note that ICM swaps round the length and pointer length in lparam2, pointer in lparam1
return (ICERR)ICSendMessage(hic, ICM_Message.ICM_DECOMPRESSEX_QUERY, (IntPtr)(void*)&ic, (IntPtr)Marshal.SizeOf(ic)).ToInt32();
}
}
}
///
/// The ICDecompressGetFormat macro requests the output format of the decompressed data from a video decompression driver.
/// You can use this macro or explicitly call the ICM_DECOMPRESS_GET_FORMAT message.
///
/// Handle to a decompressor.
/// Pointer to a BITMAPINFO structure containing the input format.
///
/// Pointer to a BITMAPINFO structure to contain the output format. You can specify zero to request only the size of the output
/// format, as in the ICDecompressGetFormatSize macro.
///
/// None
///
/// If lpbiOutput is nonzero, the driver should fill the BITMAPINFO structure with the default output format corresponding to the
/// input format specified for lpbiInput. If the compressor can produce several formats, the default format should be the one that
/// preserves the greatest amount of information.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressgetformat void ICDecompressGetFormat( hic, lpbiInput,
// lpbiOutput );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressGetFormat")]
public static ICERR ICDecompressGetFormat([In] HIC hic, in BITMAPINFO lpbiInput, in BITMAPINFO lpbiOutput) =>
(ICERR)ICSendMessage(hic, ICM_Message.ICM_DECOMPRESS_GET_FORMAT, lpbiInput, lpbiOutput).ToInt32();
///
/// The ICDecompressGetFormatSize macro requests the size of the output format of the decompressed data from a video
/// decompression driver. You can use this macro or explicitly call the ICM_DECOMPRESS_GET_FORMAT message.
///
/// Handle to a decompressor.
/// Pointer to a BITMAPINFO structure containing the input format.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressgetformatsize void ICDecompressGetFormatSize( hic, lpbi );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressGetFormatSize")]
public static int ICDecompressGetFormatSize([In] HIC hic, in BITMAPINFO lpbi)
{
using var pIn = SafeCoTaskMemHandle.CreateFromStructure(lpbi);
return ICSendMessage(hic, ICM_Message.ICM_DECOMPRESS_GET_FORMAT, pIn).ToInt32();
}
///
/// The ICDecompressGetPalette macro requests that the video decompression driver supply the color table of the output
/// BITMAPINFOHEADER structure. You can use this macro or explicitly call the ICM_DECOMPRESS_GET_PALETTE message.
///
/// Handle to a decompressor.
/// Pointer to a BITMAPINFOHEADER structure containing the input format.
///
/// Pointer to a BITMAPINFOHEADER structure to contain the color table. The space reserved for the color table is always at least
/// 256 colors. You can specify zero for this parameter to return only the size of the color table.
///
/// None
///
///
/// If lpbiOutput is nonzero, the driver sets the biClrUsed member of BITMAPINFOHEADER to the number of colors in the color
/// table. The driver fills the bmiColors members of BITMAPINFO with the actual colors.
///
/// The driver should support this message only if it uses a palette other than the one specified in the input format.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressgetpalette void ICDecompressGetPalette( hic, lpbiInput,
// lpbiOutput );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressGetPalette")]
public static ICERR ICDecompressGetPalette([In] HIC hic, in BITMAPINFOHEADER lpbiInput, in BITMAPINFOHEADER lpbiOutput) =>
(ICERR)ICSendMessage(hic, ICM_Message.ICM_DECOMPRESS_GET_PALETTE, lpbiInput, lpbiOutput).ToInt32();
/// The ICDecompressOpen macro opens a decompressor that is compatible with the specified formats.
///
/// Four-character code indicating the type of compressor to open. For video streams, the value of this parameter is "VIDC" or ICTYPE_VIDEO.
///
///
/// Four-character code indicating the preferred stream handler to use. Typically, this information is stored in the stream header
/// in an AVI file.
///
///
/// Pointer to a structure defining the input format. A decompressor handle is not returned unless it can decompress this format.
/// For bitmaps, this parameter refers to a BITMAPINFOHEADER structure.
///
///
///
/// Pointer to a structure defining an optional decompression format. You can also specify zero to use the default output format
/// associated with the input format.
///
///
/// If this parameter is nonzero, a compressor handle is not returned unless it can create this output format. For bitmaps, this
/// parameter refers to a BITMAPINFOHEADER structure.
///
///
/// None
///
/// The ICDecompressOpen macro is defined as follows:
///
/// #define ICDecompressOpen(fccType, fccHandler, lpbiIn, lpbiOut) \ ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, ICMODE_DECOMPRESS);
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressopen void ICDecompressOpen( fccType, fccHandler,
// lpbiIn, lpbiOut );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressOpen")]
public static SafeHIC ICDecompressOpen(uint fccType, [Optional] uint fccHandler, in BITMAPINFOHEADER lpbiIn, in BITMAPINFOHEADER lpbiOut) =>
ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, ICMODE.ICMODE_DECOMPRESS);
/// The ICDecompressOpen macro opens a decompressor that is compatible with the specified formats.
///
/// Four-character code indicating the type of compressor to open. For video streams, the value of this parameter is "VIDC" or ICTYPE_VIDEO.
///
///
/// Four-character code indicating the preferred stream handler to use. Typically, this information is stored in the stream header
/// in an AVI file.
///
///
/// Pointer to a structure defining the input format. A decompressor handle is not returned unless it can decompress this format.
/// For bitmaps, this parameter refers to a BITMAPINFOHEADER structure.
///
/// None
///
/// The ICDecompressOpen macro is defined as follows:
///
/// #define ICDecompressOpen(fccType, fccHandler, lpbiIn, lpbiOut) \ ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, ICMODE_DECOMPRESS);
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressopen void ICDecompressOpen( fccType, fccHandler,
// lpbiIn, lpbiOut );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressOpen")]
public static SafeHIC ICDecompressOpen(uint fccType, [Optional] uint fccHandler, in BITMAPINFOHEADER lpbiIn) =>
ICLocate(fccType, fccHandler, lpbiIn, IntPtr.Zero, ICMODE.ICMODE_DECOMPRESS);
///
/// The ICDecompressQuery macro queries a video decompression driver to determine if it supports a specific input format or
/// if it can decompress a specific input format to a specific output format. You can use this macro or explicitly call the
/// ICM_DECOMPRESS_QUERY message.
///
/// Handle to a decompressor.
/// Pointer to a BITMAPINFO structure containing the input format.
///
/// Pointer to a BITMAPINFO structure containing the output format. You can specify zero for this parameter to indicate any output
/// format is acceptable.
///
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompressquery void ICDecompressQuery( hic, lpbiInput,
// lpbiOutput );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressQuery")]
public static ICERR ICDecompressQuery([In] HIC hic, in BITMAPINFO lpbiInput, in BITMAPINFO lpbiOutput) =>
(ICERR)ICSendMessage(hic, ICM_Message.ICM_DECOMPRESS_QUERY, lpbiInput, lpbiOutput).ToInt32();
///
/// The ICDecompressSetPalette macro specifies a palette for a video decompression driver to use if it is decompressing to a
/// format that uses a palette. You can use this macro or explicitly call the ICM_DECOMPRESS_SET_PALETTE message.
///
/// Handle to a decompressor.
///
/// Pointer to a BITMAPINFOHEADER structure whose color table contains the colors that should be used if possible. You can specify
/// zero to use the default set of output colors.
///
/// None
///
///
/// This macro should not affect decompression already in progress; rather, colors passed using this message should be returned in
/// response to future ICDecompressGetFormat and ICDecompressGetPalette macros. Colors are sent back to the decompression driver in
/// a future ICDecompressBegin macro.
///
///
/// This macro is used primarily when a driver decompresses images to the screen and another application that uses a palette is in
/// the foreground, forcing the decompression driver to adapt to a foreign set of colors.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdecompresssetpalette void ICDecompressSetPalette( hic,
// lpbiPalette );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDecompressSetPalette")]
public static ICERR ICDecompressSetPalette([In] HIC hic, [In, Optional] SafeBITMAPINFO lpbiPalette) =>
(ICERR)ICSendMessage(hic, ICM_Message.ICM_DECOMPRESS_SET_PALETTE, lpbiPalette).ToInt32();
/// The ICDraw function decompresses an image for drawing.
/// Handle to an decompressor.
///
/// Decompression flags. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// ICDRAW_HURRYUP
/// Data is buffered and not drawn to the screen. Use this flag for fastest decompression.
///
/// -
/// ICDRAW_NOTKEYFRAME
/// Current frame is not a key frame.
///
/// -
/// ICDRAW_NULLFRAME
/// Current frame does not contain any data and the previous frame should be redrawn.
///
/// -
/// ICDRAW_PREROLL
///
/// Current frame of video occurs before playback should start. For example, if playback will begin on frame 10, and frame 0 is the
/// nearest previous key frame, frames 0 through 9 are sent to the driver with the ICDRAW_PREROLL flag set. The driver needs this
/// data to display frame 10 properly.
///
///
/// -
/// ICDRAW_UPDATE
/// Updates the screen based on previously received data. Set lpData to NULL when this flag is used.
///
///
///
/// Pointer to a BITMAPINFOHEADER structure containing the input format of the data.
/// Pointer to the input data.
/// Size of the input data, in bytes.
///
/// Time, in samples, to draw this frame. The units for video data are frames. For a definition of the playback rate, see the
/// dwRate and dwScale members of the ICDRAWBEGIN structure.
///
/// Returns ICERR_OK if successful or an error otherwise.
///
/// You can initiate drawing the frames by sending the ICM_DRAW_START message (or by using the ICDrawStart macro). The application
/// should be sure to buffer the required number of frames before drawing is started. Send the KM_GETBUFFERSWANTED message
/// (or use the ICGetBuffersWanted macro) to obtain this value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdraw DWORD VFWAPIV ICDraw( HIC hic, DWORD dwFlags, LPVOID
// lpFormat, LPVOID lpData, DWORD cbData, LONG lTime );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDraw")]
public static extern ICERR ICDraw([In] HIC hic, ICDRAWF dwFlags, in BITMAPINFOHEADER lpFormat, [In, Optional] IntPtr lpData, uint cbData, int lTime);
/// The ICDrawBegin function initializes the renderer and prepares the drawing destination for drawing.
/// Handle to the decompressor to use.
///
/// Decompression flags. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// ICDRAW_ANIMATE
/// Application can animate the palette.
///
/// -
/// ICDRAW_CONTINUE
/// Drawing is a continuation of the previous frame.
///
/// -
/// ICDRAW_FULLSCREEN
/// Draws the decompressed data on the full screen.
///
/// -
/// ICDRAW_HDC
/// Draws the decompressed data to a window or a DC.
///
/// -
/// ICDRAW_MEMORYDC
/// DC is off-screen.
///
/// -
/// ICDRAW_QUERY
/// Determines if the decompressor can decompress the data. The driver does not decompress the data.
///
/// -
/// ICDRAW_UPDATING
/// Current frame is being updated rather than played.
///
///
///
/// Handle to the palette used for drawing.
/// Handle to the window used for drawing.
/// DC used for drawing.
/// The x-coordinate of the upper right corner of the destination rectangle.
/// The y-coordinate of the upper right corner of the destination rectangle.
/// Width of the destination rectangle.
/// Height of the destination rectangle.
/// Pointer to a BITMAPINFOHEADER structure containing the format of the input data to be decompressed.
/// The x-coordinate of the upper right corner of the source rectangle.
/// The y-coordinate of the upper right corner of the source rectangle.
/// Width of the source rectangle.
/// Height of the source rectangle.
/// Frame rate numerator. The frame rate, in frames per second, is obtained by dividing dwRate by dwScale.
/// Frame rate denominator. The frame rate, in frames per second, is obtained by dividing dwRate by dwScale.
/// Returns ICERR_OK if the renderer can decompress the data or ICERR_UNSUPPORTED otherwise.
///
///
/// The ICDRAW_HDC and ICDRAW_FULLSCREEN flags are mutually exclusive. If an application sets the ICDRAW_HDC flag in
/// dwFlags, the decompressor uses hwnd, hdc, and the parameters defining the destination rectangle (xDst, yDst, dxDst, and dyDst).
/// Your application should set these parameters to the size of the destination rectangle. Specify destination rectangle values
/// relative to the current window or DC.
///
///
/// If an application sets the ICDRAW_FULLSCREEN flag in dwFlags, the hwnd and hdc parameters are not used and should be set
/// to NULL. Also, the destination rectangle is not used and its parameters can be set to zero.
///
///
/// The source rectangle is relative to the full video frame. The portion of the video frame specified by the source rectangle is
/// stretched or shrunk to fit the destination rectangle.
///
///
/// The dwRate and dwScale parameters specify the decompression rate. The integer value specified for dwRate divided by the integer
/// value specified for dwScale defines the frame rate in frames per second. This value is used by the renderer when it is
/// responsible for timing frames during playback.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawbegin DWORD VFWAPIV ICDrawBegin( HIC hic, DWORD dwFlags,
// HPALETTE hpal, HWND hwnd, HDC hdc, int xDst, int yDst, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi, int xSrc, int ySrc, int
// dxSrc, int dySrc, DWORD dwRate, DWORD dwScale );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawBegin")]
public static extern ICERR ICDrawBegin([In] HIC hic, ICDRAWF dwFlags, [In, Optional] HPALETTE hpal, [In, Optional] HWND hwnd,
[In, Optional] HDC hdc, int xDst, int yDst, int dxDst, int dyDst, in BITMAPINFOHEADER lpbi, int xSrc, int ySrc,
int dxSrc, int dySrc, uint dwRate, uint dwScale);
///
/// The ICDrawChangePalette macro notifies a rendering driver that the movie palette is changing. You can use this macro or
/// explicitly call the ICM_DRAW_CHANGEPALETTE message.
///
/// Handle to a rendering driver.
/// Pointer to a BITMAPINFO structure containing the new format and optional color table.
/// None
///
/// This message should be supported by installable rendering handlers that draw DIBs with an internal structure that includes a palette.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawchangepalette void ICDrawChangePalette( hic, lpbiInput );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawChangePalette")]
public static ICERR ICDrawChangePalette([In] HIC hic, in BITMAPINFO lpbiInput) =>
(ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_CHANGEPALETTE, lpbiInput).ToInt32();
///
/// The ICDrawEnd macro notifies a rendering driver to decompress the current image to the screen and to release resources
/// allocated for decompression and drawing. You can use this macro or explicitly call the ICM_DRAW_END message.
///
/// Handle to a driver.
/// None
///
/// The ICM_DRAW_BEGIN and ICM_DRAW_END messages do not nest. If your driver receives ICM_DRAW_BEGIN before decompression is
/// stopped with ICM_DRAW_END, it should restart decompression with new parameters.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawend void ICDrawEnd( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawEnd")]
public static ICERR ICDrawEnd([In] HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_END).ToInt32();
///
/// The ICDrawFlush macro notifies a rendering driver to render the contents of any image buffers that are waiting to be
/// drawn. You can use this macro or explicitly call the ICM_DRAW_FLUSH message.
///
/// Handle to a driver.
/// None
/// This message is used only by hardware that performs its own asynchronous decompression, timing, and drawing.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawflush void ICDrawFlush( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawFlush")]
public static ICERR ICDrawFlush([In] HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_FLUSH).ToInt32();
///
/// The ICDrawGetTime macro requests a rendering driver that controls the timing of drawing frames to return the current
/// value of its internal clock. You can use this macro or explicitly call the ICM_DRAW_GETTIME message.
///
/// Handle to a driver.
/// Address to contain the current time. The return value should be specified in samples.
/// None
///
/// This message is generally supported by hardware that performs its own asynchronous decompression, timing, and drawing. The
/// message can also be sent if the hardware is being used as the synchronization master.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawgettime void ICDrawGetTime( hic, lplTime );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawGetTime")]
public static ICERR ICDrawGetTime([In] HIC hic, out int lplTime)
{
unsafe
{
int val = 0;
var ret = (ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_GETTIME, (IntPtr)(void*)&val).ToInt32();
lplTime = val;
return ret;
}
}
/// The ICDrawOpen macro opens a driver that can draw images with the specified format.
///
/// Four-character code indicating the type of driver to open. For video streams, the value of this parameter is "VIDC" or ICTYPE_VIDEO.
///
///
/// Four-character code indicating the preferred stream handler to use. Typically, this information is stored in the stream header
/// in an AVI file.
///
///
/// Pointer to the structure defining the input format. A driver handle will not be returned unless it can decompress this format.
/// For images, this parameter refers to a BITMAPINFOHEADER structure.
///
/// None
///
/// The ICDrawOpen macro is defined as follows:
///
/// #define ICDrawOpen(fccType, fccHandler, lpbiIn) \ ICLocate(fccType, fccHandler, lpbiIn, NULL, ICMODE_DRAW);
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawopen void ICDrawOpen( fccType, fccHandler, lpbiIn );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawOpen")]
public static SafeHIC ICDrawOpen(uint fccType, [Optional] uint fccHandler, in BITMAPINFOHEADER lpbiIn) => ICLocate(fccType, fccHandler, lpbiIn, IntPtr.Zero, ICMODE.ICMODE_DRAW);
///
/// The ICDrawQuery macro queries a rendering driver to determine if it can render data in a specific format. You can use
/// this macro or explicitly call the ICM_DRAW_QUERY message.
///
/// Handle to a driver.
/// Pointer to a BITMAPINFO structure containing the input format.
/// None
///
/// This macro differs from the ICDrawBegin macro in that it queries the driver in a general sense. ICDrawBegin determines if
/// the driver can draw the data using the specified format under specific conditions, such as stretching the image.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawquery void ICDrawQuery( hic, lpbiInput );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawQuery")]
public static ICERR ICDrawQuery([In] HIC hic, [In, Optional] SafeBITMAPINFO lpbiInput) =>
(ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_QUERY, lpbiInput).ToInt32();
///
/// The ICDrawRealize macro notifies a rendering driver to realize its drawing palette while drawing. You can use this macro
/// or explicitly call the ICM_DRAW_REALIZE message.
///
/// Handle to a driver.
/// Handle of the DC used to realize the palette.
///
/// Background flag. Specify TRUE to realize the palette as a background task or FALSE to realize the palette in the foreground.
///
/// None
/// Drivers need to respond to this message only if the drawing palette is different from the decompressed palette.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawrealize void ICDrawRealize( hic, hdc, fBackground );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawRealize")]
public static ICERR ICDrawRealize([In] HIC hic, HDC hdc, bool fBackground) =>
(ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_REALIZE, (IntPtr)hdc, new IntPtr(fBackground ? 1 : 0)).ToInt32();
///
/// The ICDrawRenderBuffer macro notifies a rendering driver to draw the frames that have been passed to it. You can use this
/// macro or explicitly call the ICM_DRAW_RENDERBUFFER message.
///
/// Handle to a driver.
/// None
///
/// Use this message with hardware that performs its own asynchronous decompression, timing, and drawing.
///
/// This message is typically used to perform a seek operation when the driver must be specifically instructed to display each video
/// frame passed to it rather than playing a sequence of video frames.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawrenderbuffer void ICDrawRenderBuffer( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawRenderBuffer")]
public static ICERR ICDrawRenderBuffer([In] HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_RENDERBUFFER).ToInt32();
///
/// The ICDrawSetTime macro provides synchronization information to a rendering driver that handles the timing of drawing
/// frames. The synchronization information is the sample number of the frame to draw. You can use this macro or explicitly call the
/// ICM_DRAW_SETTIME message.
///
/// Handle to a driver.
/// Sample number of the frame to render.
/// None
///
///
/// Typically, the driver compares the specified value with the frame number associated with the time of its internal clock and
/// attempts to synchronize the two if the difference is significant.
///
///
/// Use this message when the hardware performs its own asynchronous decompression, timing, and drawing, and the hardware relies on
/// an external synchronization signal (the hardware is not being used as the synchronization master).
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawsettime void ICDrawSetTime( hic, lTime );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawSetTime")]
public static ICERR ICDrawSetTime([In] HIC hic, int lTime) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_SETTIME, (IntPtr)lTime).ToInt32();
///
/// The ICDrawStart macro notifies a rendering driver to start its internal clock for the timing of drawing frames. You can
/// use this macro or explicitly call the ICM_DRAW_START message.
///
/// Handle to a driver.
/// None
///
/// This message is used by hardware that performs its own asynchronous decompression, timing, and drawing.
/// When the driver receives this message, it should start rendering data at the rate specified with the ICM_DRAW_BEGIN message.
///
/// The ICDrawStart and ICDrawStop macros do not nest. If your driver receives ICDrawStart before rendering is stopped
/// with ICDrawStop, it should restart rendering with new parameters.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawstart void ICDrawStart( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawStart")]
public static ICERR ICDrawStart([In] HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_START).ToInt32();
///
/// The ICDrawStartPlay macro provides the start and end times of a play operation to a rendering driver. You can use this
/// macro or explicitly call the ICM_DRAW_START_PLAY message.
///
/// Handle to a driver.
/// Start time.
/// End time.
/// None
///
/// This message precedes any frame data sent to the rendering driver.
///
/// Units for lFrom and lTo are specified with the ICM_DRAW_BEGIN message. For video data this is normally a frame number. For more
/// information about the playback rate, see the dwRate and dwScale members of the ICDRAWBEGIN structure.
///
/// If the end time is less than the start time, the playback direction is reversed.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawstartplay void ICDrawStartPlay( hic, lFrom, lTo );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawStartPlay")]
public static ICERR ICDrawStartPlay([In] HIC hic, int lFrom, int lTo) =>
(ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_START_PLAY, (IntPtr)lFrom, (IntPtr)lTo).ToInt32();
///
/// The ICDrawStop macro notifies a rendering driver to stop its internal clock for the timing of drawing frames. You can use
/// this macro or explicitly call the ICM_DRAW_STOP message.
///
/// Handle to a driver.
/// None
/// This macro is used by hardware that performs its own asynchronous decompression, timing, and drawing.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawstop void ICDrawStop( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawStop")]
public static ICERR ICDrawStop([In] HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_STOP).ToInt32();
///
/// The ICDrawStopPlay macro notifies a rendering driver when a play operation is complete. You can use this macro or
/// explicitly call the ICM_DRAW_STOP_PLAY message.
///
/// Handle to a driver.
/// None
/// Use this message when the play operation is complete. Use the ICDrawStop macro to end timing.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawstopplay void ICDrawStopPlay( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawStopPlay")]
public static ICERR ICDrawStopPlay([In] HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_STOP_PLAY).ToInt32();
/// The ICDrawSuggestFormat function notifies the drawing handler to suggest the input data format.
/// Handle to the driver to use.
///
/// Pointer to a structure containing the format of the compressed data. For bitmaps, this is a BITMAPINFOHEADER structure.
///
///
/// Pointer to a structure to return the suggested format. The drawing handler can receive and draw data from this format. For
/// bitmaps, this is a BITMAPINFOHEADER structure.
///
/// Width of the source rectangle.
/// Height of the source rectangle.
/// Width of the destination rectangle.
/// Height of the destination rectangle.
/// Decompressor that can use the format of data in lpbiIn.
/// Returns ICERR_OK if successful or an error otherwise.
///
///
/// Applications can use this function to determine alternative input formats that a drawing handler can decompress and if the
/// drawing handler can stretch data. If the drawing handler cannot stretch data as requested, the application might have to stretch
/// the data.
///
///
/// If the drawing handler cannot decompress a format provided by an application, use the ICDecompress, ICDecompressEx, j,
/// ICDecompressExQuery, and ICDecompressOpen functions to obtain alternate formats.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawsuggestformat LRESULT VFWAPI_INLINE ICDrawSuggestFormat( HIC
// hic, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, int dxSrc, int dySrc, int dxDst, int dyDst, HIC hicDecomp );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawSuggestFormat")]
public static IntPtr ICDrawSuggestFormat([In] HIC hic, [In] IntPtr lpbiIn, [Out] IntPtr lpbiOut, int dxSrc, int dySrc, int dxDst, int dyDst, [In] HIC hicDecomp) =>
ICSendMessage(hic, ICM_Message.ICM_DRAW_SUGGESTFORMAT, new ICDRAWSUGGEST()
{
lpbiIn = lpbiIn,
lpbiSuggest = lpbiOut,
dxSrc = dxSrc,
dySrc = dySrc,
dxDst = dxDst,
dyDst = dyDst,
hicDecompressor = hicDecomp
});
///
/// The ICDrawWindow macro notifies a rendering driver that the window specified for the ICM_DRAW_BEGIN message needs to be
/// redrawn. The window has moved or become temporarily obscured. You can use this macro or explicitly call the ICM_DRAW_WINDOW message.
///
/// Handle to a driver.
///
/// Pointer to the destination rectangle in screen coordinates. If this parameter points to an empty rectangle, drawing should be
/// turned off.
///
/// None
///
/// This message is supported by hardware that performs its own asynchronous decompression, timing, and drawing.
///
/// Video-overlay drivers use this message to draw when the window is obscured or moved. When a window specified for ICM_DRAW_BEGIN
/// is completely hidden by other windows, the destination rectangle is empty. Drivers should turn off video-overlay hardware when
/// this condition occurs.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icdrawwindow void ICDrawWindow( hic, prc );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICDrawWindow")]
public static ICERR ICDrawWindow([In] HIC hic, in RECT prc) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_DRAW_STOP_PLAY, prc).ToInt32();
///
/// The ICGetBuffersWanted macro queries a driver for the number of buffers to allocate. You can use this macro or explicitly
/// call the ICM_GETBUFFERSWANTED message.
///
/// Handle to a driver.
/// Address to contain the number of samples the driver needs to efficiently render the data.
/// None
///
/// This message is used by drivers that use hardware to render data and want to ensure a minimal time lag caused by waiting for
/// buffers to arrive. For example, if a driver controls a video decompression board that can hold 10 frames of video, it could
/// return 10 for this message. This instructs applications to try to stay 10 frames ahead of the frame it currently needs.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icgetbufferswanted void ICGetBuffersWanted( hic, lpdwBuffers );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICGetBuffersWanted")]
public static ICERR ICGetBuffersWanted([In] HIC hic, out uint lpdwBuffers) => ICSendGetMessage(hic, ICM_Message.ICM_GETBUFFERSWANTED, out lpdwBuffers);
///
/// The ICGetDefaultKeyFrameRate macro queries a video compression driver for its default (or preferred) key-frame spacing.
/// You can use this macro or explicitly call the ICM_GETDEFAULTKEYFRAMERATE message.
///
/// Handle to a compressor.
/// Address to contain the preferred key-frame spacing.
/// None
/// The ICGetDefaultKeyFrameRate macro returns the default key frame rate.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icgetdefaultkeyframerate void ICGetDefaultKeyFrameRate( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICGetDefaultKeyFrameRate")]
public static ICERR ICGetDefaultKeyFrameRate([In] HIC hic, out uint dwICValue) => ICSendGetMessage(hic, ICM_Message.ICM_GETDEFAULTKEYFRAMERATE, out dwICValue);
///
/// The ICGetDefaultQuality macro queries a video compression driver to provide its default quality setting. You can use this
/// macro or explicitly call the ICM_GETDEFAULTQUALITY message.
///
/// Handle to a compressor.
/// Address to contain the default quality value. Quality values range from 0 to 10,000.
/// None
/// The ICGetDefaultQuality macro returns the default quality value.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icgetdefaultquality void ICGetDefaultQuality( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICGetDefaultQuality")]
public static ICERR ICGetDefaultQuality([In] HIC hic, out uint dwICValue) => ICSendGetMessage(hic, ICM_Message.ICM_GETDEFAULTKEYFRAMERATE, out dwICValue);
///
/// The ICGetDisplayFormat function determines the best format available for displaying a compressed image. The function also
/// opens a compressor if a handle of an open compressor is not specified.
///
/// Handle to the compressor to use. Specify NULL to have VCM select and open an appropriate compressor.
/// Pointer to BITMAPINFOHEADER structure containing the compressed format.
///
/// Pointer to a buffer to return the decompressed format. The buffer should be large enough for a BITMAPINFOHEADER structure and
/// 256 color entries.
///
/// Preferred bit depth, if nonzero.
/// Width multiplier to stretch the image. If this parameter is zero, that dimension is not stretched.
/// Height multiplier to stretch the image. If this parameter is zero, that dimension is not stretched.
/// Returns a handle to a decompressor if successful or zero otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icgetdisplayformat HIC VFWAPI ICGetDisplayFormat( HIC hic,
// LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, int BitDepth, int dx, int dy );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICGetDisplayFormat")]
public static extern SafeHIC ICGetDisplayFormat(HIC hic, in BITMAPINFOHEADER lpbiIn, IntPtr lpbiOut, [Optional] int BitDepth, [Optional] int dx, [Optional] int dy);
/// The ICGetInfo function obtains information about a compressor.
/// Handle to a compressor.
/// Pointer to the ICINFO structure to return information about the compressor.
/// Size, in bytes, of the structure pointed to by lpicinfo.
/// Returns the number of bytes copied into the structure or zero if an error occurs.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icgetinfo LRESULT VFWAPI ICGetInfo( HIC hic, ICINFO *picinfo, DWORD
// cb );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICGetInfo")]
public static extern IntPtr ICGetInfo(HIC hic, ref ICINFO picinfo, uint cb);
///
/// The ICGetState macro queries a video compression driver to return its current configuration in a block of memory. You can
/// use this macro or explicitly call the ICM_GETSTATE message.
///
/// Handle of the compressor.
///
/// Pointer to a block of memory to contain the current configuration information. You can specify NULL for this parameter to
/// determine the amount of memory required for the configuration information, as in ICGetStateSize.
///
/// Size, in bytes, of the block of memory.
/// None
///
/// The ICGetStateSize macro returns the number of bytes used by the state data.
/// The structure used to represent configuration information is driver specific and is defined by the driver.
/// Use ICGetStateSize before calling the ICGetState macro to determine the size of buffer to allocate for the call.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icgetstate void ICGetState( hic, pv, cb );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICGetState")]
public static ICERR ICGetState([In] HIC hic, IntPtr pv, uint cb) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_GETSTATE, pv, new IntPtr((int)cb)).ToInt32();
///
/// The ICGetStateSize macro queries a video compression driver to determine the amount of memory required to retrieve the
/// configuration information. You can use this macro or explicitly call the ICM_GETSTATE message.
///
/// Handle of the compressor.
/// The size, in bytes, of the buffer needed to hold state.
/// None
///
/// The structure used to represent configuration information is driver specific and is defined by the driver.
/// Use ICGetStateSize before calling the ICGetState macro to determine the size of buffer to allocate for the call.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icgetstatesize void ICGetStateSize( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICGetStateSize")]
public static ICERR ICGetStateSize([In] HIC hic, out uint size)
{
unsafe
{
uint dw = default;
var ret = (ICERR)ICSendMessage(hic, ICM_Message.ICM_GETSTATE, IntPtr.Zero, (IntPtr)(void*)&dw).ToInt32();
size = dw;
return ret;
}
}
///
/// The ICImageCompress function compresses an image to a given size. This function does not require initialization functions.
///
///
/// Handle to a compressor opened with the ICOpen function. Specify NULL to have VCM select an appropriate compressor for the
/// compression format. An application can have the user select the compressor by using the ICCompressorChoose function, which opens
/// the selected compressor and returns a handle of the compressor in this parameter.
///
/// Reserved; must be zero.
/// Pointer to the BITMAPINFO structure containing the input data format.
/// Pointer to input data bits to compress. The data bits exclude header and format information.
///
/// Pointer to the BITMAPINFO structure containing the compressed output format. Specify NULL to have the compressor use an
/// appropriate format.
///
/// Quality value used by the compressor. Values range from 0 to 10,000.
///
/// Maximum size desired for the compressed image. The compressor might not be able to compress the data to fit within this size.
/// When the function returns, this parameter points to the size of the compressed image. Image sizes are specified in bytes.
///
/// Returns a handle to a compressed DIB. The image data follows the format header.
///
/// To obtain the format information from the BITMAPINFOHEADER structure, use the GlobalLock function to lock the data. Use the
/// GlobalFree function to free the DIB when you are finished.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icimagecompress HANDLE VFWAPI ICImageCompress( HIC hic, UINT
// uiFlags, LPBITMAPINFO lpbiIn, LPVOID lpBits, LPBITMAPINFO lpbiOut, LONG lQuality, LONG *plSize );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICImageCompress")]
public static extern SafeHGlobalHandle ICImageCompress([In] HIC hic, [Optional] uint uiFlags, in BITMAPINFO lpbiIn, [In] IntPtr lpBits, [In, Optional] IntPtr lpbiOut, int lQuality, ref int plSize);
///
/// The ICImageCompress function compresses an image to a given size. This function does not require initialization functions.
///
///
/// Handle to a compressor opened with the ICOpen function. Specify NULL to have VCM select an appropriate compressor for the
/// compression format. An application can have the user select the compressor by using the ICCompressorChoose function, which opens
/// the selected compressor and returns a handle of the compressor in this parameter.
///
/// Reserved; must be zero.
/// Pointer to the BITMAPINFO structure containing the input data format.
/// Pointer to input data bits to compress. The data bits exclude header and format information.
///
/// Pointer to the BITMAPINFO structure containing the compressed output format. Specify NULL to have the compressor use an
/// appropriate format.
///
/// Quality value used by the compressor. Values range from 0 to 10,000.
///
/// Maximum size desired for the compressed image. The compressor might not be able to compress the data to fit within this size.
/// When the function returns, this parameter points to the size of the compressed image. Image sizes are specified in bytes.
///
/// Returns a handle to a compressed DIB. The image data follows the format header.
///
/// To obtain the format information from the BITMAPINFOHEADER structure, use the GlobalLock function to lock the data. Use the
/// GlobalFree function to free the DIB when you are finished.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icimagecompress HANDLE VFWAPI ICImageCompress( HIC hic, UINT
// uiFlags, LPBITMAPINFO lpbiIn, LPVOID lpBits, LPBITMAPINFO lpbiOut, LONG lQuality, LONG *plSize );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICImageCompress")]
public static extern SafeHGlobalHandle ICImageCompress([In] HIC hic, [Optional] uint uiFlags, [In] IntPtr lpbiIn, [In] IntPtr lpBits, [In, Optional] IntPtr lpbiOut, int lQuality, ref int plSize);
/// The ICImageDecompress function decompresses an image without using initialization functions.
///
/// Handle to a decompressor opened with the ICOpen function. Specify NULL to have VCM select an appropriate decompressor for
/// the compressed image.
///
/// Reserved; must be zero.
/// Compressed input data format.
/// Pointer to input data bits to compress. The data bits exclude header and format information.
/// Decompressed output format. Specify NULL to let decompressor use an appropriate format.
///
/// Returns a handle to an uncompressed DIB in the CF_DIB format if successful or NULL otherwise. Image data follows the
/// format header.
///
///
/// To obtain the format information from the LPBITMAPINFOHEADER structure, use the GlobalLock function to lock the
/// data. Use the GlobalFree function to free the DIB when you are finished.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icimagedecompress HANDLE VFWAPI ICImageDecompress( HIC hic, UINT
// uiFlags, LPBITMAPINFO lpbiIn, LPVOID lpBits, LPBITMAPINFO lpbiOut );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICImageDecompress")]
public static extern SafeHGlobalHandle ICImageDecompress([In] HIC hic, [Optional] uint uiFlags, in BITMAPINFO lpbiIn, [In] IntPtr lpBits, [In, Optional] IntPtr lpbiOut);
/// The ICImageDecompress function decompresses an image without using initialization functions.
///
/// Handle to a decompressor opened with the ICOpen function. Specify NULL to have VCM select an appropriate decompressor for
/// the compressed image.
///
/// Reserved; must be zero.
/// Compressed input data format.
/// Pointer to input data bits to compress. The data bits exclude header and format information.
/// Decompressed output format. Specify NULL to let decompressor use an appropriate format.
///
/// Returns a handle to an uncompressed DIB in the CF_DIB format if successful or NULL otherwise. Image data follows the
/// format header.
///
///
/// To obtain the format information from the LPBITMAPINFOHEADER structure, use the GlobalLock function to lock the
/// data. Use the GlobalFree function to free the DIB when you are finished.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icimagedecompress HANDLE VFWAPI ICImageDecompress( HIC hic, UINT
// uiFlags, LPBITMAPINFO lpbiIn, LPVOID lpBits, LPBITMAPINFO lpbiOut );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICImageDecompress")]
public static extern SafeHGlobalHandle ICImageDecompress([In] HIC hic, [Optional] uint uiFlags, [In] IntPtr lpbiIn, [In] IntPtr lpBits, [In, Optional] IntPtr lpbiOut);
///
/// The ICInfo function retrieves information about specific installed compressors or enumerates the installed compressors.
///
/// Four-character code indicating the type of compressor. Specify zero to match all compressor types.
///
/// Four-character code identifying a specific compressor or a number between zero and the number of installed compressors of the
/// type specified by fccType.
///
/// Pointer to a ICINFO structure to return information about the compressor.
/// Returns TRUE if successful or an error otherwise.
///
/// To enumerate the compressors or decompressors, specify an integer for fccHandler. This function returns information for integers
/// between zero and the number of installed compressors or decompressors of the type specified for fccType.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icinfo BOOL VFWAPI ICInfo( DWORD fccType, DWORD fccHandler, ICINFO
// *lpicinfo );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICInfo")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ICInfo(uint fccType, uint fccHandler, out ICINFO lpicinfo);
/// The ICInstall function installs a new compressor or decompressor.
///
/// Four-character code indicating the type of data used by the compressor or decompressor. Specify "VIDC" for a video compressor or decompressor.
///
/// Four-character code identifying a specific compressor or decompressor.
///
/// Pointer to a null-terminated string containing the name of the compressor or decompressor, or the address of a function used for
/// compression or decompression. The contents of this parameter are defined by the flags set for wFlags.
///
/// Reserved; do not use.
///
/// Flags defining the contents of lParam. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// ICINSTALL_DRIVER
/// The lParam parameter contains the address of a null-terminated string that names the compressor to install.
///
/// -
/// ICINSTALL_FUNCTION
///
/// The lParam parameter contains the address of a compressor function. This function should be structured like the DriverProc entry
/// point function used by compressors.
///
///
///
///
/// Returns ICERR_OK if successful or an error otherwise.
///
/// Applications must open an installed compressor or decompressor before using it.
///
/// If your application installs a function as a compressor or decompressor, it should remove the function with the ICRemove
/// function before it terminates. This prevents other applications from trying to access the function when it is not available.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icinstall BOOL VFWAPI ICInstall( DWORD fccType, DWORD fccHandler,
// LPARAM lParam, LPSTR szDesc, UINT wFlags );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICInstall")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ICInstall(uint fccType, uint fccHandler, [In] IntPtr lParam, [Optional, MarshalAs(UnmanagedType.LPStr)] string szDesc, ICINSTALL wFlags);
///
/// The ICLocate function finds a compressor or decompressor that can handle images with the specified formats, or finds a
/// driver that can decompress an image with a specified format directly to hardware.
///
///
/// Four-character code indicating the type of compressor or decompressor to open. For video streams, the value of this parameter is 'VIDC'.
///
///
/// Preferred handler of the specified type. Typically, the handler type is stored in the stream header in an AVI file. Specify
/// NULL if your application can use any handler type or it does not know the handler type to use.
///
///
/// Pointer to a BITMAPINFOHEADER structure defining the input format. A compressor handle is not returned unless it supports this format.
///
///
///
/// Pointer to a BITMAPINFOHEADER structure defining an optional decompressed format. You can also specify zero to use the default
/// output format associated with the input format.
///
/// If this parameter is nonzero, a compressor handle is not returned unless it can create this output format.
///
///
/// Flags that describe the search criteria for a compressor or decompressor. The following values are defined:
///
///
/// Value
/// Meaning
///
/// -
/// ICMODE_COMPRESS
/// Finds a compressor that can compress an image with a format defined by lpbiIn to the format defined by lpbiOut.
///
/// -
/// ICMODE_DECOMPRESS
/// Finds a decompressor that can decompress an image with a format defined by lpbiIn to the format defined by lpbiOut.
///
/// -
/// ICMODE_DRAW
/// Finds a decompressor that can decompress an image with a format defined by lpbiIn and draw it directly to hardware.
///
/// -
/// ICMODE_FASTCOMPRESS
///
/// Has the same meaning as ICMODE_COMPRESS except the compressor is used for a real-time operation and emphasizes speed over quality.
///
///
/// -
/// ICMODE_FASTDECOMPRESS
///
/// Has the same meaning as ICMODE_DECOMPRESS except the decompressor is used for a real-time operation and emphasizes speed over quality.
///
///
///
///
/// Returns a handle to a compressor or decompressor if successful or zero otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iclocate HIC VFWAPI ICLocate( DWORD fccType, DWORD fccHandler,
// LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, WORD wFlags );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICLocate")]
public static extern SafeHIC ICLocate(uint fccType, [Optional] uint fccHandler, in BITMAPINFOHEADER lpbiIn, in BITMAPINFOHEADER lpbiOut, ICMODE wFlags);
///
/// The ICLocate function finds a compressor or decompressor that can handle images with the specified formats, or finds a
/// driver that can decompress an image with a specified format directly to hardware.
///
///
/// Four-character code indicating the type of compressor or decompressor to open. For video streams, the value of this parameter is 'VIDC'.
///
///
/// Preferred handler of the specified type. Typically, the handler type is stored in the stream header in an AVI file. Specify
/// NULL if your application can use any handler type or it does not know the handler type to use.
///
///
/// Pointer to a BITMAPINFOHEADER structure defining the input format. A compressor handle is not returned unless it supports this format.
///
///
///
/// Pointer to a BITMAPINFOHEADER structure defining an optional decompressed format. You can also specify zero to use the default
/// output format associated with the input format.
///
/// If this parameter is nonzero, a compressor handle is not returned unless it can create this output format.
///
///
/// Flags that describe the search criteria for a compressor or decompressor. The following values are defined:
///
///
/// Value
/// Meaning
///
/// -
/// ICMODE_COMPRESS
/// Finds a compressor that can compress an image with a format defined by lpbiIn to the format defined by lpbiOut.
///
/// -
/// ICMODE_DECOMPRESS
/// Finds a decompressor that can decompress an image with a format defined by lpbiIn to the format defined by lpbiOut.
///
/// -
/// ICMODE_DRAW
/// Finds a decompressor that can decompress an image with a format defined by lpbiIn and draw it directly to hardware.
///
/// -
/// ICMODE_FASTCOMPRESS
///
/// Has the same meaning as ICMODE_COMPRESS except the compressor is used for a real-time operation and emphasizes speed over quality.
///
///
/// -
/// ICMODE_FASTDECOMPRESS
///
/// Has the same meaning as ICMODE_DECOMPRESS except the decompressor is used for a real-time operation and emphasizes speed over quality.
///
///
///
///
/// Returns a handle to a compressor or decompressor if successful or zero otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iclocate HIC VFWAPI ICLocate( DWORD fccType, DWORD fccHandler,
// LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, WORD wFlags );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICLocate")]
public static extern SafeHIC ICLocate(uint fccType, [Optional] uint fccHandler, in BITMAPINFOHEADER lpbiIn, [In, Optional] IntPtr lpbiOut, ICMODE wFlags);
/// The ICOpen function opens a compressor or decompressor.
///
/// Four-character code indicating the type of compressor or decompressor to open. For video streams, the value of this parameter is "VIDC".
///
///
/// Preferred handler of the specified type. Typically, the handler type is stored in the stream header in an AVI file.
///
///
/// Flag defining the use of the compressor or decompressor. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// ICMODE_COMPRESS
/// Compressor will perform normal compression.
///
/// -
/// ICMODE_DECOMPRESS
/// Decompressor will perform normal decompression.
///
/// -
/// ICMODE_DRAW
/// Decompressor will decompress and draw the data directly to hardware.
///
/// -
/// ICMODE_FASTCOMPRESS
/// Compressor will perform fast (real-time) compression.
///
/// -
/// ICMODE_FASTDECOMPRESS
/// Decompressor will perform fast (real-time) decompression.
///
/// -
/// ICMODE_QUERY
/// Queries the compressor or decompressor for information.
///
///
///
/// Returns a handle to a compressor or decompressor if successful or zero otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icopen HIC VFWAPI ICOpen( DWORD fccType, DWORD fccHandler, UINT
// wMode );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICOpen")]
public static extern SafeHIC ICOpen(uint fccType, uint fccHandler, ICMODE wMode);
/// The ICOpenFunction function opens a compressor or decompressor defined as a function.
/// Type of compressor to open. For video, the value of this parameter is ICTYPE_VIDEO.
/// Preferred handler of the specified type. Typically, this comes from the stream header in an AVI file.
///
/// Flag to define the use of the compressor or decompressor. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// ICMODE_COMPRESS
/// Compressor will perform normal compression.
///
/// -
/// ICMODE_DECOMPRESS
/// Decompressor will perform normal decompression.
///
/// -
/// ICMODE_DRAW
/// Decompressor will decompress and draw the data directly to hardware.
///
/// -
/// ICMODE_FASTCOMPRESS
/// Compressor will perform fast (real-time) compression.
///
/// -
/// ICMODE_FASTDECOMPRESS
/// Decompressor will perform fast (real-time) decompression.
///
/// -
/// ICMODE_QUERY
/// Queries the compressor or decompressor for information.
///
///
///
/// Pointer to the function used as the compressor or decompressor.
/// Returns a handle to a compressor or decompressor if successful or zero otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icopenfunction HIC VFWAPI ICOpenFunction( DWORD fccType, DWORD
// fccHandler, UINT wMode, FARPROC lpfnHandler );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICOpenFunction")]
public static extern SafeHIC ICOpenFunction(uint fccType, uint fccHandler, ICMODE wMode, [In] IntPtr lpfnHandler);
///
/// The ICQueryAbout macro queries a video compression driver to determine if it has an About dialog box. You can use this
/// macro or explicitly call the ICM_ABOUT message.
///
/// Handle of the compressor.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icqueryabout void ICQueryAbout( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICQueryAbout")]
public static ICERR ICQueryAbout([In] HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_ABOUT, new IntPtr(-1), (IntPtr)1).ToInt32();
///
/// The ICQueryAbout macro queries a video compression driver to determine if it has an About dialog box. You can use this
/// macro or explicitly call the ICM_ABOUT message.
///
/// Handle of the compressor.
/// Handle to the parent window of the displayed dialog box.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icqueryabout void ICQueryAbout( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICQueryAbout")]
public static ICERR ICQueryAbout([In] HIC hic, [In] HWND hwnd) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_ABOUT, (IntPtr)hwnd, IntPtr.Zero).ToInt32();
///
/// The ICQueryConfigure macro queries a video compression driver to determine if it has a configuration dialog box. You can
/// use this macro or explicitly send the ICM_CONFIGURE message.
///
/// Handle of the compressor.
/// None
///
/// This message is different from the DRV_CONFIGURE message used for hardware configuration. The dialog box for this message should
/// let the user set and edit the internal state referenced by the ICM_GETSTATE and ICM_SETSTATE messages. For example, this dialog
/// box can let the user change parameters affecting the quality level and other similar compression options.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icqueryconfigure void ICQueryConfigure( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICQueryConfigure")]
public static ICERR ICQueryConfigure([In] HIC hic) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_CONFIGURE, new IntPtr(-1), (IntPtr)1).ToInt32();
///
/// The ICQueryConfigure macro queries a video compression driver to determine if it has a configuration dialog box. You can
/// use this macro or explicitly send the ICM_CONFIGURE message.
///
/// Handle of the compressor.
/// Handle to the parent window of the displayed dialog box.
/// None
///
/// This message is different from the DRV_CONFIGURE message used for hardware configuration. The dialog box for this message should
/// let the user set and edit the internal state referenced by the ICM_GETSTATE and ICM_SETSTATE messages. For example, this dialog
/// box can let the user change parameters affecting the quality level and other similar compression options.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icqueryconfigure void ICQueryConfigure( hic );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICQueryConfigure")]
public static ICERR ICQueryConfigure([In] HIC hic, [In] HWND hwnd) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_CONFIGURE, (IntPtr)hwnd, (IntPtr)1).ToInt32();
/// The ICRemove function removes an installed compressor.
///
/// Four-character code indicating the type of data used by the compressor or decompressor. Specify "VIDC" for a video compressor or decompressor.
///
///
/// Four-character code identifying a specific compressor or a number between zero and the number of installed compressors of the
/// type specified by fccType.
///
/// Reserved; do not use.
/// Returns TRUE if successful or FALSE otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icremove BOOL VFWAPI ICRemove( DWORD fccType, DWORD fccHandler,
// UINT wFlags );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICRemove")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ICRemove(uint fccType, uint fccHandler, uint wFlags = 0);
/// The ICSendMessage function sends a message to a compressor.
/// Handle to the compressor to receive the message.
/// Message to send.
/// Additional message-specific information.
/// Additional message-specific information.
/// Returns a message-specific result.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icsendmessage LRESULT VFWAPI ICSendMessage( HIC hic, UINT msg,
// DWORD_PTR dw1, DWORD_PTR dw2 );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSendMessage")]
public static extern IntPtr ICSendMessage(HIC hic, uint msg, IntPtr dw1 = default, IntPtr dw2 = default);
/// The ICSendMessage function sends a message to a compressor.
/// Handle to the compressor to receive the message.
/// Message to send.
/// Additional message-specific information.
/// Additional message-specific information.
/// Returns a message-specific result.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icsendmessage LRESULT VFWAPI ICSendMessage( HIC hic, UINT msg,
// DWORD_PTR dw1, DWORD_PTR dw2 );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSendMessage")]
public static extern IntPtr ICSendMessage(HIC hic, ICM_Message msg, IntPtr dw1 = default, IntPtr dw2 = default);
/// The ICSendMessage function sends a message to a compressor.
/// Handle to the compressor to receive the message.
/// Message to send.
/// Additional message-specific information.
/// Additional message-specific information.
/// Returns a message-specific result.
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSendMessage")]
public static IntPtr ICSendMessage(HIC hic, ICM_Message msg, in BITMAPINFOHEADER lpbiInput, in BITMAPINFOHEADER lpbiOutput)
{
unsafe
{
fixed (void* pIn = &lpbiInput, pOut = &lpbiOutput)
{
return ICSendMessage(hic, msg, (IntPtr)pIn, (IntPtr)pOut);
}
}
}
/// The ICSendMessage function sends a message to a compressor.
/// The type of the structure to pass into .
/// Handle to the compressor to receive the message.
/// Message to send.
/// Additional message-specific information.
/// Returns a message-specific result.
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSendMessage")]
public static IntPtr ICSendMessage(HIC hic, ICM_Message msg, in T lpbiInput) where T : struct
{
using var mem = new SafeCoTaskMemStruct(lpbiInput);
return ICSendMessage(hic, msg, mem, (IntPtr)(int)mem.Size);
}
/// The ICSeqCompressFrame function compresses one frame in a sequence of frames.
/// Pointer to a COMPVARS structure initialized with information about the compression.
/// Reserved; must be zero.
/// Pointer to the data bits to compress. (The data bits exclude header or format information.)
/// Returns whether or not the frame was compressed into a key frame.
///
/// Maximum size desired for the compressed image. The compressor might not be able to compress the data to fit within this size.
/// When the function returns, the parameter points to the size of the compressed image. Images sizes are specified in bytes.
///
/// Returns the address of the compressed bits if successful or NULL otherwise.
///
///
/// This function uses a COMPVARS structure to provide settings for the specified compressor and intersperses key frames at the rate
/// specified by the ICSeqCompressorFrameStart function. You can specify values for the data rate for the sequence and the key-frame
/// frequency by using the appropriate members of COMPVARS.
///
/// Use this function instead of the ICCompress function to compress a video sequence.
///
/// You can allow the user to specify a compressor and initialize a COMPVARS structure by using the ICCompressorChoose function. Or,
/// you can initialize a COMPVARS structure manually.
///
///
/// Use the ICSeqCompressFrameStart, ICSeqCompressFrame, and ICSeqCompressFrameEnd functions to compress a sequence of frames
/// to a specified data rate and number of key frames. Use ICSeqCompressFrame once for each frame to be compressed.
///
/// When finished with compression, use the ICCompressorFree function to release the resources specified by COMPVARS.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icseqcompressframe LPVOID VFWAPI ICSeqCompressFrame( PCOMPVARS pc,
// UINT uiFlags, LPVOID lpBits, BOOL *pfKey, LONG *plSize );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSeqCompressFrame")]
public static extern IntPtr ICSeqCompressFrame(in COMPVARS pc, [Optional] uint uiFlags, [In] IntPtr lpBits, [MarshalAs(UnmanagedType.Bool)] out bool pfKey, ref int plSize);
///
/// The ICSeqCompressFrameEnd function ends sequence compression that was initiated by using the ICSeqCompressFrameStart and
/// ICSeqCompressFrame functions.
///
/// Pointer to a COMPVARS structure used during sequence compression.
/// This function does not return a value.
/// When finished with compression, use the ICCompressorFree function to release the resources specified by COMPVARS.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icseqcompressframeend void VFWAPI ICSeqCompressFrameEnd( PCOMPVARS
// pc );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSeqCompressFrameEnd")]
public static extern void ICSeqCompressFrameEnd(in COMPVARS pc);
///
/// The ICSeqCompressFrameStart function initializes resources for compressing a sequence of frames using the
/// ICSeqCompressFrame function.
///
/// Pointer to a COMPVARS structure initialized with information for compression.
/// Format of the data to be compressed.
/// Returns TRUE if successful or FALSE otherwise.
///
///
/// This function uses a COMPVARS structure to provide settings for the specified compressor and intersperses key frames at the rate
/// specified by the lKey member of COMPVARS. You can specify values for the data rate for the sequence and the
/// key-frame frequency by using the appropriate members of COMPVARS.
///
///
/// Use the ICSeqCompressFrameStart, ICSeqCompressFrame, and ICSeqCompressFrameEnd functions to compress a sequence of frames
/// to a specified data rate and number of key frames.
///
/// When finished with compression, use the ICCompressorFree function to release the resources specified in COMPVARS.
///
/// COMPVARS needs to be initialized before you use this function. You can initialize the structure manually or you can allow the
/// user to specify a compressor and initialize a COMPVARS structure by using the ICCompressorChoose function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icseqcompressframestart BOOL VFWAPI ICSeqCompressFrameStart(
// PCOMPVARS pc, LPBITMAPINFO lpbiIn );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSeqCompressFrameStart")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ICSeqCompressFrameStart(in COMPVARS pc, [In] IntPtr lpbiIn);
///
/// The ICSeqCompressFrameStart function initializes resources for compressing a sequence of frames using the
/// ICSeqCompressFrame function.
///
/// Pointer to a COMPVARS structure initialized with information for compression.
/// Format of the data to be compressed.
/// Returns TRUE if successful or FALSE otherwise.
///
///
/// This function uses a COMPVARS structure to provide settings for the specified compressor and intersperses key frames at the rate
/// specified by the lKey member of COMPVARS. You can specify values for the data rate for the sequence and the
/// key-frame frequency by using the appropriate members of COMPVARS.
///
///
/// Use the ICSeqCompressFrameStart, ICSeqCompressFrame, and ICSeqCompressFrameEnd functions to compress a sequence of frames
/// to a specified data rate and number of key frames.
///
/// When finished with compression, use the ICCompressorFree function to release the resources specified in COMPVARS.
///
/// COMPVARS needs to be initialized before you use this function. You can initialize the structure manually or you can allow the
/// user to specify a compressor and initialize a COMPVARS structure by using the ICCompressorChoose function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icseqcompressframestart BOOL VFWAPI ICSeqCompressFrameStart(
// PCOMPVARS pc, LPBITMAPINFO lpbiIn );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSeqCompressFrameStart")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ICSeqCompressFrameStart(in COMPVARS pc, in BITMAPINFO lpbiIn);
///
/// The ICSetState macro notifies a video compression driver to set the state of the compressor. You can use this macro or
/// explicitly call the ICM_SETSTATE message.
///
/// Handle of the compressor.
///
/// Pointer to a block of memory containing configuration data. You can specify NULL for this parameter to reset the
/// compressor to its default state.
///
/// Size, in bytes, of the block of memory.
/// None
///
/// The information used by this message is private and specific to a given compressor. Client applications should use this message
/// only to restore information previously obtained with the ICGetState and ICConfigure macros and should use the ICConfigure
/// macro to adjust the configuration of a video compression driver.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icsetstate void ICSetState( hic, pv, cb );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSetState")]
public static ICERR ICSetState([In] HIC hic, [In] IntPtr pv, uint cb) => (ICERR)ICSendMessage(hic, ICM_Message.ICM_SETSTATE, pv, new IntPtr((int)cb)).ToInt32();
///
/// The ICSetStatusProc function sends the address of a status callback function to a compressor. The compressor calls this
/// function during lengthy operations.
///
/// Handle to the compressor.
/// Applicable flags. Set to zero.
/// Constant specified with the status callback address.
///
/// Pointer to the status callback function. Specify NULL to indicate no status callbacks should be sent.
///
/// Returns ICERR_OK if successful or FALSE otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-icsetstatusproc LRESULT VFWAPI_INLINE ICSetStatusProc( HIC hic,
// DWORD dwFlags, LRESULT lParam, LONG(* )(LPARAM,UINT,LONG) fpfnStatus );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSetStatusProc")]
public static IntPtr ICSetStatusProc([In] HIC hic, [Optional] uint dwFlags, [In] IntPtr lParam, [Optional] Func fpfnStatus) =>
ICSendMessage(hic, ICM_Message.ICM_SET_STATUS_PROC, new ICSETSTATUSPROC() { dwFlags = dwFlags, lParam = lParam, Status = fpfnStatus });
///
/// The StretchDIB function copies a device independent bitmap from one memory location to another and resizes the image to
/// fit the destination rectangle.
///
/// Pointer to a BITMAPINFOHEADER structure that describes the destination bitmap.
/// Pointer to the memory buffer that will receive the copied pixel bits.
/// X coordinate of the destination rectangle's origin.
/// Y coordinate of the destination rectangle's origin.
/// Width, in pixels, of the destination rectangle.
/// Height, in pixels, of the destination rectangle.
/// Pointer to a BITMAPINFOHEADER structure that describes the source bitmap.
/// Pointer to the source bitmap data.
/// X coordinate of the source rectangle's origin.
/// Y coordinate of the source rectangle's origin.
/// Width, in pixels, of the source rectangle.
/// Height, in pixels, of the source rectangle.
/// None
///
/// The size of the destination buffer must be large enough to accommodate any alignment bytes at the end of each pixel row.
///
/// This function does nothing if biSrc and biDst have different values for biBitCount or if the value for biSrc. biBitCount does
/// not equal 8, 16, or 24.
///
///
/// This function performs no dithering or other smoothing. Pixel values are merely dropped or duplicated on a line-by-line,
/// column-by-column basis.
///
///
/// This function does not do any special processing based on pixel encoding except for calculating the number of bits per pixel. In
/// particular this function will not generate correct results when pixels are encoded in groups of more than 1 pixel, as in the
/// case of a YUV format where U and V are decimated and so are not represented equally in each pixel.
///
/// Before including Vfw.h, you must add the following line to your code:
///
/// #define DRAWDIB_INCLUDE_STRETCHDIB
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-stretchdib void StretchDIB( LPBITMAPINFOHEADER biDst, LPVOID lpDst,
// int DstX, int DstY, int DstXE, int DstYE, LPBITMAPINFOHEADER biSrc, LPVOID lpSrc, int SrcX, int SrcY, int SrcXE, int SrcYE );
[DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.StretchDIB")]
public static extern void StretchDIB(in BITMAPINFOHEADER biDst, [Out] IntPtr lpDst, int DstX, int DstY, int DstXE, int DstYE, in BITMAPINFOHEADER biSrc, [In] IntPtr lpSrc, int SrcX, int SrcY, int SrcXE, int SrcYE);
internal static ICERR ICSendGetMessage(HIC hic, ICM_Message msg, out T val) where T : unmanaged
{
unsafe
{
T dw = default;
var ret = (ICERR)ICSendMessage(hic, msg, (IntPtr)(void*)&dw).ToInt32();
val = dw;
return ret;
}
}
/// The ICSendMessage function sends a message to a compressor.
/// Handle to the compressor to receive the message.
/// Message to send.
/// Additional message-specific information.
/// Additional message-specific information.
/// Returns a message-specific result.
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.ICSendMessage")]
internal static IntPtr ICSendMessage(HIC hic, ICM_Message msg, [In] SafeBITMAPINFO lpbiInput, [In, Optional] SafeBITMAPINFO lpbiOutput) =>
ICSendMessage(hic, msg, lpbiInput ?? SafeBITMAPINFO.Null, lpbiOutput ?? SafeBITMAPINFO.Null);
///
/// The COMPVARS structure describes compressor settings for functions such as ICCompressorChoose, ICSeqCompressFrame, and ICCompressorFree.
///
///
/// You can let ICCompressorChoose fill the contents of this structure or you can do it manually. If you manually fill the
/// structure, you must provide information for the following members: cbSize, hic, lpbiOut, lKey, and
/// lQ. Also, you must set the ICMF_COMPVARS_VALID flag in the dwFlags member.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-compvars typedef struct { LONG cbSize; DWORD dwFlags; HIC hic;
// DWORD fccType; DWORD fccHandler; LPBITMAPINFO lpbiIn; LPBITMAPINFO lpbiOut; LPVOID lpBitsOut; LPVOID lpBitsPrev; LONG lFrame;
// LONG lKey; LONG lDataRate; LONG lQ; LONG lKeyCount; LPVOID lpState; LONG cbState; } COMPVARS, *PCOMPVARS;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_11")]
[StructLayout(LayoutKind.Sequential)]
public struct COMPVARS
{
///
/// Size, in bytes, of this structure. This member must be set to validate the structure before calling any function using this structure.
///
public int cbSize;
///
/// Applicable flags. The following value is defined:
///
///
/// Name
/// Description
///
/// -
/// ICMF_COMPVARS_VALID
///
/// Data in this structure is valid and has been manually entered. Set this flag before you call any function if you fill this
/// structure manually. Do not set this flag if you let ICCompressorChoose initialize this structure.
///
///
///
///
public ICMF_COMPVARS dwFlags;
///
/// Handle to the compressor to use. You can open a compressor and obtain a handle of it by using the ICOpen function. You can
/// also choose a compressor by using ICCompressorChoose. ICCompressorChoose opens the chosen compressor and returns the
/// handle of the compressor in this member. You can close the compressor by using ICCompressorFree.
///
public HIC hic;
/// Type of compressor used. Currently only ICTYPE_VIDEO (VIDC) is supported. This member can be set to zero.
public uint fccType;
///
/// Four-character code of the compressor. Specify NULL to indicate the data is not to be recompressed. Specify "DIB" to
/// indicate the data is an uncompressed, full frame. You can use this member to specify which compressor is selected by default
/// when the dialog box is displayed.
///
public uint fccHandler;
/// Reserved; do not use.
public IntPtr lpbiIn;
///
/// Pointer to a BITMAPINFO structure containing the image output format. You can specify a specific format to use or you can
/// specify NULL to use the default compressor associated with the input format. You can also set the image output format
/// by using ICCompressorChoose.
///
public IntPtr lpbiOut;
/// Reserved; do not use.
public IntPtr lpBitsOut;
/// Reserved; do not use.
public IntPtr lpBitsPrev;
/// Reserved; do not use.
public int lFrame;
///
/// Key-frame rate. Specify an integer to indicate the frequency that key frames are to occur in the compressed sequence or zero
/// to not use key frames. You can also let ICCompressorChoose set the key-frame rate selected in the dialog box. The
/// ICSeqCompressFrameStart function uses the value of this member for making key frames.
///
public int lKey;
///
/// Data rate, in kilobytes per second. ICCompressorChoose copies the selected data rate from the dialog box to this member.
///
public int lDataRate;
///
/// Quality setting. Specify a quality setting of 1 to 10,000 or specify ICQUALITY_DEFAULT to use the default quality
/// setting. You can also let ICCompressorChoose set the quality value selected in the dialog box. ICSeqCompressFrameStart uses
/// the value of this member as its quality setting.
///
public int lQ;
/// Reserved; do not use.
public int lKeyCount;
/// Reserved; do not use.
public IntPtr lpState;
/// Reserved; do not use.
public int cbState;
}
///
/// The DRAWDIBTIME structure contains elapsed timing information for performing a set of DrawDib operations. The DrawDibTime
/// function resets the count and the elapsed time value for each operation each time it is called.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-drawdibtime typedef struct { LONG timeCount; LONG timeDraw; LONG
// timeDecompress; LONG timeDither; LONG timeStretch; LONG timeBlt; LONG timeSetDIBits; } DRAWDIBTIME, *LPDRAWDIBTIME;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_12")]
[StructLayout(LayoutKind.Sequential)]
public struct DRAWDIBTIME
{
///
/// Number of times the following operations have been performed since DrawDibTime was last called:
///
/// -
/// Draw a bitmap on the screen.
///
/// -
/// Decompress a bitmap.
///
/// -
/// Dither a bitmap.
///
/// -
/// Stretch a bitmap.
///
/// -
/// Transfer bitmap data by using the BitBlt function.
///
/// -
/// Transfer bitmap data by using the SetDIBits function.
///
///
///
public int timeCount;
/// Time to draw bitmaps.
public int timeDraw;
/// Time to decompress bitmaps.
public int timeDecompress;
/// Time to dither bitmaps.
public int timeDither;
/// Time to stretch bitmaps.
public int timeStretch;
/// Time to transfer bitmaps by using the BitBlt function.
public int timeBlt;
/// Time to transfer bitmaps by using the SetDIBits function.
public int timeSetDIBits;
}
/// Provides a handle to a DrawDib DC.
[StructLayout(LayoutKind.Sequential)]
public struct HDRAWDIB : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HDRAWDIB(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HDRAWDIB NULL => new(IntPtr.Zero);
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HDRAWDIB h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HDRAWDIB(IntPtr h) => new(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HDRAWDIB h1, HDRAWDIB h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HDRAWDIB h1, HDRAWDIB h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HDRAWDIB h && handle == h.handle;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
/// Provides a handle to an image decompressor.
[StructLayout(LayoutKind.Sequential)]
public struct HIC : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HIC(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HIC NULL => new(IntPtr.Zero);
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HIC h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HIC(IntPtr h) => new(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HIC h1, HIC h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HIC h1, HIC h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HIC h && handle == h.handle;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
/// The ICCOMPRESS structure contains compression parameters used with the ICM_COMPRESS message.
///
/// Drivers that perform temporal compression use data from the previous frame (found in the lpbiPrev and lpPrev
/// members) to prune redundant data from the current frame.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-iccompress typedef struct { DWORD dwFlags; LPBITMAPINFOHEADER
// lpbiOutput; LPVOID lpOutput; LPBITMAPINFOHEADER lpbiInput; LPVOID lpInput; LPDWORD lpckid; LPDWORD lpdwFlags; LONG lFrameNum;
// DWORD dwFrameSize; DWORD dwQuality; LPBITMAPINFOHEADER lpbiPrev; LPVOID lpPrev; } ICCOMPRESS;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_2")]
[StructLayout(LayoutKind.Sequential)]
public struct ICCOMPRESS
{
///
/// Flags used for compression. The following value is defined:
///
///
/// Name
/// Description
///
/// -
/// ICCOMPRESS_KEYFRAME
/// Input data should be treated as a key frame.
///
///
///
public ICCOMPRESSF dwFlags;
///
/// Pointer to a BITMAPINFOHEADER structure containing the output (compressed) format. The biSizeImage member must
/// contain the size of the compressed data.
///
public IntPtr lpbiOutput;
/// Pointer to the buffer where the driver should write the compressed data.
public IntPtr lpOutput;
/// Pointer to a BITMAPINFOHEADER structure containing the input (uncompressed) format.
public IntPtr lpbiInput;
/// Pointer to the buffer containing input data.
public IntPtr lpInput;
///
/// Address to contain the chunk identifier for data in the AVI file. If the value of this member is not NULL, the driver
/// should specify a two-character code for the chunk identifier corresponding to the chunk identifier used in the AVI file.
///
public uint lpckid;
///
/// Address to contain flags for the AVI index. If the returned frame is a key frame, the driver should set the
/// AVIIF_KEYFRAME flag.
///
public uint lpdwFlags;
/// Number of the frame to compress.
public int lFrameNum;
///
/// Desired maximum size, in bytes, for compressing this frame. The size value is used for compression methods that can make
/// tradeoffs between compressed image size and image quality. Specify zero for this member to use the default setting.
///
public uint dwFrameSize;
/// Quality setting.
public uint dwQuality;
///
/// Pointer to a BITMAPINFOHEADER structure containing the format of the previous frame, which is typically the same as the
/// input format.
///
public IntPtr lpbiPrev;
/// Pointer to the buffer containing input data of the previous frame.
public IntPtr lpPrev;
}
/// The ICCOMPRESSFRAMES structure contains compression parameters used with the ICM_COMPRESS_FRAMES_INFO message.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-iccompressframes typedef struct { DWORD dwFlags; LPBITMAPINFOHEADER
// lpbiOutput; LPARAM lOutput; LPBITMAPINFOHEADER lpbiInput; LPARAM lInput; LONG lStartFrame; LONG lFrameCount; LONG lQuality; LONG
// lDataRate; LONG lKeyRate; DWORD dwRate; DWORD dwScale; DWORD dwOverheadPerFrame; DWORD dwReserved2; LONG( )(LPARAM lInput,LONG
// lFrame,LPVOID lpBits,LONG len) *GetData; LONG( )(LPARAM lOutput,LONG lFrame,LPVOID lpBits,LONG len) *PutData; } ICCOMPRESSFRAMES;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_3")]
[StructLayout(LayoutKind.Sequential)]
public struct ICCOMPRESSFRAMES
{
///
/// Applicable flags. The following value is defined: ICCOMPRESSFRAMES_PADDING. If this value is used, padding is used
/// with the frame.
///
public ICCOMPRESSFRAMESF dwFlags;
/// Pointer to a BITMAPINFOHEADER structure containing the output format.
public IntPtr lpbiOutput;
/// Reserved; do not use.
public IntPtr lOutput;
/// Pointer to a BITMAPINFOHEADER structure containing the input format.
public IntPtr lpbiInput;
/// Reserved; do not use.
public IntPtr lInput;
/// Number of the first frame to compress.
public int lStartFrame;
/// Number of frames to compress.
public int lFrameCount;
/// Quality setting.
public int lQuality;
/// Maximum data rate, in bytes per second.
public int lDataRate;
/// Maximum number of frames between consecutive key frames.
public int lKeyRate;
///
/// Compression rate in an integer format. To obtain the rate in frames per second, divide this value by the value in dwScale.
///
public uint dwRate;
/// Value used to scale dwRate to frames per second.
public uint dwScale;
/// Reserved; do not use.
public uint dwOverheadPerFrame;
/// Reserved; do not use.
public uint dwReserved2;
}
/// The ICDECOMPRESS structure contains decompression parameters used with the ICM_DECOMPRESS message.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icdecompress typedef struct { DWORD dwFlags; LPBITMAPINFOHEADER
// lpbiInput; LPVOID lpInput; LPBITMAPINFOHEADER lpbiOutput; LPVOID lpOutput; DWORD ckid; } ICDECOMPRESS;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_5")]
[StructLayout(LayoutKind.Sequential)]
public struct ICDECOMPRESS
{
///
/// Applicable flags. The following values are defined:
///
///
/// Name
/// Description
///
/// -
/// ICDECOMPRESS_HURRYUP
///
/// Tries to decompress at a faster rate. When an application uses this flag, the driver should buffer the decompressed data but
/// not draw the image.
///
///
/// -
/// ICDECOMPRESS_NOTKEYFRAME
/// Current frame is not a key frame.
///
/// -
/// ICDECOMPRESS_NULLFRAME
/// Current frame does not contain data and the decompressed image should be left the same.
///
/// -
/// ICDECOMPRESS_PREROLL
/// Current frame precedes the point in the movie where playback starts and, therefore, will not be drawn.
///
/// -
/// ICDECOMPRESS_UPDATE
/// Screen is being updated or refreshed.
///
///
///
public ICDECOMPRESSF dwFlags;
/// Pointer to a BITMAPINFOHEADER structure containing the input format.
public IntPtr lpbiInput;
/// Pointer to a buffer containing the input data.
public IntPtr lpInput;
/// Pointer to a BITMAPINFOHEADER structure containing the output format.
public IntPtr lpbiOutput;
/// Pointer to a buffer where the driver should write the decompressed image.
public IntPtr lpOutput;
/// Chunk identifier from the AVI file.
public uint ckid;
}
/// The ICDECOMPRESSEX structure contains decompression parameters used with the ICM_DECOMPRESSEX message
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icdecompressex typedef struct { DWORD dwFlags; LPBITMAPINFOHEADER
// lpbiSrc; LPVOID lpSrc; LPBITMAPINFOHEADER lpbiDst; LPVOID lpDst; int xDst; int yDst; int dxDst; int dyDst; int xSrc; int ySrc;
// int dxSrc; int dySrc; } ICDECOMPRESSEX;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_6")]
[StructLayout(LayoutKind.Sequential)]
public struct ICDECOMPRESSEX
{
///
/// Applicable flags. The following values are defined:
///
///
/// Name
/// Description
///
/// -
/// ICDECOMPRESS_HURRYUP
///
/// Tries to decompress at a faster rate. When an application uses this flag, the driver should buffer the decompressed data but
/// not draw the image.
///
///
/// -
/// ICDECOMPRESS_NOTKEYFRAME
/// Current frame is not a key frame.
///
/// -
/// ICDECOMPRESS_NULLFRAME
/// Current frame does not contain data and the decompressed image should be left the same.
///
/// -
/// ICDECOMPRESS_PREROLL
/// Current frame precedes the point in the movie where playback starts and, therefore, will not be drawn.
///
/// -
/// ICDECOMPRESS_UPDATE
/// Screen is being updated or refreshed.
///
///
///
public ICDECOMPRESSF dwFlags;
/// Pointer to a BITMAPINFOHEADER structure containing the input format.
public IntPtr lpbiSrc;
/// Pointer to a buffer containing the input data.
public IntPtr lpSrc;
/// Pointer to a BITMAPINFOHEADER structure containing the output format.
public IntPtr lpbiDst;
/// Pointer to a buffer where the driver should write the decompressed image.
public IntPtr lpDst;
/// The x-coordinate of the destination rectangle within the DIB specified by lpbiDst.
public int xDst;
/// The y-coordinate of the destination rectangle within the DIB specified by lpbiDst.
public int yDst;
/// Width of the destination rectangle.
public int dxDst;
/// Height of the destination rectangle.
public int dyDst;
/// The x-coordinate of the source rectangle within the DIB specified by lpbiSrc.
public int xSrc;
/// The y-coordinate of the source rectangle within the DIB specified by lpbiSrc.
public int ySrc;
/// Width of the source rectangle.
public int dxSrc;
/// Height of the source rectangle.
public int dySrc;
}
///
/// The ICDRAW structure contains parameters for drawing video data to the screen. This structure is used with the ICM_DRAW message.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icdraw typedef struct { DWORD dwFlags; LPVOID lpFormat; LPVOID
// lpData; DWORD cbData; LONG lTime; } ICDRAW;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_8")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ICDRAW
{
///
/// Flags from the AVI file index. The following values are defined:
///
///
/// Name
/// Description
///
/// -
/// ICDRAW_HURRYUP
/// Data is buffered and not drawn to the screen. Use this flag for fastest decompression.
///
/// -
/// ICDRAW_NOTKEYFRAME
/// Current frame is not a key frame.
///
/// -
/// ICDRAW_NULLFRAME
/// Current frame does not contain any data, and the previous frame should be redrawn.
///
/// -
/// ICDRAW_PREROLL
///
/// Current frame of video occurs before playback should start. For example, if playback will begin on frame 10, and frame 0 is
/// the nearest previous key frame, frames 0 through 9 are sent to the driver with this flag set. The driver needs this data to
/// display frame 10 properly.
///
///
/// -
/// ICDRAW_UPDATE
/// Updates the screen based on data previously received. In this case, lpData should be ignored.
///
///
///
public ICDRAWF dwFlags;
/// Pointer to a structure containing the data format. For video streams, this is a BITMAPINFOHEADER structure.
public IntPtr lpFormat;
/// Pointer to the data to render.
public IntPtr lpData;
/// Number of data bytes to render.
public uint cbData;
/// Time, in samples, when this data should be drawn. For video data this is normally a frame number.
public int lTime;
}
/// The ICDRAWBEGIN structure contains decompression parameters used with the ICM_DRAW_BEGIN message.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icdrawbegin typedef struct { DWORD dwFlags; HPALETTE hpal; HWND
// hwnd; HDC hdc; int xDst; int yDst; int dxDst; int dyDst; LPBITMAPINFOHEADER lpbi; int xSrc; int ySrc; int dxSrc; int dySrc; DWORD
// dwRate; DWORD dwScale; } ICDRAWBEGIN;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_7")]
[StructLayout(LayoutKind.Sequential)]
public struct ICDRAWBEGIN
{
///
/// Applicable flags. The following values are defined:
///
///
/// Name
/// Description
///
/// -
/// ICDRAW_ANIMATE
/// Application can animate the palette.
///
/// -
/// ICDRAW_BUFFER
/// Buffers this data off-screen; it will need to be updated.
///
/// -
/// ICDRAW_CONTINUE
/// Drawing is a continuation of the previous frame.
///
/// -
/// ICDRAW_FULLSCREEN
/// Draws the decompressed data on the full screen.
///
/// -
/// ICDRAW_HDC
/// Draws the decompressed data to a window or a DC.
///
/// -
/// ICDRAW_MEMORYDC
/// DC is off-screen.
///
/// -
/// ICDRAW_QUERY
/// Determines if the decompressor can handle the decompression. The driver does not actually decompress the data.
///
/// -
/// ICDRAW_RENDER
/// Renders but does not draw the data.
///
/// -
/// ICDRAW_UPDATING
/// Current frame is being updated rather than played.
///
///
///
public ICDRAWF dwFlags;
/// Handle to the palette used for drawing.
public HPALETTE hpal;
/// Handle to the window used for drawing.
public HWND hwnd;
/// Handle to the DC used for drawing. Specify NULL to use a DC associated with the specified window.
public HDC hdc;
/// The x-coordinate of the destination rectangle.
public int xDst;
/// The y-coordinate of the destination rectangle.
public int yDst;
/// Width of the destination rectangle.
public int dxDst;
/// Height of the destination rectangle.
public int dyDst;
/// Pointer to a BITMAPINFOHEADER structure containing the input format.
public IntPtr lpbi;
/// The x-coordinate of the source rectangle.
public int xSrc;
/// The y-coordinate of the source rectangle.
public int ySrc;
/// Width of the source rectangle.
public int dxSrc;
/// Height of the source rectangle.
public int dySrc;
///
/// Decompression rate in an integer format. To obtain the rate in frames per second, divide this value by the value in dwScale.
///
public uint dwRate;
/// Value used to scale dwRate to frames per second.
public uint dwScale;
}
///
/// The ICDRAWSUGGEST structure contains compression parameters used with the ICM_DRAW_SUGGESTFORMAT message to suggest an
/// appropriate input format.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icdrawsuggest typedef struct { LPBITMAPINFOHEADER lpbiIn;
// LPBITMAPINFOHEADER lpbiSuggest; int dxSrc; int dySrc; int dxDst; int dyDst; HIC hicDecompressor; } ICDRAWSUGGEST;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_9")]
[StructLayout(LayoutKind.Sequential)]
public struct ICDRAWSUGGEST
{
/// Pointer to the structure containing the compressed input format.
public IntPtr lpbiIn;
/// Pointer to a buffer to return a compatible input format for the renderer.
public IntPtr lpbiSuggest;
/// Width of the source rectangle.
public int dxSrc;
/// Height of the source rectangle.
public int dySrc;
/// Width of the destination rectangle.
public int dxDst;
/// Height of the destination rectangle.
public int dyDst;
/// Handle to a decompressor that supports the format of data described in lpbiIn.
public HIC hicDecompressor;
}
///
/// The ICINFO structure contains compression parameters supplied by a video compression driver. The driver fills or updates
/// the structure when it receives the ICM_GETINFO message.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icinfo typedef struct { DWORD dwSize; DWORD fccType; DWORD
// fccHandler; DWORD dwFlags; DWORD dwVersion; DWORD dwVersionICM; WCHAR szName[16]; WCHAR szDescription[128]; WCHAR szDriver[128];
// } ICINFO;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_1")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ICINFO
{
/// Size, in bytes, of the ICINFO structure.
public uint dwSize;
///
/// Four-character code indicating the type of stream being compressed or decompressed. Specify "VIDC" for video streams.
///
public uint fccType;
/// A four-character code identifying a specific compressor.
public uint fccHandler;
///
/// Applicable flags. Zero or more of the following flags can be set:
///
///
/// Name
/// Description
///
/// -
/// VIDCF_COMPRESSFRAMES
///
/// Driver is requesting to compress all frames. For information about compressing all frames, see the ICM_COMPRESS_FRAMES_INFO message.
///
///
/// -
/// VIDCF_CRUNCH
/// Driver supports compressing to a frame size.
///
/// -
/// VIDCF_DRAW
/// Driver supports drawing.
///
/// -
/// VIDCF_FASTTEMPORALC
///
/// Driver can perform temporal compression and maintains its own copy of the current frame. When compressing a stream of frame
/// data, the driver doesn't need image data from the previous frame.
///
///
/// -
/// VIDCF_FASTTEMPORALD
///
/// Driver can perform temporal decompression and maintains its own copy of the current frame. When decompressing a stream of
/// frame data, the driver doesn't need image data from the previous frame.
///
///
/// -
/// VIDCF_QUALITY
/// Driver supports quality values.
///
/// -
/// VIDCF_TEMPORAL
/// Driver supports inter-frame compression.
///
///
///
public VIDCF dwFlags;
/// Version number of the driver.
public uint dwVersion;
/// Version of VCM supported by the driver. This member should be set to ICVERSION.
public uint dwVersionICM;
///
/// Short version of the compressor name. The name in the null-terminated string should be suitable for use in list boxes.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string szName;
/// Long version of the compressor name.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szDescription;
/// Name of the module containing VCM compression driver. Normally, a driver does not need to fill this out.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szDriver;
}
///
/// The ICOPEN structure contains information about the data stream being compressed or decompressed, the version number of
/// the driver, and how the driver is used.
///
///
/// This structure is passed to video capture drivers when they are opened. This allows a single installable driver to function as
/// either an installable compressor or a video capture device. By examining the fccType member of the ICOPEN
/// structure, the driver can determine its function. For example, a fccType value of "VIDC" indicates that it is opened as
/// an installable video compressor.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icopen typedef struct { DWORD dwSize; DWORD fccType; DWORD
// fccHandler; DWORD dwVersion; DWORD dwFlags; LRESULT dwError; LPVOID pV1Reserved; LPVOID pV2Reserved; DWORD dnDevNode; } ICOPEN;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_0")]
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct ICOPEN
{
/// Size, in bytes, of the structure.
public uint dwSize;
///
/// Four-character code indicating the type of stream being compressed or decompressed. Specify "VIDC" for video streams.
///
public uint fccType;
/// Four-character code identifying a specific compressor.
public uint fccHandler;
/// Version of the installable driver interface used to open the driver.
public uint dwVersion;
///
/// Applicable flags indicating why the driver is opened. The following values are defined:
///
///
/// Name
/// Description
///
/// -
/// ICMODE_COMPRESS
/// Driver is opened to compress data.
///
/// -
/// ICMODE_DECOMPRESS
/// Driver is opened to decompress data.
///
/// -
/// ICMODE_DRAW
/// Device driver is opened to decompress data directly to hardware.
///
/// -
/// ICMODE_QUERY
/// Driver is opened for informational purposes, rather than for compression.
///
///
///
public ICMODE dwFlags;
private readonly ushort dwFlagsPadding;
///
public IntPtr dwError;
/// Reserved; do not use.
public IntPtr pV1Reserved;
/// Reserved; do not use.
public IntPtr pV2Reserved;
/// Device node for plug and play devices.
public uint dnDevNode;
}
/// The ICSETSTATUSPROC structure contains status information used with the ICM_SET_STATUS_PROC message.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icsetstatusproc typedef struct { DWORD dwFlags; LPARAM lParam;
// LONG( )(LPARAM lParam,UINT message,LONG l) *Status; } ICSETSTATUSPROC;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_4")]
[StructLayout(LayoutKind.Sequential)]
public struct ICSETSTATUSPROC
{
/// Reserved; set to zero.
public uint dwFlags;
/// Parameter that contains a constant to pass to the status procedure.
public IntPtr lParam;
///
[MarshalAs(UnmanagedType.FunctionPtr)]
public Func Status;
}
/// Provides a for that is disposed using .
public class SafeHDRAWDIB : SafeHANDLE
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHDRAWDIB(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeHDRAWDIB() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HDRAWDIB(SafeHDRAWDIB h) => h.handle;
///
protected override bool InternalReleaseHandle() => DrawDibClose(handle);
}
/// Provides a for that is disposed using .
public class SafeHIC : SafeHANDLE
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHIC(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeHIC() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HIC(SafeHIC h) => h.handle;
///
protected override bool InternalReleaseHandle() => ICClose(handle) == IntPtr.Zero;
}
}
}