HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfPreviewImage.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 #ifndef INCLUDED_IMF_PREVIEW_IMAGE_H
7 #define INCLUDED_IMF_PREVIEW_IMAGE_H
8 
9 #include "ImfForward.h"
10 
11 //-----------------------------------------------------------------------------
12 //
13 // class PreviewImage -- a usually small, low-dynamic range image,
14 // that is intended to be stored in an image file's header.
15 //
16 // struct PreviewRgba -- holds the value of a PreviewImage pixel.
17 //
18 //-----------------------------------------------------------------------------
19 
21 
23 {
24  unsigned char r; // Red, green and blue components of
25  unsigned char g; // the pixel's color; intensity is
26  unsigned char b; // proportional to pow (x/255, 2.2),
27  // where x is r, g, or b.
28 
29  unsigned char a; // The pixel's alpha; 0 == transparent,
30  // 255 == opaque.
31 
33  unsigned char r = 0,
34  unsigned char g = 0,
35  unsigned char b = 0,
36  unsigned char a = 255)
37  : r (r), g (g), b (b), a (a)
38  {}
39 
40  bool operator==(const PreviewRgba& other) const
41  {
42  return r == other.r && g == other.g && b == other.b && a == other.a;
43  }
44 };
45 
47 {
48 public:
49  //--------------------------------------------------------------------
50  // Constructor:
51  //
52  // PreviewImage(w,h,p) constructs a preview image with w by h pixels
53  // whose initial values are specified in pixel array p. The x and y
54  // coordinates of the pixels in p go from 0 to w-1, and from 0 to h-1.
55  // The pixel with coordinates (x, y) is at address p + y*w + x.
56  // Pixel (0, 0) is in the upper left corner of the preview image.
57  // If p is zero, the pixels in the preview image are initialized with
58  // (r = 0, b = 0, g = 0, a = 255).
59  //
60  //--------------------------------------------------------------------
61 
63  PreviewImage (
64  unsigned int width = 0,
65  unsigned int height = 0,
66  const PreviewRgba pixels[] = 0);
67 
68  //-----------------------------------------------------
69  // Copy constructor, destructor and assignment operator
70  //-----------------------------------------------------
71 
73  PreviewImage (const PreviewImage& other);
75  ~PreviewImage ();
76 
78  PreviewImage& operator= (const PreviewImage& other);
79 
80  //-----------------------------------------------
81  // Access to width, height and to the pixel array
82  //-----------------------------------------------
83 
84  inline unsigned int width () const { return _width; }
85  inline unsigned int height () const { return _height; }
86 
87  inline PreviewRgba* pixels () { return _pixels; }
88  inline const PreviewRgba* pixels () const { return _pixels; }
89 
90  //----------------------------
91  // Access to individual pixels
92  //----------------------------
93 
94  inline PreviewRgba& pixel (unsigned int x, unsigned int y)
95  {
96  return _pixels[y * _width + x];
97  }
98 
99  inline const PreviewRgba& pixel (unsigned int x, unsigned int y) const
100  {
101  return _pixels[y * _width + x];
102  }
103 
104 private:
105  unsigned int _width;
106  unsigned int _height;
107  PreviewRgba* _pixels;
108 };
109 
111 
112 #endif
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:83
unsigned int width() const
const PreviewRgba * pixels() const
GLboolean GLboolean g
Definition: glcorearb.h:1222
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLint GLint GLsizei GLint GLenum GLenum const void * pixels
Definition: glcorearb.h:108
GLint y
Definition: glcorearb.h:103
unsigned char r
unsigned int height() const
bool operator==(const PreviewRgba &other) const
GLint GLsizei GLsizei height
Definition: glcorearb.h:103
const PreviewRgba & pixel(unsigned int x, unsigned int y) const
PreviewRgba * pixels()
unsigned char a
#define IMF_EXPORT
Definition: ImfExport.h:54
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
unsigned char b
LeafData & operator=(const LeafData &)=delete
class IMF_EXPORT_TYPE PreviewImage
Definition: ImfForward.h:82
PreviewRgba & pixel(unsigned int x, unsigned int y)
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:80
GLint GLsizei width
Definition: glcorearb.h:103
GLboolean r
Definition: glcorearb.h:1222
PreviewRgba(unsigned char r=0, unsigned char g=0, unsigned char b=0, unsigned char a=255)
#define IMF_EXPORT_TYPE
Definition: ImfExport.h:57
unsigned char g