ReusableImage.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 an interface for a reusable image.
  10. */
  11. #ifndef INCLUDED_REUSABLEIMAGE_H_1558802
  12. #define INCLUDED_REUSABLEIMAGE_H_1558802
  13. #include <pylon/Platform.h>
  14. #ifdef _MSC_VER
  15. # pragma pack(push, PYLON_PACKING)
  16. #endif /* _MSC_VER */
  17. #include <pylon/PylonBase.h>
  18. #include <pylon/Image.h>
  19. namespace Pylon
  20. {
  21. /** \addtogroup Pylon_ImageHandlingSupport
  22. * @{
  23. */
  24. /*!
  25. \interface IReusableImage
  26. \brief Extends the IImage interface to be able to reuse the image's resources to represent a different image.
  27. */
  28. interface IReusableImage : public IImage
  29. {
  30. public:
  31. /// Ensure proper destruction by using a virtual destructor.
  32. // implementation must be out of class or older compilers will throw an error (see below)
  33. virtual ~IReusableImage() = 0;
  34. /*!
  35. \brief Can be used to check whether the pixel type is supported.
  36. \return Returns true if the pixel type is supported.
  37. \error
  38. Does not throw C++ exceptions.
  39. */
  40. virtual bool IsSupportedPixelType( EPixelType pixelType ) const = 0;
  41. /*!
  42. \brief Can be used to check whether the value of PaddingX can be defined by the user.
  43. \return Returns true if the value of PaddingX can be defined by the user.
  44. \error
  45. Does not throw C++ exceptions.
  46. */
  47. virtual bool IsAdditionalPaddingSupported() const = 0;
  48. /*!
  49. \brief Resets the image properties and provides a buffer to hold the image.
  50. \param[in] pixelType The pixel type of the new image.
  51. \param[in] width The number of pixels in a row in the new image.
  52. \param[in] height The number of rows in the new image.
  53. \param[in] orientation The vertical orientation of the image in the image buffer.
  54. \pre
  55. <ul>
  56. <li> The IsSupportedPixelType() method returns true.
  57. <li> The \c width value must be >= 0 and < _I32_MAX.
  58. <li> The \c height value must be >= 0 and < _I32_MAX.
  59. </ul>
  60. \post
  61. <ul>
  62. <li> The properties of the image are changed.
  63. <li> A buffer large enough to hold the image is provided.
  64. </ul>
  65. \error
  66. Throws an exception when the preconditions are not met.
  67. Throws an exception when no buffer with the required size can be provided, e.g. by allocation.
  68. The original representation is preserved on error.
  69. */
  70. virtual void Reset( EPixelType pixelType, uint32_t width, uint32_t height, EImageOrientation orientation = ImageOrientation_TopDown ) = 0;
  71. /*!
  72. \brief Resets the image properties including user defined PaddingX and provides a buffer to hold the image.
  73. Extends the Reset(EPixelType, uint32_t, uint32_t) method with user provided padding.
  74. \param[in] pixelType The pixel type of the new image.
  75. \param[in] width The number of pixels in a row in the new image.
  76. \param[in] height The number of rows in the new image.
  77. \param[in] paddingX The number of extra data bytes at the end of each row.
  78. \param[in] orientation The vertical orientation of the image in the image buffer.
  79. \pre
  80. <ul>
  81. <li> The preconditions of the Reset() method without paddingX parameter apply.
  82. <li> The IsAdditionalPaddingSupported() method returns true.
  83. </ul>
  84. */
  85. virtual void Reset( EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation = ImageOrientation_TopDown ) = 0;
  86. /*!
  87. \brief Releases the image buffer and resets to an invalid image.
  88. \post
  89. <ul>
  90. <li> PixelType = PixelType_Undefined.
  91. <li> Width = 0.
  92. <li> Height = 0.
  93. <li> PaddingX = 0.
  94. <li> No buffer is allocated.
  95. </ul>
  96. \error
  97. Does not throw C++ exceptions.
  98. */
  99. virtual void Release() = 0;
  100. };
  101. /**
  102. * @}
  103. */
  104. // implementation for d'tor must be out of class
  105. inline IReusableImage::~IReusableImage()
  106. {
  107. }
  108. }
  109. #ifdef _MSC_VER
  110. # pragma pack(pop)
  111. #endif /* _MSC_VER */
  112. #endif /* INCLUDED_REUSABLEIMAGE_H_1558802 */