Table of Contents

Method LoadFileAsBitmap

Namespace
PaintDotNet.FileTypes
Assembly
PaintDotNet.FileTypes.dll

LoadFileAsBitmap(IFileTypesService1, string)

Loads the image from the given file path. If necessary, the image is converted to an appropriate BGRA/RGBA format and color space.

public static IFileTypeBitmapSource LoadFileAsBitmap(this IFileTypesService1 service, string filePath)

Parameters

service IFileTypesService1

The service to use for finding and creating IFileType instances.

filePath string

The path of the file to load from.

Returns

IFileTypeBitmapSource

The bitmap source. Use the Lock() to access the pixel data directly, or the ToBitmap() extension method to convert it to an IBitmap.

Remarks

This method will only return bitmaps in a BGRA or RGBA pixel format at 32-, 64-, or 128-bits per pixel.

Exceptions

UnsupportedPixelFormatException

LoadFileAsBitmap(IFileTypesService1, string, in PixelFormat, IColorContext?)

Loads the image from the given file path, then converts it to the given PixelFormat while optionally using a specific IColorContext for the conversion.

public static IFileTypeBitmapSource LoadFileAsBitmap(this IFileTypesService1 service, string filePath, in PixelFormat targetPixelFormat, IColorContext? targetColorContext = null)

Parameters

service IFileTypesService1

The service to use for finding and creating IFileType instances.

filePath string

The path of the file to load from.

targetPixelFormat PixelFormat

The target pixel format.

targetColorContext IColorContext

The target color context. If null then the default color context for targetPixelFormat will be used (usually sRGB).

Returns

IFileTypeBitmapSource

The bitmap source. Use the Lock() to access the pixel data directly, or the ToBitmap() extension method to convert it to an IBitmap.

Remarks

If you are using the bitmap to render to another bitmap, then in general you should specify the color context and pixel format that matches that bitmap. This information is available for both Effect and FileType plugins.

LoadFileAsBitmap<TPixel>(IFileTypesService1, string, IColorContext?)

Loads the image from the given file path, then converts it to the given PixelFormat while optionally using a specific IColorContext for the conversion.

public static IFileTypeBitmapSource<TPixel> LoadFileAsBitmap<TPixel>(this IFileTypesService1 service, string filePath, IColorContext? targetColorContext = null) where TPixel : unmanaged, INaturalPixelInfo

Parameters

service IFileTypesService1

The service to use for finding and creating IFileType instances.

filePath string

The path of the file to load from.

targetColorContext IColorContext

The target color context. If null then the default color context for TPixel will be used (usually sRGB).

Returns

IFileTypeBitmapSource<TPixel>

The bitmap source. Use the ToBitmap() extension method to convert to an IBitmap.

Type Parameters

TPixel

The color struct for the pixel format to use, e.g. ColorBgra32.