Skip to content

pylon/ImageFormatConverter.h#

Contains an image format converter class.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::CImageFormatConverter
Creates new images by converting a source image to another format.
class Pylon::CImageFormatConverter::IOutputPixelFormatEnum

Source code#

//------------------------------------------------------------------------------
//  Basler pylon SDK
//  Copyright (c) 2010-2022 Basler AG
//  http://www.baslerweb.com
//  Author:  Andreas Gau
//------------------------------------------------------------------------------
#ifndef INCLUDED_IMAGEFORMATCONVERTER_H_1564142
#define INCLUDED_IMAGEFORMATCONVERTER_H_1564142

#include <pylon/Platform.h>

#ifdef _MSC_VER
#   pragma pack(push, PYLON_PACKING)
#endif /* _MSC_VER */

#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4275 ) // Class must have a dll interface to be used by clients of the class.
#endif

#include <pylon/stdinclude.h>
#include <pylon/PylonUtility.h>
#include <pylon/_ImageFormatConverterParams.h>
#include <pylon/ReusableImage.h>

namespace Pylon
{
    using namespace Basler_ImageFormatConverterParams;


    class PYLONUTILITY_API CImageFormatConverter : public CImageFormatConverterParams_Params
    {
    public:

        CImageFormatConverter();


        virtual ~CImageFormatConverter();


        virtual void Initialize( EPixelType sourcePixelType );


        virtual bool IsInitialized( EPixelType sourcePixelType ) const;


        virtual void Uninitialize();


        virtual bool ImageHasDestinationFormat( const IImage& sourceImage ) const;


        virtual bool ImageHasDestinationFormat( EPixelType sourcePixelType, size_t sourcePaddingX, EImageOrientation sourceOrientation ) const;


        virtual size_t GetBufferSizeForConversion( const IImage& sourceImage ) const;


        virtual size_t GetBufferSizeForConversion( EPixelType sourcePixelType, uint32_t sourceWidth, uint32_t sourceHeight ) const;


        virtual void Convert( IReusableImage& destinationImage, const IImage& sourceImage );


        virtual void Convert( IReusableImage& destinationImage,
                              const void* pSourceBuffer,
                              size_t sourceBufferSizeBytes,
                              EPixelType sourcePixelType,
                              uint32_t sourceWidth,
                              uint32_t sourceHeight,
                              size_t sourcePaddingX,
                              EImageOrientation sourceOrientation
                              );


        virtual void Convert( void* pDestinationBuffer, size_t destinationBufferSizeBytes, const IImage& sourceImage );


        virtual void Convert( void* pDestinationBuffer,
                              size_t destinationBufferSizeBytes,
                              const void* pSourceBuffer,
                              size_t sourceBufferSizeBytes,
                              EPixelType sourcePixelType,
                              uint32_t sourceWidth,
                              uint32_t sourceHeight,
                              size_t sourcePaddingX,
                              EImageOrientation sourceOrientation
                              );


        static bool IsSupportedInputFormat( EPixelType sourcePixelType );


        static bool IsSupportedOutputFormat( EPixelType destinationPixelType );


        virtual GenApi::INodeMap& GetNodeMap();

    private:
        // The converter object can not be copied.
        CImageFormatConverter( const CImageFormatConverter& src );
        // The converter object can not be copied.
        CImageFormatConverter& operator=( const CImageFormatConverter& src );

        // Internal use only.
        class CImageFormatConverterImpl;
        CImageFormatConverterImpl* m_pImpl;

    public:
        // This class emulates part of the behavior of a GenApi::IEnumerationT<T> interface used for native parameter access.
        // This allows using the EPixelType enumeration.
        class IOutputPixelFormatEnum
        {
        public:
            virtual void operator=( EPixelType outputPixelType ) = 0;
            virtual void SetValue( EPixelType outputPixelType ) = 0;

            virtual EPixelType GetValue() const = 0;
            virtual EPixelType operator()() const = 0;
        };

        IOutputPixelFormatEnum& OutputPixelFormat;
    };

}

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#ifdef _MSC_VER
#   pragma pack(pop)
#endif /* _MSC_VER */

#endif /* INCLUDED_IMAGEFORMATCONVERTER_H_1564142 */

Updated on 5 July 2022 at 15:30:01