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
serviceIFileTypesService1The service to use for finding and creating IFileType instances.
filePathstringThe 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
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
serviceIFileTypesService1The service to use for finding and creating IFileType instances.
filePathstringThe path of the file to load from.
targetPixelFormatPixelFormatThe target pixel format.
targetColorContextIColorContextThe target color context. If
nullthen the default color context fortargetPixelFormatwill 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
serviceIFileTypesService1The service to use for finding and creating IFileType instances.
filePathstringThe path of the file to load from.
targetColorContextIColorContextThe target color context. If
nullthen the default color context forTPixelwill be used (usually sRGB).
Returns
- IFileTypeBitmapSource<TPixel>
The bitmap source. Use the
ToBitmap()extension method to convert to an IBitmap.
Type Parameters
TPixelThe color struct for the pixel format to use, e.g. ColorBgra32.