IWICImagingFactory::CreateBitmapFromSourceRect method (wincodec.h)

Creates an IWICBitmap from a specified rectangle of an IWICBitmapSource.

Syntax

HRESULT CreateBitmapFromSourceRect(
  [in]  IWICBitmapSource *pIBitmapSource,
  [in]  UINT             x,
  [in]  UINT             y,
  [in]  UINT             width,
  [in]  UINT             height,
  [out] IWICBitmap       **ppIBitmap
);

Parameters

[in] pIBitmapSource

Type: IWICBitmapSource*

The IWICBitmapSource to create the bitmap from.

[in] x

Type: UINT

The horizontal coordinate of the upper-left corner of the rectangle.

[in] y

Type: UINT

The vertical coordinate of the upper-left corner of the rectangle.

[in] width

Type: UINT

The width of the rectangle and the new bitmap.

[in] height

Type: UINT

The height of the rectangle and the new bitmap.

[out] ppIBitmap

Type: IWICBitmap**

A pointer that receives a pointer to the new bitmap.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Providing a rectangle that is larger than the source will produce undefined results.

This method always creates a separate copy of the source image, similar to the cache option WICBitmapCacheOnLoad.

Requirements

Requirement Value
Minimum supported client Windows XP with SP2, Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header wincodec.h
Library Windowscodecs.lib
DLL Windowscodecs.dll