IWICPlanarBitmapFrameEncode::WriteSource method (wincodec.h)
Writes lines from the source planes to the encoded format.
Syntax
HRESULT WriteSource(
[in] IWICBitmapSource **ppPlanes,
UINT cPlanes,
WICRect *prcSource
);
Parameters
[in] ppPlanes
Type: IWICBitmapSource**
Specifies an array of IWICBitmapSource that represent image planes.
cPlanes
Type: UINT
The number of component planes specified by the planes parameter.
prcSource
Type: WICRect*
The source rectangle of pixels to encode from the IWICBitmapSource planes. Null indicates the entire source. The source rect width must match the width set through SetSize. Repeated WriteSource calls can be made as long as the total accumulated source rect height is the same as set through SetSize.
Return value
Type: HRESULT
If the planes and source rectangle do not meet the requirements, this method fails with WINCODEC_ERR_IMAGESIZEOUTOFRANGE.
If the IWICBitmapSource format does not meet the encoder requirements, this method fails with WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT.
Remarks
Successive WriteSource calls are assumed sequentially add scanlines to the output image. IWICBitmapFrameEncode::Initialize, IWICBitmapFrameEncode::SetSize and IWICBitmapFrameEncode::SetPixelFormat must be called before this method or it will fail.
The interleaved pixel format set via IWICBitmapFrameEncode::SetPixelFormat and the codec specific encode parameters determine the supported planar formats.
WIC JPEG Encoder: QueryInterface can be used to obtain this interface from the WIC JPEG IWICBitmapFrameEncode implementation. When using this method to encode Y’CbCr data with the WIC JPEG encoder, chroma subsampling can be configured with encoder options during frame creation. See the Encoding Overview and IWICBitmapEncoder::CreateNewFrame for more details.
Depending upon the configured chroma subsampling, the lineCount parameter has the following restrictions:
Chroma Subsampling | X Coordinate | Y Coordinate | Chroma Width | Chroma Height |
---|---|---|---|---|
4:2:0 | Multiple of 2 | Multiple of 2 | lumaWidth / 2 Rounded up to the nearest integer. | lumaHeight / 2 Rounded up to the nearest integer. |
4:2:2 | Multiple of 2 | Any | lumaWidth / 2 Rounded up to the nearest integer. | Any |
4:4:4 | Any | Any | Any | Any |
4:4:0 | Any | Multiple of 2 | lumaWidth | llumaHeight / 2 Rounded up to the nearest integer. |
The full scanline width must be encoded, and the width of the bitmap sources must match their planar configuration.
Additionally, if a pixel format is set via IWICBitmapFrameEncode::SetPixelFormat, it must be GUID_WICPixelFormat24bppBGR.
The supported pixel formats of the bitmap sources passed into this method are as follows:
Plane Count | Plane 1 | Plane 2 | Plane 3 |
---|---|---|---|
3 | GUID_WICPixelFormat8bppY | GUID_WICPixelFormat8bppCb | GUID_WICPixelFormat8bppCr |
2 | GUID_WICPixelFormat8bppY | GUID_WICPixelFormat16bppCbCr | N/A |
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 8.1 [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2012 R2 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | wincodec.h |
Library | Windowscodecs.lib |
DLL | Windowscodecs.dll |