/work/include/GraphicsMagick/Magick++/Pixels.h
Line | Count | Source |
1 | | // This may look like C code, but it is really -*- C++ -*- |
2 | | // |
3 | | // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002 |
4 | | // SPDX-License-Identifier: MIT |
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 | | { |
18 | | class MagickDLLDecl Pixels |
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 int x_, const int y_, |
32 | | const unsigned int columns_,const unsigned int 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 int x_, const int y_, |
37 | | const unsigned int columns_, |
38 | | const unsigned int rows_ ); |
39 | | |
40 | | // Transfers the image view pixels to the image. |
41 | | void sync ( void ); |
42 | | |
43 | | // Allocate a pixel view region to store image pixels as defined |
44 | | // by the region rectangle. This area is subsequently transferred |
45 | | // from the pixel view to the image via sync. |
46 | | PixelPacket* set ( const int x_, const int y_, |
47 | | const unsigned int columns_, const unsigned int rows_ ); |
48 | | |
49 | | // Return pixel colormap index array |
50 | | IndexPacket* indexes ( void ); |
51 | | |
52 | | // Left ordinate of view |
53 | | int x ( void ) const; |
54 | | |
55 | | // Top ordinate of view |
56 | | int y ( void ) const; |
57 | | |
58 | | // Width of view |
59 | | unsigned int columns ( void ) const; |
60 | | |
61 | | // Height of view |
62 | | unsigned int rows ( void ) const; |
63 | | |
64 | | #if 0 |
65 | | // Transfer one or more pixel components from a buffer or file |
66 | | // into the image pixel view of an image. Used to support image |
67 | | // decoders. |
68 | | void decode ( const QuantumType quantum_, |
69 | | const unsigned char *source_ ) |
70 | | { |
71 | | MagickLib::ReadPixelCache( _image.image(), quantum_, source_ ); |
72 | | } |
73 | | |
74 | | // Transfer one or more pixel components from the image pixel |
75 | | // view to a buffer or file. Used to support image encoders. |
76 | | void encode ( const QuantumType quantum_, |
77 | | const unsigned char *destination_ ) |
78 | | { |
79 | | MagickLib::WritePixelCache( _image.image(), quantum_, destination_ ); |
80 | | } |
81 | | #endif |
82 | | private: |
83 | | |
84 | | // Copying and assigning Pixels is not supported. |
85 | | Pixels( const Pixels& pixels_ ); |
86 | | const Pixels& operator=( const Pixels& pixels_ ); |
87 | | |
88 | | Magick::Image _image; // Image reference |
89 | | MagickLib::ViewInfo* _view; // Image view handle |
90 | | int _x; // Left ordinate of view |
91 | | int _y; // Top ordinate of view |
92 | | unsigned int _columns; // Width of view |
93 | | unsigned int _rows; // Height of view |
94 | | MagickLib:: ExceptionInfo _exception; // Any thrown exception |
95 | | |
96 | | }; // class Pixels |
97 | | |
98 | | } // Magick namespace |
99 | | |
100 | | // |
101 | | // Inline methods |
102 | | // |
103 | | |
104 | | // Left ordinate of view |
105 | | inline int Magick::Pixels::x ( void ) const |
106 | 0 | { |
107 | 0 | return _x; |
108 | 0 | } |
109 | | |
110 | | // Top ordinate of view |
111 | | inline int Magick::Pixels::y ( void ) const |
112 | 0 | { |
113 | 0 | return _y; |
114 | 0 | } |
115 | | |
116 | | // Width of view |
117 | | inline unsigned int Magick::Pixels::columns ( void ) const |
118 | 0 | { |
119 | 0 | return _columns; |
120 | 0 | } |
121 | | |
122 | | // Height of view |
123 | | inline unsigned int Magick::Pixels::rows ( void ) const |
124 | 0 | { |
125 | 0 | return _rows; |
126 | 0 | } |
127 | | |
128 | | #endif // Magick_Pixels_header |