Skip to content

Pylon::CPylonImageBase#

Module: Image Handling Support

Provides basic functionality for pylon image classes.

#include <pylon/PylonImageBase.h>

Inherits from Pylon::IReusableImage, Pylon::IImage

Inherited by Pylon::CPylonBitmapImage, Pylon::CPylonImage

Public Functions#

Name
virtual void Save(EImageFileFormat imageFileFormat, const String_t & filename, CImagePersistenceOptions * pOptions =NULL) const
Saves the image to disk.
virtual void Load(const String_t & filename)
Loads an image from a disk.
virtual bool CanSaveWithoutConversion(EImageFileFormat imageFileFormat) const
Can be used to check whether the image can be saved without prior conversion.
virtual SPixelData GetPixelData(uint32_t posX, uint32_t posY) const
Retrieves the data of a pixel.
virtual bool IsSupportedPixelType(EPixelType pixelType) const =0
Can be used to check whether the pixel type is supported.
virtual bool IsAdditionalPaddingSupported() const =0
Can be used to check whether the value of PaddingX can be defined by the user.
virtual void Reset(EPixelType pixelType, uint32_t width, uint32_t height, EImageOrientation orientation =ImageOrientation_TopDown) =0
Resets the image properties and provides a buffer to hold the image.
virtual void Reset(EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation =ImageOrientation_TopDown) =0
Resets the image properties including user defined PaddingX and provides a buffer to hold the image.
virtual void Release() =0
Releases the image buffer and resets to an invalid image.
virtual bool IsValid() const =0
Can be used to check whether an image is valid.
virtual EPixelType GetPixelType() const =0
Get the current pixel type.
virtual uint32_t GetWidth() const =0
Get the current number of columns in pixels.
virtual uint32_t GetHeight() const =0
Get the current number of rows.
virtual size_t GetPaddingX() const =0
Get the number of extra data bytes at the end of each row.
virtual EImageOrientation GetOrientation() const =0
Get the vertical orientation of the image in memory.
virtual void * GetBuffer() =0
Get the pointer to the buffer.
virtual const void * GetBuffer() const =0
Get the pointer to the buffer containing the image.
virtual size_t GetImageSize() const =0
Get the size of the image in bytes.
virtual bool IsUnique() const =0
Indicates that the referenced buffer is only referenced by this image.
virtual bool GetStride(size_t & strideBytes) const =0
Get the stride in bytes.

Additional inherited members#

Public Functions inherited from Pylon::IReusableImage

Name
virtual ~IReusableImage() =0
Ensure proper destruction by using a virtual destructor.

Public Functions inherited from Pylon::IImage

Name
virtual ~IImage() =0
Ensure proper destruction by using a virtual destructor.

Public Functions Documentation#

function Save#

virtual void Save(
    EImageFileFormat imageFileFormat,
    const String_t & filename,
    CImagePersistenceOptions * pOptions =NULL
) const

Saves the image to disk.

Parameters:

  • imageFileFormat File format to save the image in.
  • filename Name and path of the image.
  • pOptions Additional options.

Precondition: The pixel type of the image to be saved must be a supported input format of the Pylon::CImageFormatConverter.

Error Safety:

Throws an exception if the saving of the image fails.

Converts the image to a format that can be saved if required.

This is a convenience method that calls CImagePersistence::Save().

If required, the image is automatically converted into a new image and saved afterwards. See CImagePersistence::CanSaveWithoutConversion() for more information. 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 CImageFormatConverter class can be used to convert the input image before saving it.

function Load#

virtual void Load(
    const String_t & filename
)

Loads an image from a disk.

Parameters:

  • filename Name and path of the image.

Precondition: The image object must be able to hold the image format of the loaded image.

Error Safety:

Throws an exception if the image cannot be loaded. The image buffer content is undefined when the loading of the image fails.

This is a convenience method that calls CImagePersistence::Load()

function CanSaveWithoutConversion#

virtual bool CanSaveWithoutConversion(
    EImageFileFormat imageFileFormat
) const

Can be used to check whether the image can be saved without prior conversion.

Parameters:

  • imageFileFormat Target file format for the image to be saved.

Return: Returns true, if the image can be saved without prior conversion.

Error Safety:

Does not throw C++ exceptions.

This is a convenience method that calls CImagePersistence::CanSaveWithoutConversion().

function GetPixelData#

virtual SPixelData GetPixelData(
    uint32_t posX,
    uint32_t posY
) const

