Gets the friendly name for any of the WICLead-defined enumerations.
HRESULT GetDitherTypeFriendlyName(WICLeadDitherType nDitherType, UINT cchFriendlyName, WCHAR *pwzFriendlyName, UINT *pcchActual );
- nDitherType
- [in] A value that specifies one of the WICLeadDitherType constants.
- cchFriendlyName
- [in] [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.
Returns S_OK if successful, or an error value otherwise.
Use this method to get a user-readable string representation of any of the WICLeadDitherType constants Call GetDitherTypeFriendlyName once to get the length of the friendly name. Allocate the appropriately sized array. Then call GetDitherTypeFriendlyName again, passing the allocated array as an argument. The example illustrates this technique.
Note that GetLeadEnumFriendlyName can also be used to obtain a readable string from any of the LEAD WIC Enumerations that is identical to the constant name.
// This example creates a LEAD Bitmap Tiff encoder, and then gets and displays all the dithering types. // Refer to the Example_Requirements for help in running this sample. HRESULT IWICLeadBitmapEncoder_GetDitherType_Example(HWND hWnd) { HRESULT hr = S_OK; IWICImagingFactory *piImagingFactory = NULL; IWICBitmapEncoder *piBitmapEncoder = NULL; IWICLeadBitmapEncoder *piLeadBitmapEncoder = NULL; UINT uDitherTypes = 0; WICLeadDitherType *pDitherTypes = NULL; CString csExampleName = L"IWICLeadBitmapEncoder_GetDitherType_Example"; 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))); // Choose a BitsPerPixel that requires dithering (less than 24) // Call GetDitherTypes twice. First to get the required size of the array, then to fill the array IFS(piLeadBitmapEncoder->GetDitherTypes(GUID_WICPixelFormat8bppIndexed, 0, NULL, &uDitherTypes)); if (SUCCEEDED(hr)) { pDitherTypes = new WICLeadDitherType[uDitherTypes]; if (pDitherTypes) { IFS(piLeadBitmapEncoder->GetDitherTypes(GUID_WICPixelFormat8bppIndexed, uDitherTypes, pDitherTypes, &uDitherTypes)); } } // Get and display the WICLeadDitherType friendly name if (SUCCEEDED(hr)) { UINT uActual = 0; WCHAR *pwzFriendlyName = NULL; for (UINT i = 0; i < uDitherTypes; i++) { // Call once to get length of friendly name IFS(piLeadBitmapEncoder->GetDitherTypeFriendlyName(pDitherTypes[i], uActual, NULL, &uActual)); if (SUCCEEDED(hr)) { pwzFriendlyName = new WCHAR[uActual]; // Call again to fill the friendly name buffer IFS(piLeadBitmapEncoder->GetDitherTypeFriendlyName(pDitherTypes[i], uActual, pwzFriendlyName, &uActual)); csMsg = csMsg + CString(pwzFriendlyName) + "\n"; DELETE_POINTER(pwzFriendlyName); } } } RELEASE_INTERFACE(piLeadBitmapEncoder); RELEASE_INTERFACE(piBitmapEncoder); RELEASE_INTERFACE(piImagingFactory); DELETE_POINTER(pDitherTypes); MessageBox(hWnd, csMsg, csExampleName, MB_OK); return hr; }
LEAD WIC-Enabled Codecs Overview
Registering a LEAD WIC-Enabled Codec
WICLeadEnumName
GetLeadEnumFriendlyName