Skip to content

Pylon::CPylonImage#

Module: Image Handling Support

Describes an image. More…

#include <pylon/PylonImage.h>

Inherits from Pylon::CPylonImageBase, Pylon::IReusableImage, Pylon::IImage

Public Functions#

Name
CPylonImage()
Creates an invalid image.
CPylonImage(const CPylonImage & source)
Copies the image properties and creates a reference to the buffer of the source image.
virtual ~CPylonImage()
Destroys a pylon image object.
virtual CPylonImage & operator=(const CPylonImage & source)
Copies the image properties and creates a reference to the buffer of the source image.
virtual void CopyImage(const IImage & image)
Copies the image data from a different image.
virtual void CopyImage(const IImage & image, size_t newPaddingX)
Copies the image data from a different image and changes the padding while copying.
virtual void CopyImage(void * pBuffer, size_t bufferSizeBytes, EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation =ImageOrientation_TopDown)
Copies the image data from a provided buffer.
virtual void AttachGrabResultBufferWithUserHints(const CGrabResultPtr & grabResult, EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation =ImageOrientation_TopDown)
Attaches a grab result buffer using additional hints.
virtual void AttachGrabResultBuffer(const CGrabResultPtr & grabResult)
Attaches a grab result buffer.
virtual void AttachUserBuffer(void * pBuffer, size_t bufferSizeBytes, EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation =ImageOrientation_TopDown, CPylonImageUserBufferEventHandler * pEventHandler =NULL)
Attaches a user buffer.
virtual bool IsValid() const
Can be used to check whether an image is valid.
virtual EPixelType GetPixelType() const
Get the current pixel type.
virtual uint32_t GetWidth() const
Get the current number of columns in pixels.
virtual uint32_t GetHeight() const
Get the current number of rows.
virtual size_t GetPaddingX() const
Get the number of extra data bytes at the end of each row.
virtual EImageOrientation GetOrientation() const
Get the vertical orientation of the image in memory.
virtual void * GetBuffer()
Get the pointer to the buffer.
virtual const void * GetBuffer() const
Get the pointer to the buffer containing the image.
virtual size_t GetImageSize() const
Get the size of the image in bytes.
virtual bool IsUnique() const
Indicates that the referenced buffer is only referenced by this image.
virtual bool GetStride(size_t & strideBytes) const
Get the stride in bytes.
virtual bool IsSupportedPixelType(EPixelType pixelType) const
Can be used to check whether the pixel type is supported.
virtual bool IsAdditionalPaddingSupported() const
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)
Resets the image properties and allocates a new buffer if required.
virtual void Reset(EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation =ImageOrientation_TopDown)
Extends the Reset( EPixelType, uint32_t, uint32_t, EImageOrientation) method by settable paddingX.
virtual void Release()
Releases the image buffer and resets to an invalid image.
virtual bool IsUserBufferAttached() const
Returns true if the referenced buffer has been provided by the user.
virtual bool IsGrabResultBufferAttached() const
Returns true if the referenced buffer has been provided by a grab result.
virtual size_t GetAllocatedBufferSize() const
Returns the size of the used buffer.
virtual void ChangePixelType(EPixelType pixelType)
Changes the pixel type of the image.
virtual CPylonImage GetPlane(size_t planeIndex) const
Creates a new pylon image for a plane of the image.
virtual CPylonImage GetAoi(uint32_t topLeftX, uint32_t topLeftY, uint32_t width, uint32_t height) const
Creates a new pylon image for an image area of interest (Image AOI) derived from the image.
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.
CPylonImage Create(EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX =0, EImageOrientation orientation =ImageOrientation_TopDown)
Creates an image and allocates a buffer for it.

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.

Detailed Description#

class Pylon::CPylonImage;

Describes an image.

Buffer Handling:

The buffer that is automatically created by the CPylonImage class or a hosted grab result buffer are replaced by a larger buffer if required. The size of the allocated buffer is never decreased. Referenced user buffers are never automatically replaced by a larger buffer. Referenced grab result buffers are never reused. See the Reset() method for more details. The Release() method can be used to detach a user buffer, release a hosted grab result buffer or to free an allocated buffer.

