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