BitmapEncoder.IsThumbnailGenerated 屬性

定義

指出是否自動產生新的縮圖。

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

屬性值

Boolean

bool

值,指出點陣圖編碼器是否會自動產生新的縮圖。 預設值是 False。

備註

當此值為 true 時,點陣圖編碼器會藉由縮小框架點陣圖來產生新的縮圖。 縮圖大小取決於 GeneratedThumbnailWidthGeneratedThumbnailHeight 屬性。 當此值為 false 時,不會將縮圖寫入檔案。

如果使用CreateForTranscodingAsync方法建立BitmapEncoder,且IsThumbnailGenerated為 false,則點陣圖編碼器會保留任何現有的縮圖資料未變更。 在此情況下,如果在編碼之前修改點陣圖,輸出檔案可能會有與影像新內容不符的縮圖。

只有 JPEG、TIFF 和 JPEG-XR 影像類型支援編碼縮圖。 如果編碼的影像格式不支援縮圖,而且您將 IsThumbnailGenerated 設定為 true,則 FlushAsync 的呼叫將會失敗,且 HRESULT WINCODEC_ERR_UNSUPPORTEDOPERATION。 您應該攔截此例外狀況,並在停用縮圖產生時重試編碼。 如果您的應用程式只編碼支援縮圖的影像格式,您可以略過此步驟。

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

適用於