Thread Safety:

The CPylonImage class is not thread-safe.

  • Automatically handles size and lifetime of the image buffer.
  • Allows to take over a buffer of grab result which is preventing its reuse as long as required.
  • Allows to connect user buffers or buffers provided by third party software packages.
  • Provides methods for loading and saving an image in different file formats.
  • Serves as the main target format for the image format converter CImageFormatConverter.
  • Eases working with planar images.
  • Eases extraction of AOIs, e.g. for thumbnail images of defects.

Public Functions Documentation#

function CPylonImage#

CPylonImage()

Creates an invalid image.

Error Safety:

Does not throw C++ exceptions.

See Pylon::IImage on how the properties of an invalid image are returned.

function CPylonImage#

CPylonImage(
    const CPylonImage & source
)

Copies the image properties and creates a reference to the buffer of the source image.

Parameters:

  • source The source image.

Postcondition:

  • Another reference to the source image buffer is created.
  • Creates an invalid image if the source image is invalid.

Error Safety:

Does not throw C++ exceptions.

function ~CPylonImage#

virtual ~CPylonImage()

Destroys a pylon image object.

Error Safety:

Does not throw C++ exceptions.

function operator=#

virtual CPylonImage & operator=(
    const CPylonImage & source
)

Copies the image properties and creates a reference to the buffer of the source image.

Parameters:

  • source The source image.

Postcondition:

  • Another reference to the source image buffer is created.
  • Creates an invalid image if the source image is invalid.

Error Safety:

Does not throw C++ exceptions.

function CopyImage#

virtual void CopyImage(
    const IImage & image
)

Copies the image data from a different image.

Parameters:

Precondition: The preconditions of the Reset() method must be met.

Postcondition:

  • The image contains a copy of the image data contained by the source image.
  • Creates an invalid image if the source image is invalid.

Error Safety:

Throws an exception when no buffer with the required size could be allocated. Throws an exception when the preconditions of the Reset() method are not met.

This method is used for making a full copy of an image. Calls the Reset() method to set the same image properties as the source image and copies the image data.

function CopyImage#

virtual void CopyImage(
    const IImage & image,
    size_t newPaddingX
)

Copies the image data from a different image and changes the padding while copying.

Parameters:

  • image The source image, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object.
  • newPaddingX The number of extra data bytes at the end of each row.

Precondition:

  • The preconditions of the Reset() method must be met.
  • The rows of the source image must be byte aligned. This may not be the case for packed pixel types. See Pylon::IsPacked().
  • The rows of the newly created image must be byte aligned. This may not be the case for packed pixel types. See Pylon::IsPacked().

Postcondition:

  • The image contains a copy of the image data contained by the source image.
  • The line padding is adjusted.
  • The byte aligned row padding area is set to zero.
  • Creates an invalid image if the source image is invalid.

Error Safety:

Throws an exception when no buffer with the required size could be allocated. Throws an exception when the preconditions of the Reset() method are not met.

This method is used for making a full copy of an image except for changing the padding. Calls the Reset() method to set the same image properties as the source image and copies the image data. This method is useful in combination with the GetAoi() method.

function CopyImage#

virtual void CopyImage(
    void * pBuffer,
    size_t bufferSizeBytes,
    EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    size_t paddingX,
    EImageOrientation orientation =ImageOrientation_TopDown
)

Copies the image data from a provided buffer.

Parameters:

  • pBuffer The pointer to the buffer of the source image.
  • bufferSizeBytes The size of the buffer of the source image.
  • pixelType The pixel type of the source image.
  • width The number of pixels in a row in the source image.
  • height The number of rows in the source 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:

  • The pixel type must be valid.
  • The width value must be >= 0 and < _I32_MAX.
  • The height value must be >= 0 and < _I32_MAX.
  • The pointer to the source buffer must not be NULL.
  • The source buffer must be large enough to hold the image described by the parameters.
  • The preconditions of the Reset() method must be met.

