]>
git.saurik.com Git - wxWidgets.git/blob - interface/rawbmp.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPixelData
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A class template with ready to use implementations for getting
14 direct and efficient access to wxBitmap's internal data and
15 wxImage's internal data through a standard interface. It is
16 possible to extend this class (interface) to other types of
19 Implemented on Windows, GTK+ and OS X:
20 @li wxNativePixelData: Class to access to wxBitmap's internal data
21 without alpha channel (RGB).
22 @li wxAlphaPixelData: Class to access to wxBitmap's internal data with
25 Implemented everywhere:
26 @li wxImagePixelData: Class to access to wxImage's internal data with
33 wxNativePixelData data(bmp);
36 // ... raw access to bitmap data unavailable, do something else ...
40 if ( data.GetWidth() < 20 || data.GetHeight() < 20 )
42 // ... complain: the bitmap it too small ...
46 wxNativePixelData::Iterator p(data);
48 // we draw a (10, 10)-(20, 20) rect manually using the given r, g, b
49 p.Offset(data, 10, 10);
51 for ( int y = 0; y < 10; ++y )
53 wxNativePixelData::Iterator rowStart = p;
55 for ( int x = 0; x < 10; ++x, ++p )
70 @see wxBitmap, wxImage
72 template <class Image
, class PixelFormat
= wxPixelFormatFor
<Image
> >
74 public wxPixelDataOut
<Image
>::template wxPixelDataIn
<PixelFormat
>
78 The type of the class we're working with.
80 typedef Image ImageType
;
83 Create pixel data object representing the entire image.
85 wxPixelData(Image
& image
);
89 Create pixel data object representing the area of the image defined by
92 wxPixelData(Image
& i
, const wxRect
& rect
);
95 Create pixel data object representing the area of the image defined by
98 wxPixelData(Image
& i
, const wxPoint
& pt
, const wxSize
& sz
)
101 Return @true of if we could get access to bitmap data successfully.
103 operator bool() const:
106 Return the iterator pointing to the origin of the image.
108 Iterator
GetPixels() const;
111 Returns origin of the rectangular region this wxPixelData represents.
113 wxPoint
GetOrigin() const;
116 Return width of the region this wxPixelData represents.
118 int GetWidth() const;
121 Return height of the region this wxPixelData represents.
123 int GetHeight() const;
126 Return the area which this wxPixelData represents in the image.
128 wxSize
GetSize() const;
131 Return the distance between two rows.
133 int GetRowStride() const;
137 The iterator of class wxPixelData.
144 Reset the iterator to point to (0, 0).
146 void Reset(const PixelData
& data
);
149 Initializes the iterator to point to the origin of the given pixel
152 Iterator(PixelData
& data
);
155 Initializes the iterator to point to the origin of the given Bitmap.
157 Iterator(wxBitmap
& bmp
, PixelData
& data
);
165 Return @true if this iterator is valid.
170 Advance the iterator to the next pixel, prefix version.
172 Iterator
& operator++();
175 Advance the iterator to the next pixel, postfix (hence less
176 efficient -- don't use it unless you absolutely must) version.
178 Iterator
operator++(int);
181 Move @a x pixels to the right and @a y down.
183 @note The rows won't wrap automatically.
185 void Offset(const PixelData
& data
, int x
, int y
);
188 Move @a x pixels to the right.
190 @note The rows won't wrap automatically.
192 void OffsetX(const PixelData
&data
, int x
);
195 Move @a y rows to the bottom
197 void OffsetY(const PixelData
& data
, int y
);
200 Go to the given position
202 void MoveTo(const PixelData
& data
, int x
, int y
);
206 Data Access: Access to invidividual colour components.
209 ChannelType
& Green();
211 ChannelType
& Alpha();