Share via


IImageEncoder::SetEncoderParameters

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This method is used to set encoder parameters.

Your application must call this method prior to calling IImageEncoder::GetEncodeSink.

Syntax

HRESULT SetEncoderParameters(
  const EncoderParameters* Param
);

Parameters

  • Param
    [in] A pointer to an EncoderParameters object containing the parameter data that will be set for the encoder.

Return Value

If successful, this method returns S_OK.

This method may return E_NOTIMPL if it fails.

Remarks

If the encoder does not support the combination of the encoding parameters, it ignores the call and returns S_FALSE.

The encoder should define a default set of encoder parameters in case the caller does not call this method, or calls the method with the wrong parameters.

By default, the encoder should save the image in the same color depth if it can support it. If not, the encoder should define the closest color depth for the source.

The following code shows how an application set two 2-parameter values for an encoder.

EncoderParameters* ParamsList;
LONG lCompression = EncoderValueCompressionNone;  // No compression
LONG lColorDepth = 16;                            // 16 bpp
// Allocate enough memory for 2 parameters.
// Note that EncoderParameters automatically has room for one.
ParamsList = CoTaskMemAlloc(sizeof (EncoderParameters) +
                            1 * sizeof(EncoderParameter));
ParamsList->Count = 2;
ParamsList->Parameter[0].Guid           = ENCODER_COMPRESSION;
ParamsList->Parameter[0].NumberOfValues = 1;
ParamsList->Parameter[0].Type           = EncoderParameterValueTypeLong;
ParamsList->Parameter[0].Value          = (void*) &lCompression;
ParamsList->Parameter[1].Guid           = ENCODER_COLORDEPTH;
ParamsList->Parameter[1].NumberOfValues = 1;
ParamsList->Parameter[1].Type           = EncoderParameterValueTypeLong;
ParamsList->Parameter[1].Value          = (void*) &lColorDepth;
SetEncoderParameters(ParamsList);

Requirements

Header imaging.h
Library Imaging.lib
Windows Embedded CE Windows CE 5.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

IImageEncoder