// This example displays a printable name of all of the WICLeadSubFormatFlags enumerations
// See the following Example Requirements for help in running this sample
CString GetLeadEnumFriendlyName(IWICLeadBitmapEncoder *piLeadBitmapEncoder, WICLeadEnumName nLeadEnumName, UINT uLeadEnumValue)
{
HRESULT hr = S_OK;
CString csRet;
UINT uActual = 0;
WCHAR *pwzFriendlyName = NULL;
if (piLeadBitmapEncoder)
{
// First, call GetLeadEnumFriendlyName to get the length of the friendly name
IFS(piLeadBitmapEncoder->GetLeadEnumFriendlyName(nLeadEnumName, uLeadEnumValue, 0, NULL, &uActual));
// Next, call GetLeadEnumFriendlyName to get the friendly name
if (SUCCEEDED(hr))
{
pwzFriendlyName = new WCHAR[uActual];
IFS(piLeadBitmapEncoder->GetLeadEnumFriendlyName(nLeadEnumName, uLeadEnumValue, uActual, pwzFriendlyName, &uActual));
if (SUCCEEDED(hr))
csRet = pwzFriendlyName;
}
}
DELETE_POINTER(pwzFriendlyName);
csRet = csRet + L"\n";
return csRet;
}
HRESULT IWICLeadBitmapEncoder_GetLeadEnumFriendlyName(HWND hWnd)
{
HRESULT hr = S_OK;
IWICImagingFactory *piImagingFactory = NULL;
IWICBitmapEncoder *piBitmapEncoder = NULL;
IWICLeadBitmapEncoder *piLeadBitmapEncoder = NULL;
CString csExampleName = L"IWICLeadBitmapEncoder_GetLeadEnumFriendlyName.htm";
CString csMsg = csExampleName + "\n\n";
// Create a LEAD TIFF Bitmap Encoder
IFS(CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*) &piImagingFactory));
IFS(piImagingFactory->CreateEncoder(GUID_ContainerFormatLeadTiff, NULL, &piBitmapEncoder));
// QueryInterface on the encoder to get the IWICLeadBitmapEncoder interface
IFS(piBitmapEncoder->QueryInterface(IID_WICLeadBitmapEncoder, reinterpret_cast<void**>(&piLeadBitmapEncoder)));
if (SUCCEEDED(hr))
{
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagNone);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagProgressive);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagCmpQualityFactorPredefined);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagQualityFactor);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagMultiPage);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagStamp);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagLosslessJpeg);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagJpeg2000Basic);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagJpeg2000Advanced);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagPngQualityFactor);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagAbcQualityFactor);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagEcwQualityFactor);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagJpeg2000AlphaChannel);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagJbig2Support);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagXpsPngQualityFactor);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagXpsJpegQualityFactor);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagJpeg2000QualityFactor);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagHdpQualityFactor);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagInterlaced);
csMsg = csMsg + GetLeadEnumFriendlyName(piLeadBitmapEncoder, WICLeadEnum_WICLeadSubFormatFlags, WICLeadFlagDither);
}
RELEASE_INTERFACE(piLeadBitmapEncoder);
RELEASE_INTERFACE(piBitmapEncoder);
RELEASE_INTERFACE(piImagingFactory);
MessageBox(hWnd, csMsg, csExampleName, MB_OK);
return hr;
}