Postcondition: A copy of the image contained by the source image buffer is made.

Error Safety:

Throws an exception when no buffer with the required size could be allocated. Throws an exception when the preconditions of the Reset() method are not met.

This method is used for making a full copy of an image. Calls the Reset() method to set the same image properties as the source image and copies the image data.

function AttachGrabResultBufferWithUserHints#

virtual void AttachGrabResultBufferWithUserHints(
    const CGrabResultPtr & grabResult,
    EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    size_t paddingX,
    EImageOrientation orientation =ImageOrientation_TopDown
)

Attaches a grab result buffer using additional hints.

Parameters:

  • grabResult The source buffer.
  • pixelType The pixel type of the source image.
  • width The number of pixels in a row in the source image.
  • height The number of rows in the source 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:

  • The grabResult must be valid.
  • The pixelType must be valid.
  • The width value must be >= 0 and < _I32_MAX.
  • The height value must be >= 0 and < _I32_MAX.

Postcondition:

  • The image properties are taken from the width, height, pixelType, paddingX and orientation parameters.
  • The grab result buffer is used by the image class.
  • Another reference to the grab result buffer is created. This prevents the buffer's reuse for grabbing.

Error Safety:

Throws an exception if the preconditions are not met. Throws an exception if the buffer size of the grabresult is too small for an image with the given parameters.

This allows to display grabbed data in a user-defined way.

function AttachGrabResultBuffer#

virtual void AttachGrabResultBuffer(
    const CGrabResultPtr & grabResult
)

Attaches a grab result buffer.

Parameters:

  • grabResult The source image represented by a grab result.

Postcondition:

  • The image properties are taken from the grab result.
  • The grab result buffer is used by the image class.
  • Another reference to the grab result buffer is created. This prevents the buffer's reuse for grabbing.
  • Creates an invalid image if the grabResult is invalid.
  • Creates an invalid image if the grab was not successful. See CGrabResultData::GrabSucceeded().

Error Safety:

Throws an exception when no buffer with the required size could be allocated. Throws an exception when the preconditions of the Reset() method are not met.

function AttachUserBuffer#

virtual void AttachUserBuffer(
    void * pBuffer,
    size_t bufferSizeBytes,
    EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    size_t paddingX,
    EImageOrientation orientation =ImageOrientation_TopDown,
    CPylonImageUserBufferEventHandler * pEventHandler =NULL
)

Attaches a user buffer.

Parameters:

  • pBuffer The pointer to the buffer of the source image. CPylonImage will never free any user buffers.
  • bufferSizeBytes The size of the buffer of the source image.
  • pixelType The pixel type of the source image.
  • width The number of pixels in a row in the source image.
  • height The number of rows in the source 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.
  • pEventHandler A pointer to an optional CPylonImageUserBufferEventHandler-derived object called when the user-supplied buffer is not used anymore. You can use this to free the user-supplied buffer. In case the function throws an exception, the handler will not be called.

Precondition:

  • The pixel type must be valid.
  • The width value must be >= 0 and < _I32_MAX.
  • The height value must be >= 0 and < _I32_MAX.
  • The pointer to the source buffer must not be NULL.
  • The source buffer must be large enough to hold the image described by the parameters.
  • The buffer passed in pBuffer must not be currently attached.

Postcondition:

  • The image properties are taken from the parameters passed.
  • The user buffer is used by the image class.
  • The user buffer must not be freed while being attached.

Error Safety:

Throws an exception if the preconditions are not met. In this case the an optional handler passed in pEventHandler will not be called.

When attaching a user buffer and passing a pEventHandler, the user is responsible for ensuring the object is valid until CPylonImageUserBufferEventHandler::OnPylonImageUserBufferDetached() has been called. The user is also responsible to free the handler object after CPylonImageUserBufferEventHandler::OnPylonImageUserBufferDetached() has been called. After the function has returned, CPylonImage won't access the object anymore. See CPylonImageUserBufferEventHandler::OnPylonImageUserBufferDetached() for a sample.

