Bitmap::ConvertFormat 方法 (gdiplusheaders.h)

Bitmap::ConvertFormat方法會將點陣圖轉換成指定的像素格式。 點陣圖中的原始圖元資料會由新的圖元資料取代。

語法

Status ConvertFormat(
  [in] PixelFormat  format,
  [in] DitherType   dithertype,
  [in] PaletteType  palettetype,
  [in] ColorPalette *palette,
  [in] REAL         alphaThresholdPercent
);

參數

[in] format

類型: PixelFormat

指定新像素格式的像素格式常數

[in] dithertype

類型: DitherType

指定 DitherType 列舉演算法的 DitherType 列舉專案。 如果轉換不會減少圖元資料的位深度,請傳遞 DitherTypeNone

[in] palettetype

類型: PaletteType

PaletteType列舉的 元素,指定要用於轉接的標準調色盤。 如果您要轉換成非索引格式,則會忽略此參數。 在此情況下,請傳遞 PaletteType 列舉的任何元素,例如 PaletteTypeCustom

[in] palette

類型: ColorPalette*

ColorPalette結構的指標,指定索引儲存在已轉換點陣圖圖元資料的調色盤。 此調色盤 (稱為實際調色盤) 不需要具有 palettetype 參數所指定的類型。 palettetype參數會指定標準調色盤,可供任何已排序演算法或擷取器演算法使用。 如果實際調色盤的類型不同于 palettetype 參數所指定的類型, 則 Bitmap::ConvertFormat 方法會執行從標準調色盤到實際調色盤的最接近色彩轉換。

[in] alphaThresholdPercent

類型: REAL

範圍 0 到 100 中的實數,指定來源點陣圖中的圖元會對應至已轉換點陣圖中的透明色彩。 值為 0 指定來源圖元都不會對應至透明色彩。 值為 100 指定任何不透明圖元都會對應至透明色彩。 值 t 指定任何小於完全不透明百分比的來源圖元都會對應至透明色彩。 請注意,若要讓 Alpha 臨界值生效,調色盤必須具有透明色彩。 如果調色盤沒有透明色彩,則低於閾值的 Alpha 值圖元會對應到最接近 (0、0、0、0、0) 的色彩,通常是黑色。

傳回值

類型: 狀態

如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其中一個其他元素。

需求

   
最低支援的用戶端 Windows Vista [僅限傳統型應用程式]
最低支援的伺服器 Windows Server 2008 [僅限傳統型應用程式]
目標平台 Windows
標頭 gdiplusheaders.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

點陣圖

Bitmap::InitializePalette