Retrieves the data of a pixel.

Parameters:

  • posX Horizontal position of the pixel. The first column has position 0.
  • posY Vertical position of the pixel. The first row has position 0.

Return: Returns the data of a pixel for supported pixel types. For unsupported pixel types pixel data of the SPixelData::PixelDataType_Unknown type is returned.

Note This method is relativly slow. Do not use it for image processing tasks.

Precondition:

  • The image must be valid.
  • The pixel position defined by posX and posY must be located inside the image area.

Error Safety:

Throws an exception, if the preconditions are not met.

Supported pixel types:

  • PixelType_Mono1packed
  • PixelType_Mono2packed
  • PixelType_Mono4packed
  • PixelType_Mono8
  • PixelType_Mono8signed
  • PixelType_Mono10
  • PixelType_Mono10packed
  • PixelType_Mono10p
  • PixelType_Mono12
  • PixelType_Mono12packed
  • PixelType_Mono12p
  • PixelType_Mono16

  • PixelType_BayerGR8

  • PixelType_BayerRG8
  • PixelType_BayerGB8
  • PixelType_BayerBG8
  • PixelType_BayerGR10
  • PixelType_BayerRG10
  • PixelType_BayerGB10
  • PixelType_BayerBG10
  • PixelType_BayerGR12
  • PixelType_BayerRG12
  • PixelType_BayerGB12
  • PixelType_BayerBG12
  • PixelType_BayerGR12Packed
  • PixelType_BayerRG12Packed
  • PixelType_BayerGB12Packed
  • PixelType_BayerBG12Packed
  • PixelType_BayerGR10p
  • PixelType_BayerRG10p
  • PixelType_BayerGB10p
  • PixelType_BayerBG10p
  • PixelType_BayerGR12p
  • PixelType_BayerRG12p
  • PixelType_BayerGB12p
  • PixelType_BayerBG12p
  • PixelType_BayerGR16
  • PixelType_BayerRG16
  • PixelType_BayerGB16
  • PixelType_BayerBG16

  • PixelType_RGB8packed

  • PixelType_BGR8packed
  • PixelType_RGBA8packed
  • PixelType_BGRA8packed
  • PixelType_RGB10packed
  • PixelType_BGR10packed
  • PixelType_RGB12packed
  • PixelType_BGR12packed
  • PixelType_RGB12V1packed
  • PixelType_RGB16packed
  • PixelType_RGB8planar
  • PixelType_RGB10planar
  • PixelType_RGB12planar
  • PixelType_RGB16planar

  • PixelType_YUV422packed

  • PixelType_YUV422_YUYV_Packed

function IsSupportedPixelType#

virtual bool IsSupportedPixelType(
    EPixelType pixelType
) const =0

Can be used to check whether the pixel type is supported.

Return: Returns true if the pixel type is supported.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CPylonBitmapImage::IsSupportedPixelType, Pylon::CPylonImage::IsSupportedPixelType

function IsAdditionalPaddingSupported#

virtual bool IsAdditionalPaddingSupported() const =0

Can be used to check whether the value of PaddingX can be defined by the user.

Return: Returns true if the value of PaddingX can be defined by the user.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CPylonBitmapImage::IsAdditionalPaddingSupported, Pylon::CPylonImage::IsAdditionalPaddingSupported

function Reset#

virtual void Reset(
    EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    EImageOrientation orientation =ImageOrientation_TopDown
) =0

Resets the image properties and provides a buffer to hold the image.

Parameters:

  • pixelType The pixel type of the new image.
  • width The number of pixels in a row in the new image.
  • height The number of rows in the new image.
  • orientation The vertical orientation of the image in the image buffer.

Precondition:

  • The IsSupportedPixelType() method returns true.
  • The width value must be >= 0 and < _I32_MAX.
  • The height value must be >= 0 and < _I32_MAX.

Postcondition:

  • The properties of the image are changed.
  • A buffer large enough to hold the image is provided.

Error Safety:

Throws an exception when the preconditions are not met. Throws an exception when no buffer with the required size can be provided, e.g. by allocation. The original representation is preserved on error.

Reimplemented by: Pylon::CPylonBitmapImage::Reset, Pylon::CPylonImage::Reset

function Reset#

virtual void Reset(
    EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    size_t paddingX,
    EImageOrientation orientation =ImageOrientation_TopDown
) =0

Resets the image properties including user defined PaddingX and provides a buffer to hold the image.

