Bitmap.ConvertFormat 方法

定义

重载

名称 说明
ConvertFormat(PixelFormat)

将位图转换为指定的 format。 原始像素数据将替换为新格式。

ConvertFormat(PixelFormat, DitherType, PaletteType, ColorPalette, Single)

使用给定format的位图转换为指定的ditherType位图。 原始像素数据将替换为新格式。

ConvertFormat(PixelFormat)

Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs

将位图转换为指定的 format。 原始像素数据将替换为新格式。

public:
 void ConvertFormat(System::Drawing::Imaging::PixelFormat format);
public void ConvertFormat(System.Drawing.Imaging.PixelFormat format);
member this.ConvertFormat : System.Drawing.Imaging.PixelFormat -> unit
Public Sub ConvertFormat (format As PixelFormat)

参数

format
PixelFormat

新的像素格式。

注解

对于 formatFormat16bppGrayScale 不支持。

适用于

ConvertFormat(PixelFormat, DitherType, PaletteType, ColorPalette, Single)

Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs

使用给定format的位图转换为指定的ditherType位图。 原始像素数据将替换为新格式。

public void ConvertFormat(System.Drawing.Imaging.PixelFormat format, System.Drawing.Imaging.DitherType ditherType, System.Drawing.Imaging.PaletteType paletteType = System.Drawing.Imaging.PaletteType.Custom, System.Drawing.Imaging.ColorPalette? palette = default, float alphaThresholdPercent = 0);
member this.ConvertFormat : System.Drawing.Imaging.PixelFormat * System.Drawing.Imaging.DitherType * System.Drawing.Imaging.PaletteType * System.Drawing.Imaging.ColorPalette * single -> unit
Public Sub ConvertFormat (format As PixelFormat, ditherType As DitherType, Optional paletteType As PaletteType = System.Drawing.Imaging.PaletteType.Custom, Optional palette As ColorPalette = Nothing, Optional alphaThresholdPercent As Single = 0)

参数

format
PixelFormat

新的像素格式。

ditherType
DitherType

dithering 算法。

paletteType
PaletteType

索引像素格式时要使用的调色板类型。

palette
ColorPalette

指向一个 ColorPalette 指针,该调色板的索引存储在转换的位图的像素数据中。 必须为索引像素格式指定此项。

alphaThresholdPercent
Single

范围 0 到 100 中的实数,指定源位图中的哪些像素将映射到转换后的位图中的透明颜色。

注解

对于 formatFormat16bppGrayScale 不支持。

对于 ditherType,转换不会减少像素数据的位深度时传递 None 。 这必须是 SolidErrorDiffusion 如果 paletteTypeCustomFixedBlackAndWhite

paletteType 对于非索引像素格式,将忽略 。

palette (称为实际调色板)不必具有由参数指定的paletteType类型。 该 paletteType 参数指定标准调色板,该调色板可由任何有序算法或螺旋式任一算法使用。 如果实际调色板的类型不同于参数指定的 paletteType 类型,则 ConvertFormat(PixelFormat, DitherType, PaletteType, ColorPalette, Single) 执行从标准调色板到实际调色板的最接近的颜色转换。

对于 alphaThresholdPercent,值为 0 指定没有源像素映射到透明颜色。 值 100 指定任何不透明像素都将映射到透明颜色。 值 t 指定任何小于不透明百分比的源像素将映射到透明颜色。 请注意,要使 alpha 阈值有效,调色板必须具有透明颜色。 如果调色板没有透明颜色,则低于阈值的 alpha 值的像素将映射到最匹配 (0, 0, 0, 0)的颜色,通常是黑色。

paletteType 并且 palette 实际上只有索引像素格式的相关性。 可以传递 ColorPalette 非索引像素格式,但它对转换没有影响,并且只会在转换完成后调用 Palette 设置调色板。

适用于