ImfImageChannel.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Copyright (c) Contributors to the OpenEXR Project.
  4. //
  5. #ifndef INCLUDED_IMF_IMAGE_CHANNEL_H
  6. #define INCLUDED_IMF_IMAGE_CHANNEL_H
  7. //----------------------------------------------------------------------------
  8. //
  9. // class ImageChannel
  10. //
  11. // For an explanation of images, levels and channels,
  12. // see the comments in header file Image.h.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "ImfUtilExport.h"
  16. #include "ImfPixelType.h"
  17. #include "ImfFrameBuffer.h"
  18. #include "ImfChannelList.h"
  19. #include "IexBaseExc.h"
  20. #include <ImathBox.h>
  21. #include <half.h>
  22. #include <typeinfo>
  23. #include <cstring>
  24. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
  25. class ImageLevel;
  26. //
  27. // Image channels:
  28. //
  29. // An image channel holds the pixel data for a single channel of one level
  30. // of an image. Separate classes for flat and deep channels are derived
  31. // from the ImageChannel base class.
  32. //
  33. class ImageLevel;
  34. class IMFUTIL_EXPORT_TYPE ImageChannel
  35. {
  36. public:
  37. //
  38. // The OpenEXR pixel type of this channel (HALF, FLOAT or UINT).
  39. //
  40. virtual PixelType pixelType () const = 0;
  41. //
  42. // Generate an OpenEXR channel for this image channel.
  43. //
  44. IMFUTIL_EXPORT
  45. Channel channel () const;
  46. //
  47. // Access to x and y sampling rates, "perceptually linear" flag,
  48. // and the number of pixels that are stored in this channel.
  49. //
  50. int xSampling () const {return _xSampling;}
  51. int ySampling () const {return _ySampling;}
  52. bool pLinear () const {return _pLinear;}
  53. int pixelsPerRow () const {return _pixelsPerRow;}
  54. int pixelsPerColumn () const {return _pixelsPerColumn;}
  55. size_t numPixels () const {return _numPixels;}
  56. //
  57. // Access to the image level to which this channel belongs.
  58. //
  59. ImageLevel & level () {return _level;}
  60. const ImageLevel & level () const {return _level;}
  61. protected:
  62. IMFUTIL_EXPORT
  63. ImageChannel (ImageLevel &level,
  64. int xSampling,
  65. int ySampling,
  66. bool pLinear);
  67. IMFUTIL_EXPORT
  68. virtual ~ImageChannel();
  69. IMFUTIL_EXPORT
  70. virtual void resize ();
  71. IMFUTIL_EXPORT
  72. void boundsCheck(int x, int y) const;
  73. private:
  74. ImageChannel (const ImageChannel &) = delete;
  75. ImageChannel & operator = (const ImageChannel &) = delete;
  76. ImageChannel (ImageChannel &&) = delete;
  77. ImageChannel & operator = (ImageChannel &&) = delete;
  78. ImageLevel & _level;
  79. int _xSampling;
  80. int _ySampling;
  81. bool _pLinear;
  82. int _pixelsPerRow;
  83. int _pixelsPerColumn;
  84. size_t _numPixels;
  85. };
  86. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  87. #endif