Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.8.10
IWICLeadBitmapEncoder::GetLeadEnumFriendlyName Method
See Also

Gets the friendly name for any of the WICLead-defined enumerations.

Syntax

 

HRESULT GetLeadEnumFriendlyName(      
    WICLeadEnumName nLeadEnumName,     UINT uLeadEnumValue,     UINT cchFriendlyName,     WCHAR *pwzFriendlyName,     UINT *pcchActual );

Parameters

 
nLeadEnumName
[in] A value that specifies one of the LEAD WIC Enumerations. Choose one of the WICLeadEnumName.
uLeadEnumValue
[in] The enumeration constant for which a friendly name will be returned.
cchFriendlyName
[in] The size of the pwzFriendlyName buffer.
pwzFriendlyName
[in,out] A pointer that receives the friendly name of the component.
pcchActual
[out] A pointer that receives the actual length of the component's friendly name.

Return Values

Returns S_OK if successful, or an error value otherwise.

Remarks

Use this method to get a user-readable string representation for any of the WIC LEAD defined enumerations.  Call GetLeadEnumFriendlyName once to get the length of the friendly name.  Allocate the appropriately sized array.  Then call GetLeadEnumFriendlyName again, passing the allocated array as an argument. The example illustrates this technique.

Note that this is different from the other GetFriendlyName methods in that a string is returned that is identical to the constant name.
Example (for brevity, not all arguments are shown)
Method String Result
GetEnumFriendlyName(WICLeadEnum_WICLeadDitherType, WICLeadDitherFloydStein) "WICLeadDitherFloydStein"
GetDitherTypeFriendlyName(WICLeadDitherFloydStein) "FloydStein"
 

See Also

Example

// 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;
}