Skip to content

pylon/ImagePersistence.h#

Contains an image loading and saving support class.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::CImagePersistenceOptions
Used to pass options to CImagePersistence methods.
class Pylon::CImagePersistence
Contains static functions supporting loading and saving of images.

Source code#

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

#include <pylon/Platform.h>

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


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

namespace Pylon
{
#if defined(PYLON_WIN_BUILD)
    enum EImageFileFormat
    {
        ImageFileFormat_Bmp  = 0,       
        ImageFileFormat_Tiff = 1,       
        ImageFileFormat_Jpeg = 2,       
        ImageFileFormat_Png  = 3,       
        ImageFileFormat_Raw  = 4,       
        ImageFileFormat_Dng  = 5        
    };
#elif defined(PYLON_UNIX_BUILD)
    enum EImageFileFormat
    {
        ImageFileFormat_Tiff = 1,       
        ImageFileFormat_Png  = 3,       
        ImageFileFormat_Raw  = 4,       
        ImageFileFormat_Dng  = 5        
    };
#else
#   error unsupported platform
#endif


    class CImagePersistenceOptions
    {
    public:
        CImagePersistenceOptions()
            : m_quality( 90 )
        {
        }

        ~CImagePersistenceOptions()
        {
        }

        void SetQuality( int quality )
        {
            m_quality = quality;
        }

        int GetQuality()
        {
            return m_quality;
        }

    private:
        int m_quality; 
    };


    class PYLONUTILITY_API CImagePersistence
    {
    public:
        static void Save( EImageFileFormat imageFileFormat, const String_t& filename, const void* pBuffer, size_t bufferSize, EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation, CImagePersistenceOptions* pOptions = NULL );


        static void Save( EImageFileFormat imageFileFormat, const String_t& filename, const IImage& image, CImagePersistenceOptions* pOptions = NULL );


        static bool CanSaveWithoutConversion( EImageFileFormat imageFileFormat, EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation );


        static bool CanSaveWithoutConversion( EImageFileFormat imageFileFormat, const IImage& image );


        static void Load( const String_t& filename, IReusableImage& image );

        static void LoadFromMemory( const void* pBuffer, size_t bufferSizeBytes, IReusableImage& image );

    };

}

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

#endif /* INCLUDED_IMAGEPERSISTENCE_H_3336145 */

Updated on 5 July 2022 at 15:30:01