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 
20 
22 
23 
25 {
26  unsigned char r; // Red, green and blue components of
27  unsigned char g; // the pixel's color; intensity is
28  unsigned char b; // proportional to pow (x/255, 2.2),
29  // where x is r, g, or b.
30 
31  unsigned char a; // The pixel's alpha; 0 == transparent,
32  // 255 == opaque.
33 
34  PreviewRgba (unsigned char r = 0,
35  unsigned char g = 0,
36  unsigned char b = 0,
37  unsigned char a = 255)
38  : r(r), g(g), b(b), a(a) {}
39 };
40 
41 
43 {
44  public:
45 
46  //--------------------------------------------------------------------
47  // Constructor:
48  //
49  // PreviewImage(w,h,p) constructs a preview image with w by h pixels
50  // whose initial values are specified in pixel array p. The x and y
51  // coordinates of the pixels in p go from 0 to w-1, and from 0 to h-1.
52  // The pixel with coordinates (x, y) is at address p + y*w + x.
53  // Pixel (0, 0) is in the upper left corner of the preview image.
54  // If p is zero, the pixels in the preview image are initialized with
55  // (r = 0, b = 0, g = 0, a = 255).
56  //
57  //--------------------------------------------------------------------
58 
60  PreviewImage (unsigned int width = 0,
61  unsigned int height = 0,
62  const PreviewRgba pixels[] = 0);
63 
64  //-----------------------------------------------------
65  // Copy constructor, destructor and assignment operator
66  //-----------------------------------------------------
67 
69  PreviewImage (const PreviewImage &other);
71  ~PreviewImage ();
72 
74  PreviewImage & operator = (const PreviewImage &other);
75 
76 
77  //-----------------------------------------------
78  // Access to width, height and to the pixel array
79  //-----------------------------------------------
80 
81  inline
82  unsigned int width () const {return _width;}
83  inline
84  unsigned int height () const {return _height;}
85 
86  inline
87  PreviewRgba * pixels () {return _pixels;}
88  inline
89  const PreviewRgba * pixels () const {return _pixels;}
90 
91 
92  //----------------------------
93  // Access to individual pixels
94  //----------------------------
95 
96  inline
97  PreviewRgba & pixel (unsigned int x, unsigned int y)
98  {return _pixels[y * _width + x];}
99 
100  inline
101  const PreviewRgba & pixel (unsigned int x, unsigned int y) const
102  {return _pixels[y * _width + x];}
103 
104  private:
105 
106  unsigned int _width;
107  unsigned int _height;
108  PreviewRgba * _pixels;
109 };
110 
111 
113 
114 #endif
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:80
unsigned int width() const
const PreviewRgba * pixels() const
GLboolean GLboolean g
Definition: glcorearb.h:1222
unsigned char r
unsigned int height() const
GLint GLenum GLint x
Definition: glcorearb.h:409
const PreviewRgba & pixel(unsigned int x, unsigned int y) const
PreviewRgba * pixels()
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
unsigned char a
#define IMF_EXPORT
Definition: ImfExport.h:54
GLint GLsizei width
Definition: glcorearb.h:103
GLint GLsizei GLsizei height
Definition: glcorearb.h:103
unsigned char b
class IMF_EXPORT_TYPE PreviewImage
Definition: ImfForward.h:84
PreviewRgba & pixel(unsigned int x, unsigned int y)
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:79
PreviewRgba(unsigned char r=0, unsigned char g=0, unsigned char b=0, unsigned char a=255)
GLboolean r
Definition: glcorearb.h:1222
#define IMF_EXPORT_TYPE
Definition: ImfExport.h:57
GLint GLint GLsizei GLint GLenum GLenum const void * pixels
Definition: glcorearb.h:108
GLint y
Definition: glcorearb.h:103
unsigned char g