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 
42 {
43 public:
44  //--------------------------------------------------------------------
45  // Constructor:
46  //
47  // PreviewImage(w,h,p) constructs a preview image with w by h pixels
48  // whose initial values are specified in pixel array p. The x and y
49  // coordinates of the pixels in p go from 0 to w-1, and from 0 to h-1.
50  // The pixel with coordinates (x, y) is at address p + y*w + x.
51  // Pixel (0, 0) is in the upper left corner of the preview image.
52  // If p is zero, the pixels in the preview image are initialized with
53  // (r = 0, b = 0, g = 0, a = 255).
54  //
55  //--------------------------------------------------------------------
56 
58  PreviewImage (
59  unsigned int width = 0,
60  unsigned int height = 0,
61  const PreviewRgba pixels[] = 0);
62 
63  //-----------------------------------------------------
64  // Copy constructor, destructor and assignment operator
65  //-----------------------------------------------------
66 
68  PreviewImage (const PreviewImage& other);
70  ~PreviewImage ();
71 
73  PreviewImage& operator= (const PreviewImage& other);
74 
75  //-----------------------------------------------
76  // Access to width, height and to the pixel array
77  //-----------------------------------------------
78 
79  inline unsigned int width () const { return _width; }
80  inline unsigned int height () const { return _height; }
81 
82  inline PreviewRgba* pixels () { return _pixels; }
83  inline const PreviewRgba* pixels () const { return _pixels; }
84 
85  //----------------------------
86  // Access to individual pixels
87  //----------------------------
88 
89  inline PreviewRgba& pixel (unsigned int x, unsigned int y)
90  {
91  return _pixels[y * _width + x];
92  }
93 
94  inline const PreviewRgba& pixel (unsigned int x, unsigned int y) const
95  {
96  return _pixels[y * _width + x];
97  }
98 
99 private:
100  unsigned int _width;
101  unsigned int _height;
102  PreviewRgba* _pixels;
103 };
104 
106 
107 #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
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