Parameters:

  • pixelType The pixel type of the new image.
  • width The number of pixels in a row in the new image.
  • height The number of rows in the new image.
  • paddingX The number of extra data bytes at the end of each row.
  • orientation The vertical orientation of the image in the image buffer.

Precondition:

Reimplemented by: Pylon::CPylonBitmapImage::Reset, Pylon::CPylonImage::Reset

Extends the Reset(EPixelType, uint32_t, uint32_t) method with user provided padding.

function Release#

virtual void Release() =0

Releases the image buffer and resets to an invalid image.

Postcondition:

  • PixelType = PixelType_Undefined.
  • Width = 0.
  • Height = 0.
  • PaddingX = 0.
  • No buffer is allocated.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CPylonBitmapImage::Release, Pylon::CPylonImage::Release

function IsValid#

virtual bool IsValid() const =0

Can be used to check whether an image is valid.

Return: Returns false if the image is invalid.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::IsValid, Pylon::CPylonBitmapImage::IsValid, Pylon::CPylonImage::IsValid

function GetPixelType#

virtual EPixelType GetPixelType() const =0

Get the current pixel type.

Return: Returns the pixel type or PixelType_Undefined if the image is invalid.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::GetPixelType, Pylon::CPylonBitmapImage::GetPixelType, Pylon::CPylonImage::GetPixelType

function GetWidth#

virtual uint32_t GetWidth() const =0

Get the current number of columns in pixels.

Return: Returns the current number of columns in pixels or 0 if the image is invalid.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::GetWidth, Pylon::CPylonBitmapImage::GetWidth, Pylon::CPylonImage::GetWidth

function GetHeight#

virtual uint32_t GetHeight() const =0

Get the current number of rows.

Return: Returns the current number of rows or 0 if the image is invalid.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::GetHeight, Pylon::CPylonBitmapImage::GetHeight, Pylon::CPylonImage::GetHeight

function GetPaddingX#

virtual size_t GetPaddingX() const =0

Get the number of extra data bytes at the end of each row.

Return: Returns the number of extra data bytes at the end of each row or 0 if the image is invalid.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::GetPaddingX, Pylon::CPylonBitmapImage::GetPaddingX, Pylon::CPylonImage::GetPaddingX

function GetOrientation#

virtual EImageOrientation GetOrientation() const =0

Get the vertical orientation of the image in memory.

Return: Returns the orientation of the image or ImageOrientation_TopDown if the image is invalid.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::GetOrientation, Pylon::CPylonBitmapImage::GetOrientation, Pylon::CPylonImage::GetOrientation

function GetBuffer#

virtual void * GetBuffer() =0

Get the pointer to the buffer.

Return: Returns the pointer to the used buffer or NULL if the image is invalid.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::GetBuffer, Pylon::CPylonBitmapImage::GetBuffer, Pylon::CPylonImage::GetBuffer

function GetBuffer#

virtual const void * GetBuffer() const =0

Get the pointer to the buffer containing the image.

Return: Returns the pointer to the used buffer or NULL if the image is invalid.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::GetBuffer, Pylon::CPylonBitmapImage::GetBuffer, Pylon::CPylonImage::GetBuffer

The buffer is at least as large as the value returned by GetImageSize().

function GetImageSize#

virtual size_t GetImageSize() const =0

Get the size of the image in bytes.

Return: Returns the size of the image in bytes or 0 if the image is invalid.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::GetImageSize, Pylon::CPylonBitmapImage::GetImageSize, Pylon::CPylonImage::GetImageSize

function IsUnique#

virtual bool IsUnique() const =0

Indicates that the referenced buffer is only referenced by this image.

Return: Returns true if the referenced buffer is only referenced by this image. Returns false if the image is invalid.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::IsUnique, Pylon::CPylonBitmapImage::IsUnique, Pylon::CPylonImage::IsUnique

function GetStride#

virtual bool GetStride(
    size_t & strideBytes
) const =0

Get the stride in bytes.

Parameters:

  • strideBytes The stride in byte if it can be computed.

Return: Returns true if the stride can be computed.

Error Safety:

Does not throw C++ exceptions.

Reimplemented by: Pylon::CGrabResultImageT::GetStride, Pylon::CPylonBitmapImage::GetStride, Pylon::CPylonImage::GetStride

The stride in bytes can not be computed for packed image format when the stride is not byte aligned. See also Pylon::IsPacked(). The stride in bytes can not be computed if the image is invalid.