]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/rawbmp.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPixelData
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
11 A class template with ready to use implementations for getting
12 direct and efficient access to wxBitmap's internal data and
13 wxImage's internal data through a standard interface. It is
14 possible to extend this class (interface) to other types of
17 Implemented on Windows, GTK+ and OS X:
18 @li wxNativePixelData: Class to access to wxBitmap's internal data
19 without alpha channel (RGB).
20 @li wxAlphaPixelData: Class to access to wxBitmap's internal data with
23 Implemented everywhere:
24 @li wxImagePixelData: Class to access to wxImage's internal data with
31 wxNativePixelData data(bmp);
34 // ... raw access to bitmap data unavailable, do something else ...
38 if ( data.GetWidth() < 20 || data.GetHeight() < 20 )
40 // ... complain: the bitmap it too small ...
44 wxNativePixelData::Iterator p(data);
46 // we draw a (10, 10)-(20, 20) rect manually using the given r, g, b
47 p.Offset(data, 10, 10);
49 for ( int y = 0; y < 10; ++y )
51 wxNativePixelData::Iterator rowStart = p;
53 for ( int x = 0; x < 10; ++x, ++p )
68 @see wxBitmap, wxImage
70 template <class Image
, class PixelFormat
= wxPixelFormatFor
<Image
> >
72 public wxPixelDataOut
<Image
>::template wxPixelDataIn
<PixelFormat
>
76 The type of the class we're working with.
78 typedef Image ImageType
;
81 Create pixel data object representing the entire image.
83 wxPixelData(Image
& image
);
87 Create pixel data object representing the area of the image defined by
90 wxPixelData(Image
& i
, const wxRect
& rect
);
93 Create pixel data object representing the area of the image defined by
96 wxPixelData(Image
& i
, const wxPoint
& pt
, const wxSize
& sz
);
99 Return @true of if we could get access to bitmap data successfully.
101 operator bool() const;
104 Return the iterator pointing to the origin of the image.
106 Iterator
GetPixels() const;
109 Returns origin of the rectangular region this wxPixelData represents.
111 wxPoint
GetOrigin() const;
114 Return width of the region this wxPixelData represents.
116 int GetWidth() const;
119 Return height of the region this wxPixelData represents.
121 int GetHeight() const;
124 Return the area which this wxPixelData represents in the image.
126 wxSize
GetSize() const;
129 Return the distance between two rows.
131 int GetRowStride() const;
135 The iterator of class wxPixelData.
142 Reset the iterator to point to (0, 0).
144 void Reset(const PixelData
& data
);
147 Initializes the iterator to point to the origin of the given pixel
150 Iterator(PixelData
& data
);
153 Initializes the iterator to point to the origin of the given Bitmap.
155 Iterator(wxBitmap
& bmp
, PixelData
& data
);
163 Return @true if this iterator is valid.
168 Advance the iterator to the next pixel, prefix version.
170 Iterator
& operator++();
173 Advance the iterator to the next pixel, postfix (hence less
174 efficient -- don't use it unless you absolutely must) version.
176 Iterator
operator++(int);
179 Move @a x pixels to the right and @a y down.
181 @note The rows won't wrap automatically.
183 void Offset(const PixelData
& data
, int x
, int y
);
186 Move @a x pixels to the right.
188 @note The rows won't wrap automatically.
190 void OffsetX(const PixelData
&data
, int x
);
193 Move @a y rows to the bottom
195 void OffsetY(const PixelData
& data
, int y
);
198 Go to the given position
200 void MoveTo(const PixelData
& data
, int x
, int y
);
204 Data Access: Access to individual colour components.
207 ChannelType
& Green();
209 ChannelType
& Alpha();