function IsValid#

virtual bool IsValid() const

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.

Reimplements: Pylon::CPylonImageBase::IsValid

function GetPixelType#

virtual EPixelType GetPixelType() const

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.

Reimplements: Pylon::CPylonImageBase::GetPixelType

function GetWidth#

virtual uint32_t GetWidth() const

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.

Reimplements: Pylon::CPylonImageBase::GetWidth

function GetHeight#

virtual uint32_t GetHeight() const

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.

Reimplements: Pylon::CPylonImageBase::GetHeight

function GetPaddingX#

virtual size_t GetPaddingX() const

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.

Reimplements: Pylon::CPylonImageBase::GetPaddingX

function GetOrientation#

virtual EImageOrientation GetOrientation() const

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.

Reimplements: Pylon::CPylonImageBase::GetOrientation

function GetBuffer#

virtual void * GetBuffer()

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.

Reimplements: Pylon::CPylonImageBase::GetBuffer

function GetBuffer#

virtual const void * GetBuffer() const

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.

Reimplements: Pylon::CPylonImageBase::GetBuffer

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

function GetImageSize#

virtual size_t GetImageSize() const

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.

Reimplements: Pylon::CPylonImageBase::GetImageSize

function IsUnique#

virtual bool IsUnique() const

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.

Reimplements: Pylon::CPylonImageBase::IsUnique

function GetStride#

virtual bool GetStride(
    size_t & strideBytes
) const

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.

Reimplements: Pylon::CPylonImageBase::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.

function IsSupportedPixelType#

virtual bool IsSupportedPixelType(
    EPixelType pixelType
) const

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.

Reimplements: Pylon::CPylonImageBase::IsSupportedPixelType

function IsAdditionalPaddingSupported#

virtual bool IsAdditionalPaddingSupported() const

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.

Reimplements: Pylon::CPylonImageBase::IsAdditionalPaddingSupported

function Reset#

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

Resets the image properties and allocates a new buffer if required.

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 width value must be >= 0 and < _I32_MAX.
  • The height value must be >= 0 and < _I32_MAX.
  • If a user buffer is referenced then this buffer must not be referenced by another pylon image. See the IsUnique() and IsUserBufferAttached() methods.
  • If a user buffer is referenced then this buffer must be large enough to hold the destination image. See the GetAllocatedBufferSize() and IsUserBufferAttached() methods.

Postcondition:

  • If the previously referenced buffer is a grab result buffer, a new buffer has been allocated.
  • If the previously referenced buffer is also referenced by another pylon image, a new buffer has been allocated.
  • If the previously referenced buffer is not large enough to hold an image with the given properties, a new buffer has been allocated.
  • If no buffer has been allocated before, a buffer has been allocated.

Error Safety:

Throws an exception when the preconditions are not met. Throws an exception when no buffer with the required size could be allocated.

Reimplements: Pylon::CPylonImageBase::Reset

function Reset#

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

Extends the Reset( EPixelType, uint32_t, uint32_t, EImageOrientation) method by settable paddingX.

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.
  • paddingX The number of extra data bytes at the end of each row.

Precondition:

  • The width value must be >= 0 and < _I32_MAX.
  • The height value must be >= 0 and < _I32_MAX.
  • If a user buffer is referenced then this buffer must not be referenced by another pylon image. See the IsUnique() and IsUserBufferAttached() methods.
  • If a user buffer is referenced then this buffer must be large enough to hold the destination image. See the GetAllocatedBufferSize() and IsUserBufferAttached() methods.

Postcondition:

  • If the previously referenced buffer is a grab result buffer, a new buffer has been allocated.
  • If the previously referenced buffer is also referenced by another pylon image, a new buffer has been allocated.
  • If the previously referenced buffer is not large enough to hold an image with the given properties, a new buffer has been allocated.
  • If no buffer has been allocated before, a buffer has been allocated.

Error Safety:

Throws an exception when the preconditions are not met. Throws an exception when no buffer with the required size could be allocated.

Reimplements: Pylon::CPylonImageBase::Reset

