Skip to content

ImagePersistence Class#

Contains static methods that support saving of images.

Inheritance Hierarchy#

System.Object
  Basler.Pylon.ImagePersistence

Syntax#

C#

public static class ImagePersistence

VB

Public NotInheritable Class ImagePersistence

The ImagePersistence type exposes the following members.

Methods#

NameDescription
Public methodStatic memberLoad Loads an image from disk.
Public methodStatic memberSave(ImageFileFormat, String, IImage) Saves the image to disk. If required, converts the image to a new format and then saves it.
Public methodStatic memberSave(ImageFileFormat, String, IntPtr, Int64, PixelType, Int32, Int32, Int32, ImageOrientation) Saves the image to disk. If required, converts the image to a new format and then saves it.
Public methodStatic memberSave(T)(ImageFileFormat, String, T[], PixelType, Int32, Int32, Int32, ImageOrientation) Saves the image to disk. If required, converts the image to a new format and then saves it.
 

ImagePersistence.Load Method#

Loads an image from disk.

Syntax#

C#

public static void Load(
    string filename,
    ref byte[] buffer,
    ref PixelType pixelType,
    ref int width,
    ref int height,
    ref int paddingX,
    ref ImageOrientation orientation
)

VB

Public Shared Sub Load ( 
    filename As String,
    ByRef buffer As Byte(),
    ByRef pixelType As PixelType,
    ByRef width As Integer,
    ByRef height As Integer,
    ByRef paddingX As Integer,
    ByRef orientation As ImageOrientation
)

Parameters#

 

filename
Type: System.String
Name and path of the image.
buffer
Type: System.Byte[]
The byte array containing the image data on success.
pixelType
Type: Basler.Pylon.PixelType
The pixel type of the image.
width
Type: System.Int32
The number of image pixels in a row.
height
Type: System.Int32
The number of rows of the image.
paddingX
Type: System.Int32
The number of extra data bytes at the end of each row.
orientation
Type: Basler.Pylon.ImageOrientation
The vertical orientation of the image in the image buffer.

Remarks#

On success, the buffer array will contain the raw image data of the image loaded.

Due to automatic conversion during save, saving an image and then loading it again may result in different memory layout of the image data.

Thread Safety: This method is thread-safe.

Error Safety: Throws an exception if loading the image fails.

ImagePersistence.Save Method (ImageFileFormat, String, IImage)#

Saves the image to disk. If required, converts the image to a new format and then saves it.

Syntax#

C#

public static void Save(
    ImageFileFormat imageFileFormat,
    string filename,
    IImage image
)

VB

Public Shared Sub Save ( 
    imageFileFormat As ImageFileFormat,
    filename As String,
    image As IImage
)

Parameters#

 

imageFileFormat
Type: Basler.Pylon.ImageFileFormat
The file format to save the image in.
filename
Type: System.String
Name and path of the image.
image
Type: Basler.Pylon.IImage
The image to save.

Remarks#

If required, the image is automatically converted to a new image and then saved. An image with a bit depth higher than 8 bit is stored with 16 bit bit depth if supported by the image file format. In this case, the pixel data is MSB aligned. If more control over the conversion is required, the PixelDataConverter class can be used to convert the input image before saving it.

Preconditions:
 

  • The pixel type of the image to save must be a supported input format of the PixelDataConverter.
  • The image must be valid.
  Thread Safety: This method is thread-safe.

Error Safety: Throws an exception if saving the image fails.

ImagePersistence.Save Method (ImageFileFormat, String, IntPtr, Int64, PixelType, Int32, Int32, Int32, ImageOrientation)#

Saves the image to disk. If required, converts the image to a new format and then saves it.

Syntax#

C#

public static void Save(
    ImageFileFormat imageFileFormat,
    string filename,
    IntPtr pBuffer,
    long bufferSize,
    PixelType pixelType,
    int width,
    int height,
    int paddingX,
    ImageOrientation orientation
)

VB

Public Shared Sub Save ( 
    imageFileFormat As ImageFileFormat,
    filename As String,
    pBuffer As IntPtr,
    bufferSize As Long,
    pixelType As PixelType,
    width As Integer,
    height As Integer,
    paddingX As Integer,
    orientation As ImageOrientation
)

