Class BitmapFrameEncode
[Guid("00000105-a8f2-4877-ba0a-fd2b6645fb94")]
public class BitmapFrameEncode : ComObject
- Inheritance
-
BitmapFrameEncode
Constructors
BitmapFrameEncode(BitmapEncoder)
Initializes a new instance of the BitmapFrameEncode class.
public BitmapFrameEncode(BitmapEncoder encoder)
Parameters
encoder
BitmapEncoderThe encoder.
BitmapFrameEncode(nint)
public BitmapFrameEncode(nint nativePtr)
Parameters
nativePtr
nint
Properties
MetadataQueryWriter
Gets the metadata query writer for the encoder frame.
public MetadataQueryWriter MetadataQueryWriter { get; }
Property Value
Remarks
If you are setting metadata on the frame, you must do this before you use IWICBitmapFrameEncode::WritePixels or IWICBitmapFrameEncode::WriteSource to write any image pixels to the frame
Options
Gets the properties to setup before Initialize().
public BitmapEncoderOptions Options { get; }
Property Value
Palette
Sets the Palette for indexed pixel formats.
public Palette Palette { set; }
Property Value
Remarks
This method doesn't fail if called on a frame whose pixel format is set to a non-indexed pixel format. If the target pixel format is a non-indexed format, the palette will be ignored.
If you already called IWICBitmapEncoder::SetPalette to set a global palette, this method overrides that palette for the current frame.
The palette must be specified before your first call to WritePixels/WriteSource. Doing so will cause WriteSource to use the specified palette when converting the source image to the encoder pixel format. If no palette is specified, a palette will be generated on the first call to WriteSource.
Thumbnail
Proxy function for the SetThumbnail method.
public BitmapSource Thumbnail { set; }
Property Value
Methods
Commit()
Commits the frame to the image.
public void Commit()
Remarks
After the frame Commit has been called, you can't use or reinitialize the BitmapFrameEncode object and any objects created from it.
To finalize the image, both the frame Commit and the encoder Commit must be called. However, only call the encoder Commit method after all frames have been committed.
Dispose(bool)
protected override void Dispose(bool disposing)
Parameters
disposing
bool
Initialize()
Initializes this instance.
public void Initialize()
SetColorContexts(ColorContext[])
Sets the ColorContext objects for this frame encoder.
public void SetColorContexts(ColorContext[] colorContextOut)
Parameters
colorContextOut
ColorContext[]The color contexts to set for the encoder.
SetPixelFormat(ref Guid)
Requests that the encoder use the specified pixel format.
public void SetPixelFormat(ref Guid pixelFormatRef)
Parameters
pixelFormatRef
GuidOn input, the requested pixel format Guid. On output, the closest pixel format Guid supported by the encoder; this may be different than the requested format. For a list of pixel format GUIDs, see Native Pixel Formats.
Remarks
The encoder might not support the requested pixel format. If not, SetPixelFormat returns the closest match in the memory block that pPixelFormat points to. If the returned pixel format doesn't match the requested format, you must use an FormatConverter object to convert the pixel data.
SetResolution(double, double)
Sets the physical resolution of the output image.
public void SetResolution(double dpiX, double dpiY)
Parameters
Remarks
Windows Imaging Component (WIC) doesn't perform any special processing as a result of DPI resolution values. For example, data returned from IWICBitmapSource::CopyPixels isn't scaled by the DPI. The app must handle DPI resolution.
SetSize(int, int)
Sets the output image dimensions for the frame.
public void SetSize(int width, int height)
Parameters
WritePixels(int, DataRectangle, int)
Encodes the frame scanlines.
public void WritePixels(int lineCount, DataRectangle buffer, int totalSizeInBytes = 0)
Parameters
lineCount
intThe number of lines to encode.
buffer
DataRectangleA data buffer containing the pixels to copy from.
totalSizeInBytes
intTotal size in bytes of pixels to write. If == 0, size is calculated with lineCount * rowStride.
Remarks
Successive WritePixels calls are assumed to be sequential scanline access in the output image.
WritePixels(int, nint, int, int)
Encodes the frame scanlines.
public void WritePixels(int lineCount, nint buffer, int rowStride, int totalSizeInBytes = 0)
Parameters
lineCount
intThe number of lines to encode.
buffer
nintA data buffer containing the pixels to copy from.
rowStride
intThe stride of one row.
totalSizeInBytes
intTotal size in bytes of pixels to write. If == 0, size is calculated with lineCount * rowStride.
Remarks
Successive WritePixels calls are assumed to be sequential scanline access in the output image.
WritePixels<T>(int, int, T[])
Encodes the frame scanlines.
public void WritePixels<T>(int lineCount, int stride, T[] pixelBuffer) where T : struct
Parameters
lineCount
intThe number of lines to encode.
stride
intThe stride of the image pixels.
pixelBuffer
T[]A reference to the pixel buffer.
Type Parameters
T
Remarks
Successive WritePixels calls are assumed to be sequential scanline access in the output image.
WriteSource(BitmapSource)
Encodes a bitmap source.
public void WriteSource(BitmapSource bitmapSource)
Parameters
bitmapSource
BitmapSourceThe bitmap source to encode.
Remarks
If SetSize is not called prior to calling WriteSource, the size given in prc is used if not null
. Otherwise, the size of the BitmapSource given in pIBitmapSource is used.
If SetPixelFormat is not called prior to calling WriteSource, the pixel format of the BitmapSource given in pIBitmapSource is used.
If SetResolution is not called prior to calling WriteSource, the pixel format of pIBitmapSource is used.
If SetPalette is not called prior to calling WriteSource, the target pixel format is indexed, and the pixel format of pIBitmapSource matches the encoder frame's pixel format, then the pIBitmapSource pixel format is used.
When encoding a GIF image, if the global palette is set and the frame level palette is not set directly by the user or by a custom independent software vendor (ISV) GIF codec, WriteSource will use the global palette to encode the frame even when pIBitmapSource has a frame level palette.
Windows Vista:The source rect width must match the width set through SetSize. Repeated WriteSource calls can be made as long as the total accumulated source rect height is the same as set through SetSize.
WriteSource(BitmapSource, RawBox)
Encodes a bitmap source.
public void WriteSource(BitmapSource bitmapSourceRef, RawBox rectangleRef)
Parameters
bitmapSourceRef
BitmapSourceThe bitmap source to encode.
rectangleRef
RawBoxThe size rectangle of the bitmap source.
Remarks
If SetSize is not called prior to calling WriteSource, the size given in prc is used if not null
. Otherwise, the size of the BitmapSource given in pIBitmapSource is used.
If SetPixelFormat is not called prior to calling WriteSource, the pixel format of the BitmapSource given in pIBitmapSource is used.
If SetResolution is not called prior to calling WriteSource, the pixel format of pIBitmapSource is used.
If SetPalette is not called prior to calling WriteSource, the target pixel format is indexed, and the pixel format of pIBitmapSource matches the encoder frame's pixel format, then the pIBitmapSource pixel format is used.
When encoding a GIF image, if the global palette is set and the frame level palette is not set directly by the user or by a custom independent software vendor (ISV) GIF codec, WriteSource will use the global palette to encode the frame even when pIBitmapSource has a frame level palette.
Windows Vista:The source rect width must match the width set through SetSize. Repeated WriteSource calls can be made as long as the total accumulated source rect height is the same as set through SetSize.
Operators
explicit operator BitmapFrameEncode(nint)
public static explicit operator BitmapFrameEncode(nint nativePtr)
Parameters
nativePtr
nint