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