Magick++  6.9.3
Pixels.h
Go to the documentation of this file.
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002
4 // Copyright Dirk Lemstra 2014
5 //
6 // Representation of a pixel view.
7 //
8 
9 #if !defined(Magick_Pixels_header)
10 #define Magick_Pixels_header
11 
12 #include "Magick++/Include.h"
13 #include "Magick++/Color.h"
14 #include "Magick++/Image.h"
15 
16 namespace Magick
17 {
19  {
20  public:
21 
22  // Construct pixel view using specified image.
23  Pixels(Magick::Image &image_);
24 
25  // Destroy pixel view
26  ~Pixels(void);
27 
28  // Transfer pixels from the image to the pixel view as defined by
29  // the specified region. Modified pixels may be subsequently
30  // transferred back to the image via sync.
31  PixelPacket *get(const ::ssize_t x_, const ::ssize_t y_,
32  const size_t columns_,const size_t rows_ );
33 
34  // Transfer read-only pixels from the image to the pixel view as
35  // defined by the specified region.
36  const PixelPacket *getConst(const ::ssize_t x_,const ::ssize_t y_,
37  const size_t columns_,const size_t rows_);
38 
39  // Allocate a pixel view region to store image pixels as defined
40  // by the region rectangle. This area is subsequently transferred
41  // from the pixel view to the image via sync.
42  PixelPacket *set(const ::ssize_t x_,const ::ssize_t y_,
43  const size_t columns_,const size_t rows_);
44 
45  // Transfers the image view pixels to the image.
46  void sync(void);
47 
48  // Width of view
49  size_t columns(void) const;
50 
51  // Return pixel colormap index array
52  IndexPacket *indexes(void);
53 
54  // Height of view
55  size_t rows (void) const;
56 
57  // Left ordinate of view
58  ::ssize_t x(void) const;
59 
60  // Top ordinate of view
61  ::ssize_t y(void) const;
62 
63  private:
64 
65  // Copying and assigning Pixels is not supported.
66  Pixels(const Pixels& pixels_);
67  const Pixels& operator=(const Pixels& pixels_);
68 
69  Magick::Image _image; // Image reference
70  MagickCore::CacheView *_view; // Image view handle
71  ::ssize_t _x; // Left ordinate of view
72  ::ssize_t _y; // Top ordinate of view
73  size_t _columns; // Width of view
74  size_t _rows; // Height of view
75 
76  }; // class Pixels
77 
79  {
80  public:
81 
82  // Construct pixel data using specified image
83  PixelData(Magick::Image &image_,std::string map_,const StorageType type_);
84 
85  // Construct pixel data using specified image
86  PixelData(Magick::Image &image_,const ::ssize_t x_,const ::ssize_t y_,
87  const size_t width_,const size_t height_,std::string map_,
88  const StorageType type_);
89 
90  // Destroy pixel data
91  ~PixelData(void);
92 
93  // Pixel data buffer
94  const void *data(void) const;
95 
96  // Length of the buffer
97  ::ssize_t length(void) const;
98 
99  // Size of the buffer in bytes
100  ::ssize_t size(void) const;
101 
102  private:
103 
104  // Copying and assigning PixelData is not supported
105  PixelData(const PixelData& pixels_);
106  const PixelData& operator=(const PixelData& pixels_);
107 
108  void init(Magick::Image &image_,const ::ssize_t x_,const ::ssize_t y_,
109  const size_t width_,const size_t height_,std::string map_,
110  const StorageType type_);
111 
112  void relinquish(void) throw();
113 
114  void *_data; // The pixel data
115  ::ssize_t _length; // Length of the data
116  ::ssize_t _size; // Size of the data
117  }; // class PixelData
118 
119 } // Magick namespace
120 
121 //
122 // Inline methods
123 //
124 
125 // Left ordinate of view
126 inline ::ssize_t Magick::Pixels::x(void) const
127 {
128  return _x;
129 }
130 
131 // Top ordinate of view
132 inline ::ssize_t Magick::Pixels::y(void) const
133 {
134  return _y;
135 }
136 
137 // Width of view
138 inline size_t Magick::Pixels::columns(void) const
139 {
140  return _columns;
141 }
142 
143 // Height of view
144 inline size_t Magick::Pixels::rows(void) const
145 {
146  return _rows;
147 }
148 
149 #endif // Magick_Pixels_header
size_t rows(void) const
Definition: Pixels.h:144
::ssize_t x(void) const
Definition: Pixels.h:126
size_t columns(void) const
Definition: Pixels.h:138
::ssize_t y(void) const
Definition: Pixels.h:132
#define MagickPPExport
Definition: Include.h:261