PylonImageBase.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. //------------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2010-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: Andreas Gau
  6. //------------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief Contains the pylon image base class.
  10. */
  11. #ifndef INCLUDED_PYLONIMAGEBASE_H_6835095
  12. #define INCLUDED_PYLONIMAGEBASE_H_6835095
  13. #include <pylon/Platform.h>
  14. #ifdef _MSC_VER
  15. # pragma pack(push, PYLON_PACKING)
  16. #endif /* _MSC_VER */
  17. #include <pylon/stdinclude.h>
  18. #include <pylon/PylonUtility.h>
  19. #include <pylon/ReusableImage.h>
  20. #include <pylon/ImagePersistence.h>
  21. #include <pylon/PixelData.h>
  22. namespace Pylon
  23. {
  24. /** \addtogroup Pylon_ImageHandlingSupport
  25. * @{
  26. */
  27. /*!
  28. \class CPylonImageBase
  29. \brief Provides basic functionality for pylon image classes.
  30. */
  31. class PYLONUTILITY_API CPylonImageBase : public IReusableImage
  32. {
  33. public:
  34. /*!
  35. \brief Saves the image to disk. Converts the image to a format that can be saved if required.
  36. This is a convenience method that calls CImagePersistence::Save().
  37. If required, the image is automatically converted into a new image and saved afterwards. See
  38. CImagePersistence::CanSaveWithoutConversion() for more information.
  39. An image with a bit depth higher than 8 bit is stored with 16 bit bit depth,
  40. if supported by the image file format. In this case the pixel data is MSB aligned.
  41. If more control over the conversion is required, the CImageFormatConverter class
  42. can be used to convert the input image before saving it.
  43. \param[in] imageFileFormat File format to save the image in.
  44. \param[in] filename Name and path of the image.
  45. \param[in] pOptions Additional options.
  46. \pre
  47. The pixel type of the image to be saved must be a supported input format of the Pylon::CImageFormatConverter.
  48. \error
  49. Throws an exception if the saving of the image fails.
  50. */
  51. virtual void Save( EImageFileFormat imageFileFormat, const String_t& filename, CImagePersistenceOptions* pOptions = NULL ) const;
  52. /*!
  53. \brief Loads an image from a disk.
  54. This is a convenience method that calls CImagePersistence::Load()
  55. \param[in] filename Name and path of the image.
  56. \pre
  57. The image object must be able to hold the image format of the loaded image.
  58. \error
  59. Throws an exception if the image cannot be loaded. The image buffer content is undefined when the loading of the image fails.
  60. */
  61. virtual void Load( const String_t& filename );
  62. /*!
  63. \brief Can be used to check whether the image can be saved without prior conversion.
  64. This is a convenience method that calls CImagePersistence::CanSaveWithoutConversion().
  65. \param[in] imageFileFormat Target file format for the image to be saved.
  66. \return Returns true, if the image can be saved without prior conversion.
  67. \error
  68. Does not throw C++ exceptions.
  69. */
  70. virtual bool CanSaveWithoutConversion( EImageFileFormat imageFileFormat ) const;
  71. /*!
  72. \brief Retrieves the data of a pixel.
  73. \note This method is relativly slow. Do not use it for image processing tasks.
  74. \param[in] posX Horizontal position of the pixel. The first column has position 0.
  75. \param[in] posY Vertical position of the pixel. The first row has position 0.
  76. \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.
  77. \pre
  78. <ul>
  79. <li> The image must be valid.
  80. <li> The pixel position defined by \c posX and \c posY must be located inside the image area.
  81. </ul>
  82. Supported pixel types:
  83. <ul>
  84. <li> PixelType_Mono1packed
  85. <li> PixelType_Mono2packed
  86. <li> PixelType_Mono4packed
  87. <li> PixelType_Mono8
  88. <li> PixelType_Mono8signed
  89. <li> PixelType_Mono10
  90. <li> PixelType_Mono10packed
  91. <li> PixelType_Mono10p
  92. <li> PixelType_Mono12
  93. <li> PixelType_Mono12packed
  94. <li> PixelType_Mono12p
  95. <li> PixelType_Mono16
  96. </ul>
  97. <ul>
  98. <li> PixelType_BayerGR8
  99. <li> PixelType_BayerRG8
  100. <li> PixelType_BayerGB8
  101. <li> PixelType_BayerBG8
  102. <li> PixelType_BayerGR10
  103. <li> PixelType_BayerRG10
  104. <li> PixelType_BayerGB10
  105. <li> PixelType_BayerBG10
  106. <li> PixelType_BayerGR12
  107. <li> PixelType_BayerRG12
  108. <li> PixelType_BayerGB12
  109. <li> PixelType_BayerBG12
  110. <li> PixelType_BayerGR12Packed
  111. <li> PixelType_BayerRG12Packed
  112. <li> PixelType_BayerGB12Packed
  113. <li> PixelType_BayerBG12Packed
  114. <li> PixelType_BayerGR10p
  115. <li> PixelType_BayerRG10p
  116. <li> PixelType_BayerGB10p
  117. <li> PixelType_BayerBG10p
  118. <li> PixelType_BayerGR12p
  119. <li> PixelType_BayerRG12p
  120. <li> PixelType_BayerGB12p
  121. <li> PixelType_BayerBG12p
  122. <li> PixelType_BayerGR16
  123. <li> PixelType_BayerRG16
  124. <li> PixelType_BayerGB16
  125. <li> PixelType_BayerBG16
  126. </ul>
  127. <ul>
  128. <li> PixelType_RGB8packed
  129. <li> PixelType_BGR8packed
  130. <li> PixelType_RGBA8packed
  131. <li> PixelType_BGRA8packed
  132. <li> PixelType_RGB10packed
  133. <li> PixelType_BGR10packed
  134. <li> PixelType_RGB12packed
  135. <li> PixelType_BGR12packed
  136. <li> PixelType_RGB12V1packed
  137. <li> PixelType_RGB16packed
  138. <li> PixelType_RGB8planar
  139. <li> PixelType_RGB10planar
  140. <li> PixelType_RGB12planar
  141. <li> PixelType_RGB16planar
  142. </ul>
  143. <ul>
  144. <li> PixelType_YUV422packed
  145. <li> PixelType_YUV422_YUYV_Packed
  146. </ul>
  147. \error
  148. Throws an exception, if the preconditions are not met.
  149. */
  150. virtual SPixelData GetPixelData( uint32_t posX, uint32_t posY ) const;
  151. };
  152. /**
  153. * @}
  154. */
  155. }
  156. #ifdef _MSC_VER
  157. # pragma pack(pop)
  158. #endif /* _MSC_VER */
  159. #endif /* INCLUDED_PYLONIMAGEBASE_H_6835095 */