Skip to content

Latest commit

 

History

History
58 lines (41 loc) · 2.38 KB

bitmapencoder_isthumbnailgenerated.md

File metadata and controls

58 lines (41 loc) · 2.38 KB
-api-id -api-type
P:Windows.Graphics.Imaging.BitmapEncoder.IsThumbnailGenerated
winrt property

Windows.Graphics.Imaging.BitmapEncoder.IsThumbnailGenerated

-description

Indicates whether or not a new thumbnail is automatically generated.

-property-value

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();
    }

-examples

-see-also