BitmapEncoder.IsThumbnailGenerated Property

Definition

Indicates whether or not a new thumbnail is automatically generated.

public:
 property bool IsThumbnailGenerated { bool get(); void set(bool value); };
bool IsThumbnailGenerated();

void IsThumbnailGenerated(bool value);
public bool IsThumbnailGenerated { get; set; }
var boolean = bitmapEncoder.isThumbnailGenerated;
bitmapEncoder.isThumbnailGenerated = boolean;
Public Property IsThumbnailGenerated As Boolean

Property Value

Boolean

A value that indicates whether or not the bitmap encoder will automatically generate a new thumbnail. The default value is False.

Remarks

When this value is true, the bitmap encoder will generate a new thumbnail by downscaling the frame bitmap. The thumbnail size is determined by the GeneratedThumbnailWidth and GeneratedThumbnailHeight properties. When this value is false, no thumbnail is written to the file.

If the BitmapEncoder was created using the CreateForTranscodingAsync method and IsThumbnailGenerated is false, the bitmap encoder will leave any existing thumbnail data untouched. In this case, if the bitmap was modified before encoding, it's possible for the output file to have a thumbnail that does not match the new contents of the image.

Only JPEG, TIFF and JPEG-XR image types support encoding thumbnails. If the image format being encoded does not support thumbnails and you set IsThumbnailGenerated to true, then the call to FlushAsync will fail with HRESULT WINCODEC_ERR_UNSUPPORTEDOPERATION. You should catch this exception and retry encoding with thumbnail generation disabled. If your app only encodes image formats that support thumbnails, you can skip this step.

try
 {
     await encoder.FlushAsync();
 }
 catch (Exception err)
 {
     switch (err.HResult)
     {
         case unchecked ((int) 0x88982F81): //WINCODEC_ERR_UNSUPPORTEDOPERATION
             // If the encoder does not support writing a thumbnail, then try again
             // but disable thumbnail generation.
             encoder.IsThumbnailGenerated = false;
             break;
         default:
             throw err;
     }
 }

 if (encoder.IsThumbnailGenerated == false)
 {
     await encoder.FlushAsync();
 }

Applies to