Parameters#

 

imageFileFormat
Type: Basler.Pylon.ImageFileFormat
The file format to save the image in.
filename
Type: System.String
Name and path of the image.
pBuffer
Type: System.IntPtr
The pointer to the buffer of the image.
bufferSize
Type: System.Int64
The size of the buffer in bytes.
pixelType
Type: Basler.Pylon.PixelType
The pixel type of the image to save.
width
Type: System.Int32
The number of pixels in a row of the image to save.
height
Type: System.Int32
The number of rows of the image to save.
paddingX
Type: System.Int32
The number of extra data bytes at the end of each row.
orientation
Type: Basler.Pylon.ImageOrientation
The vertical orientation of the image in the image buffer.

Remarks#

If required, the image is automatically converted to a new image and then saved. An image with a bit depth higher than 8 bit is stored with 16 bit bit depth if supported by the image file format. In this case, the pixel data is MSB aligned. If more control over the conversion is required, the PixelDataConverter class can be used to convert the input image before saving it.

Preconditions:
 

  • The bufferSize value must be >= 0.
  • The pixel type of the image to save must be a supported input format of the PixelDataConverter.
  • The width value must be >= 0.
  • The height value must be >= 0.
  • The paddingX value must be >= 0.
  Thread Safety: This method is thread-safe.

Error Safety: Throws an exception if saving the image fails.

ImagePersistence.Save(T) Method (ImageFileFormat, String, T[], PixelType, Int32, Int32, Int32, ImageOrientation)#

Saves the image to disk. If required, converts the image to a new format and then saves it.

Syntax#

C#

public static void Save<T>(
    ImageFileFormat imageFileFormat,
    string filename,
    T[] buffer,
    PixelType pixelType,
    int width,
    int height,
    int paddingX,
    ImageOrientation orientation
)

VB

Public Shared Sub Save(Of T) ( 
    imageFileFormat As ImageFileFormat,
    filename As String,
    buffer As T(),
    pixelType As PixelType,
    width As Integer,
    height As Integer,
    paddingX As Integer,
    orientation As ImageOrientation
)

Parameters#

 

imageFileFormat
Type: Basler.Pylon.ImageFileFormat
The file format to save the image in.
filename
Type: System.String
Name and path of the image.
buffer
Type: T[]
The array providing the buffer of the image.
pixelType
Type: Basler.Pylon.PixelType
The pixel type of the image to save.
width
Type: System.Int32
The number of pixels in a row of the image to save.
height
Type: System.Int32
The number of rows of the image to save.
paddingX
Type: System.Int32
The number of extra data bytes at the end of each row.
orientation
Type: Basler.Pylon.ImageOrientation
The vertical orientation of the image in the image buffer.

Type Parameters#

 

T
The array item value type of the destination buffer array.

Remarks#

If required, the image is automatically converted to a new image and then saved. An image with a bit depth higher than 8 bit is stored with 16 bit bit depth if supported by the image file format. In this case, the pixel data is MSB aligned. If more control over the conversion is required, the PixelDataConverter class can be used to convert the input image before saving it.

Preconditions:
 

  • The pixel type of the image to save must be a supported input format of the PixelDataConverter.
  • The width value must be >= 0.
  • The height value must be >= 0.
  • The paddingX value must be >= 0.
  Thread Safety: This method is thread-safe.

Error Safety: Throws an exception if saving the image fails.

ImagePersistence.Save Method#

Overload List#

NameDescription
Public methodStatic memberSave(ImageFileFormat, String, IImage) Saves the image to disk. If required, converts the image to a new format and then saves it.
Public methodStatic memberSave(T)(ImageFileFormat, String, T[], PixelType, Int32, Int32, Int32, ImageOrientation) Saves the image to disk. If required, converts the image to a new format and then saves it.
Public methodStatic memberSave(ImageFileFormat, String, IntPtr, Int64, PixelType, Int32, Int32, Int32, ImageOrientation) Saves the image to disk. If required, converts the image to a new format and then saves it.