]>
git.saurik.com Git - wxWidgets.git/blob - interface/rawbmp.h
6 A class template with ready to use implementations for getting
7 direct and efficient access to wxBitmap's internal data and
8 wxImage's internal data through a standard interface. It is
9 possible to extend this class (interface) to other types of
12 Implemented on Windows, GTK+ and OS X:
13 @li wxNativePixelData: Class to access to wxBitmap's internal data without alpha channel (RGB).
14 @li wxAlphaPixelData: Class to access to wxBitmap's internal data with alpha channel (RGBA).
16 Implemented everywhere:
17 @li wxImagePixelData: Class to access to wxImage's internal data with alpha channel (RGBA).
21 wxNativePixelData data(bmp);
24 // ... raw access to bitmap data unavailable, do something else ...
28 if ( data.GetWidth() < 20 || data.GetHeight() < 20 )
30 // ... complain: the bitmap it too small ...
34 wxNativePixelData::Iterator p(data);
36 // we draw a (10, 10)-(20, 20) rect manually using the given r, g, b
37 p.Offset(data, 10, 10);
39 for ( int y = 0; y < 10; ++y )
41 wxNativePixelData::Iterator rowStart = p;
43 for ( int x = 0; x < 10; ++x, ++p )
58 @see wxBitmap, wxImage
60 template <class Image
, class PixelFormat
= wxPixelFormatFor
<Image
> >
62 public wxPixelDataOut
<Image
>::template wxPixelDataIn
<PixelFormat
>
66 the type of the class we're working with
68 typedef Image ImageType
;
71 Create pixel data object representing the entire image
73 wxPixelData(Image
& image
);
77 Create pixel data object representing the area
78 of the image defined by @e rect.
80 wxPixelData(Image
& i
, const wxRect
& rect
);
83 Create pixel data object representing the area
84 of the image defined by @e pt and @e sz.
86 wxPixelData(Image
& i
, const wxPoint
& pt
, const wxSize
& sz
)
89 Return true of if we could get access to bitmap data
92 operator bool() const:
95 Return the iterator pointing to the origin of the image
97 Iterator
GetPixels() const;
100 Returns origin of the rectangular region we represent
102 wxPoint
GetOrigin() const;
105 Return width of the region we represent
107 int GetWidth() const;
110 Return height of the region we represent
112 int GetHeight() const;
115 Return area which this class represents in the image
117 wxSize
GetSize() const;
120 Return the distance between two rows
122 int GetRowStride() const;
134 void Reset(const PixelData
& data
);
137 Initializes the iterator to point to the origin of the given
140 Iterator(PixelData
& data
);
143 Initializes the iterator to point to the origin of the given
146 Iterator(wxBitmap
& bmp
, PixelData
& data
);
154 Return true if this iterator is valid
159 Advance the iterator to the next pixel, prefix version
161 Iterator
& operator++();
164 Postfix (hence less efficient -- don't use it unless you
165 absolutely must) version
167 Iterator
operator++(int);
170 Move x pixels to the right and y down
171 note that the rows don't wrap!
173 void Offset(const PixelData
& data
, int x
, int y
);
176 Move x pixels to the right (again, no row wrapping)
178 void OffsetX(const PixelData
&data
, int x
);
181 Move y rows to the bottom
183 void OffsetY(const PixelData
& data
, int y
);
186 Go to the given position
188 void MoveTo(const PixelData
& data
, int x
, int y
);
192 Data access: gives access to invidividual colour components.
195 ChannelType
& Green();
197 ChannelType
& Alpha();