]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/rawbmp.h
a802ac29a61d84b75da7c7a68a2c1c6594bcfa5c
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPixelData
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 A class template with ready to use implementations for getting
13 direct and efficient access to wxBitmap's internal data and
14 wxImage's internal data through a standard interface. It is
15 possible to extend this class (interface) to other types of
18 Implemented on Windows, GTK+ and OS X:
19 @li wxNativePixelData: Class to access to wxBitmap's internal data
20 without alpha channel (RGB).
21 @li wxAlphaPixelData: Class to access to wxBitmap's internal data with
24 Implemented everywhere:
25 @li wxImagePixelData: Class to access to wxImage's internal data with
32 wxNativePixelData data(bmp);
35 // ... raw access to bitmap data unavailable, do something else ...
39 if ( data.GetWidth() < 20 || data.GetHeight() < 20 )
41 // ... complain: the bitmap it too small ...
45 wxNativePixelData::Iterator p(data);
47 // we draw a (10, 10)-(20, 20) rect manually using the given r, g, b
48 p.Offset(data, 10, 10);
50 for ( int y = 0; y < 10; ++y )
52 wxNativePixelData::Iterator rowStart = p;
54 for ( int x = 0; x < 10; ++x, ++p )
69 @see wxBitmap, wxImage
71 template <class Image
, class PixelFormat
= wxPixelFormatFor
<Image
> >
73 public wxPixelDataOut
<Image
>::template wxPixelDataIn
<PixelFormat
>
77 The type of the class we're working with.
79 typedef Image ImageType
;
82 Create pixel data object representing the entire image.
84 wxPixelData(Image
& image
);
88 Create pixel data object representing the area of the image defined by
91 wxPixelData(Image
& i
, const wxRect
& rect
);
94 Create pixel data object representing the area of the image defined by
97 wxPixelData(Image
& i
, const wxPoint
& pt
, const wxSize
& sz
);
100 Return @true of if we could get access to bitmap data successfully.
102 operator bool() const;
105 Return the iterator pointing to the origin of the image.
107 Iterator
GetPixels() const;
110 Returns origin of the rectangular region this wxPixelData represents.
112 wxPoint
GetOrigin() const;
115 Return width of the region this wxPixelData represents.
117 int GetWidth() const;
120 Return height of the region this wxPixelData represents.
122 int GetHeight() const;
125 Return the area which this wxPixelData represents in the image.
127 wxSize
GetSize() const;
130 Return the distance between two rows.
132 int GetRowStride() const;
136 The iterator of class wxPixelData.
143 Reset the iterator to point to (0, 0).
145 void Reset(const PixelData
& data
);
148 Initializes the iterator to point to the origin of the given pixel
151 Iterator(PixelData
& data
);
154 Initializes the iterator to point to the origin of the given Bitmap.
156 Iterator(wxBitmap
& bmp
, PixelData
& data
);
164 Return @true if this iterator is valid.
169 Advance the iterator to the next pixel, prefix version.
171 Iterator
& operator++();
174 Advance the iterator to the next pixel, postfix (hence less
175 efficient -- don't use it unless you absolutely must) version.
177 Iterator
operator++(int);
180 Move @a x pixels to the right and @a y down.
182 @note The rows won't wrap automatically.
184 void Offset(const PixelData
& data
, int x
, int y
);
187 Move @a x pixels to the right.
189 @note The rows won't wrap automatically.
191 void OffsetX(const PixelData
&data
, int x
);
194 Move @a y rows to the bottom
196 void OffsetY(const PixelData
& data
, int y
);
199 Go to the given position
201 void MoveTo(const PixelData
& data
, int x
, int y
);
205 Data Access: Access to invidividual colour components.
208 ChannelType
& Green();
210 ChannelType
& Alpha();