IWICLeadBitmapEncoder::GetDitherTypeFriendlyName Method

Show in webframe

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

Syntax

Syntax


            HRESULT GetDitherTypeFriendlyName(WICLeadDitherType nDitherType,
                UINT cchFriendlyName,
                WCHAR *pwzFriendlyName,
                UINT *pcchActual
            );

Parameters

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.

Return Values

Returns S_OK if successful, or an error value otherwise.

Remarks

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.

Example


            // 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**&gt;(&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;
            }
            

References

LEAD WIC-Enabled Codecs Overview
Registering a LEAD WIC-Enabled Codec
WICLeadEnumName
GetLeadEnumFriendlyName

Parameters

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.

Return Values

Returns S_OK if successful, or an error value otherwise.

Remarks

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.

Example

Syntax

Parameters

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.

Return Values

Returns S_OK if successful, or an error value otherwise.

Remarks

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.

Example


            // 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**&gt;(&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;
            }
            

References

LEAD WIC-Enabled Codecs Overview
Registering a LEAD WIC-Enabled Codec
WICLeadEnumName
GetLeadEnumFriendlyName

Syntax


            HRESULT GetDitherTypeFriendlyName(WICLeadDitherType nDitherType,
                UINT cchFriendlyName,
                WCHAR *pwzFriendlyName,
                UINT *pcchActual
            );

Parameters

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.

Return Values

Returns S_OK if successful, or an error value otherwise.

Remarks

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.

Example


            // 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**&gt;(&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;
            }
            

References

LEAD WIC-Enabled Codecs Overview
Registering a LEAD WIC-Enabled Codec
WICLeadEnumName
GetLeadEnumFriendlyName

References

LEAD WIC-Enabled Codecs Overview
Registering a LEAD WIC-Enabled Codec
WICLeadEnumName
GetLeadEnumFriendlyName

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.