![]() |
|
ImageExtensionsConvertPixelFormat Method | KGy SOFT Drawing Libraries Help |
Converts the image to another one with the desired PixelFormat.
See the Remarks section for details.
See the Remarks section for details.
Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 4.6.0
Syntax
public static Image ConvertPixelFormat( this Image image, PixelFormat newPixelFormat, Color[] palette )
<ExtensionAttribute> Public Shared Function ConvertPixelFormat ( image As Image, newPixelFormat As PixelFormat, palette As Color() ) As Image
public: [ExtensionAttribute] static Image^ ConvertPixelFormat( Image^ image, PixelFormat newPixelFormat, array<Color>^ palette )
[<ExtensionAttribute>] static member ConvertPixelFormat : image : Image * newPixelFormat : PixelFormat * palette : Color[] -> Image
Parameters
- image
- Type: System.DrawingImage
The original image to convert. - newPixelFormat
- Type: System.Drawing.ImagingPixelFormat
The desired new pixel format. If the requested format is an indexed one, built-in strategies are used for the generated palette. - palette
- Type: System.DrawingColor
The required palette for the result image. If , the palette will be taken from source or will be generated on demand. If palette contains transparent color, it might be considered. If it contains too few elements black entries will be added.
Return Value
Type: ImageA new Image instance with the desired pixel format.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type Image. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Remarks
If newPixelFormat is Format8bppIndexed, image has no palette and palette is , a standard palette will be used. Transparency will be preserved.
If newPixelFormat is Format4bppIndexed, image has no palette and palette is , the standard 16 color palette will be used.
If newPixelFormat is Format1bppIndexed, image has no palette and palette is , black and white colors will be used.
If the target pixel format is indexed, palette contains the transparent color (Color.Transparent), and the source has transparency, then the result will have transparency for fully transparent pixels.
See Also