function Release#

virtual void Release()

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.

Reimplements: Pylon::CPylonImageBase::Release

function IsUserBufferAttached#

virtual bool IsUserBufferAttached() const

Returns true if the referenced buffer has been provided by the user.

function IsGrabResultBufferAttached#

virtual bool IsGrabResultBufferAttached() const

Returns true if the referenced buffer has been provided by a grab result.

function GetAllocatedBufferSize#

virtual size_t GetAllocatedBufferSize() const

Returns the size of the used buffer.

Error Safety:

Does not throw C++ exceptions.

This method is useful when working with so-called user buffers.

function ChangePixelType#

virtual void ChangePixelType(
    EPixelType pixelType
)

Changes the pixel type of the image.

Parameters:

  • pixelType The new pixel type.

Precondition:

  • Pylon::SamplesPerPixel( oldPixelType) == Pylon::SamplesPerPixel( newPixelType)
  • Pylon::BitPerPixel( oldPixelType) == Pylon::BitPerPixel( newPixelType)

Error Safety:

Throws an exception when the new pixel type properties do not match the existing ones.

function GetPlane#

virtual CPylonImage GetPlane(
    size_t planeIndex
) const

Creates a new pylon image for a plane of the image.

Parameters:

  • planeIndex The zero based index of the plane.

Return: A pylon image referencing a plane of the image.

Precondition: The value of planeIndex < Pylon::PlaneCount( GetPixelType()).

Postcondition:

  • A reference to the same buffer is created. No image data is copied.
  • The returned image has the Pylon::GetPlanePixelType( GetPixelType()) pixel type.
  • If the image is not planar only index 0 is allowed. A call passing index 0 returns a copy of the image. No image data is copied.

Error Safety:

Throws an exception when the plane index is out of range.

No image data is copied.

Use CopyImage( const IImage& image) to create a full copy.

copiedPlane.CopyImage( planarImage.GetPlane( 2));

function GetAoi#

virtual CPylonImage GetAoi(
    uint32_t topLeftX,
    uint32_t topLeftY,
    uint32_t width,
    uint32_t height
) const

Creates a new pylon image for an image area of interest (Image AOI) derived from the image.

Parameters:

  • topLeftX The x-coordinate of the top left corner of the image AOI in pixels.
  • topLeftY The y-coordinate of the top left corner of the image AOI in pixels.
  • width The width of the image AOI in pixels.
  • height The height of the image AOI in pixels.

Return: A pylon image referencing an image AOI of the image.

Precondition:

  • The image must be valid.
  • The image AOI is located inside the image.
  • The image is not in a planar format, see Pylon::IsPlanar(). Use GetPlane() first in this case.
  • The rows of the image must be byte aligned. This may not be the case for packed pixel types. See Pylon::IsPacked().
  • The x-coordinate must be byte aligned. This may not be the case for packed pixel types. See Pylon::IsPacked().
  • The topLeftX parameter must be divisible by the return value of Pylon::GetPixelIncrementX() for the image's pixel type.
  • The topLeftY parameter must be divisible by the return value of Pylon::GetPixelIncrementY() for the image's pixel type.

Postcondition:

  • A reference to the same buffer is created. The image data is not copied.
  • The returned image uses the paddingX property to skip over image content outside of the image AOI.

Error Safety:

Throws an exception when the preconditions are not met.

No image data is copied.

Use CopyImage( const IImage& image, size_t newPaddingX) to create a full copy and to remove the additional padding.

copiedAoi.CopyImage( image.GetAoi( 80, 90, 100, 100), 0);

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 Create#

static CPylonImage Create(
    EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    size_t paddingX =0,
    EImageOrientation orientation =ImageOrientation_TopDown
)

Creates an image and allocates a buffer for it.

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:

  • The pixel type must be valid.
  • The width value must be >= 0 and < _I32_MAX.
  • The height value must be >= 0 and < _I32_MAX.

Error Safety:

Throws an exception when the parameters are invalid. Throws an exception when no buffer with the required size could be allocated.