Image.h 5.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 an interface for an image.
  10. */
  11. #ifndef INCLUDED_IMAGE_H_9730799
  12. #define INCLUDED_IMAGE_H_9730799
  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/PixelType.h>
  19. namespace Pylon
  20. {
  21. /** \addtogroup Pylon_ImageHandlingSupport
  22. * @{
  23. */
  24. /// Defines the vertical orientation of an image in memory.
  25. enum EImageOrientation
  26. {
  27. ImageOrientation_TopDown, //!< The first row of the image is located at the start of the image buffer. This is the default for images taken by a camera.
  28. ImageOrientation_BottomUp //!< The last row of the image is located at the start of the image buffer.
  29. };
  30. /*!
  31. \interface IImage
  32. \brief Usable to access image properties and image buffer.
  33. */
  34. interface IImage
  35. {
  36. public:
  37. /// Ensure proper destruction by using a virtual destructor.
  38. // Do not add implemenation here in class as older compilers doesn't accept in-class definitions (see definition below)
  39. virtual ~IImage() = 0;
  40. //
  41. /*!
  42. \brief Can be used to check whether an image is valid.
  43. \return Returns false if the image is invalid.
  44. \error
  45. Does not throw C++ exceptions.
  46. */
  47. virtual bool IsValid() const = 0;
  48. /*!
  49. \brief Get the current pixel type.
  50. \return Returns the pixel type or PixelType_Undefined if the image is invalid.
  51. \error
  52. Does not throw C++ exceptions.
  53. */
  54. virtual EPixelType GetPixelType() const = 0;
  55. /*!
  56. \brief Get the current number of columns in pixels.
  57. \return Returns the current number of columns in pixels or 0 if the image is invalid.
  58. \error
  59. Does not throw C++ exceptions.
  60. */
  61. virtual uint32_t GetWidth() const = 0;
  62. /*!
  63. \brief Get the current number of rows.
  64. \return Returns the current number of rows or 0 if the image is invalid.
  65. \error
  66. Does not throw C++ exceptions.
  67. */
  68. virtual uint32_t GetHeight() const = 0;
  69. /*!
  70. \brief Get the number of extra data bytes at the end of each row.
  71. \return Returns the number of extra data bytes at the end of each row or 0 if the image is invalid.
  72. \error
  73. Does not throw C++ exceptions.
  74. */
  75. virtual size_t GetPaddingX() const = 0;
  76. /*!
  77. \brief Get the vertical orientation of the image in memory.
  78. \return Returns the orientation of the image or ImageOrientation_TopDown if the image is invalid.
  79. \error
  80. Does not throw C++ exceptions.
  81. */
  82. virtual EImageOrientation GetOrientation() const = 0;
  83. /*!
  84. \brief Get the pointer to the buffer.
  85. \return Returns the pointer to the used buffer or NULL if the image is invalid.
  86. \error
  87. Does not throw C++ exceptions.
  88. */
  89. virtual void* GetBuffer() = 0;
  90. /*!
  91. \brief Get the pointer to the buffer containing the image.
  92. The buffer is at least as large as the value returned by GetImageSize().
  93. \return Returns the pointer to the used buffer or NULL if the image is invalid.
  94. \error
  95. Does not throw C++ exceptions.
  96. */
  97. virtual const void* GetBuffer() const = 0;
  98. /*!
  99. \brief Get the size of the image in bytes.
  100. \return Returns the size of the image in bytes or 0 if the image is invalid.
  101. \error
  102. Does not throw C++ exceptions.
  103. */
  104. virtual size_t GetImageSize() const = 0;
  105. /*!
  106. \brief Indicates that the referenced buffer is only referenced by this image.
  107. \return Returns true if the referenced buffer is only referenced by this image. Returns false if the image is invalid.
  108. \error
  109. Does not throw C++ exceptions.
  110. */
  111. virtual bool IsUnique() const = 0;
  112. /*!
  113. \brief Get the stride in bytes.
  114. The stride in bytes can not be computed for packed image format when the stride is not byte aligned. See also Pylon::IsPacked().
  115. The stride in bytes can not be computed if the image is invalid.
  116. \param[out] strideBytes The stride in byte if it can be computed.
  117. \return Returns true if the stride can be computed.
  118. \error
  119. Does not throw C++ exceptions.
  120. */
  121. virtual bool GetStride( size_t& strideBytes ) const = 0;
  122. };
  123. /**
  124. * @}
  125. */
  126. // Implementation required for Windows only.
  127. // Note: the C++ standard >= 11 prohibit pure virtual destructors with a function body
  128. // in the declaration. Consequently gcc 4.0 and newer reject an inline implementation
  129. // in the class.
  130. inline IImage::~IImage()
  131. {
  132. }
  133. }
  134. #ifdef _MSC_VER
  135. # pragma pack(pop)
  136. #endif /* _MSC_VER */
  137. #endif /* INCLUDED_IMAGE_H_9730799 */