IWICImagingFactory::CreateBitmapFromMemory method (wincodec.h)

Creates an IWICBitmap from a memory block.


HRESULT CreateBitmapFromMemory(
  [in]  UINT                  uiWidth,
  [in]  UINT                  uiHeight,
  [in]  REFWICPixelFormatGUID pixelFormat,
  [in]  UINT                  cbStride,
  [in]  UINT                  cbBufferSize,
  [in]  BYTE                  *pbBuffer,
  [out] IWICBitmap            **ppIBitmap


[in] uiWidth

Type: UINT

The width of the new bitmap.

[in] uiHeight

Type: UINT

The height of the new bitmap.

[in] pixelFormat

Type: REFWICPixelFormatGUID

The pixel format of the new bitmap. For valid pixel formats, see Native Pixel Formats.

[in] cbStride

Type: UINT

The number of bytes between successive scanlines in pbBuffer.

[in] cbBufferSize

Type: UINT

The size of pbBuffer.

[in] pbBuffer

Type: BYTE*

The buffer used to create the bitmap.

[out] ppIBitmap

Type: IWICBitmap**

A pointer that receives a pointer to the new bitmap.

Return value


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


The size of the IWICBitmap to be created must be smaller than or equal to the size of the image in pbBuffer.

The stride of the destination bitmap will equal the stride of the source data, regardless of the width and height specified.

The pixelFormat parameter defines the pixel format for both the input data and the output bitmap.


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