| Version: 3.0.2

- Main Page
- Related Pages
- Categories
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | List of all members
wxPixelData< Image, PixelFormat > Class Template Reference
Graphics Device Interface (GDI)

`#include <wx/rawbmp.h>`

Inheritance diagram for wxPixelData< Image, PixelFormat >:
[legend]

## Detailed Description

### template<class Image, class PixelFormat = wxPixelFormatFor<Image>>
class wxPixelData< Image, PixelFormat >

A class template with ready to use implementations for getting direct and efficient access to wxBitmap's internal data and wxImage's internal data through a standard interface.

It is possible to extend this class (interface) to other types of image content.

Implemented on Windows, GTK+ and OS X:

- wxNativePixelData: Class to access to wxBitmap's internal data without alpha channel (RGB).
- wxAlphaPixelData: Class to access to wxBitmap's internal data with alpha channel (RGBA).

Implemented everywhere:

- wxImagePixelData: Class to access to wxImage's internal data with alpha channel (RGBA).

Example:

wxBitmap bmp;
wxNativePixelData data(bmp);
if ( !data )
{
// ... raw access to bitmap data unavailable, do something else ...
return;
}
if ( data.GetWidth() < 20 || data.GetHeight() < 20 )
{
// ... complain: the bitmap it too small ...
return;
}
wxNativePixelData::Iterator p(data);
// we draw a (10, 10)-(20, 20) rect manually using the given r, g, b
p.Offset(data, 10, 10);
for ( int y = 0; y < 10; ++y )
{
wxNativePixelData::Iterator rowStart = p;
for ( int x = 0; x < 10; ++x, ++p )
{
p.Red() = r;
p.Green() = g;
p.Blue() = b;
}
p = rowStart;
p.OffsetY(data, 1);
}

##

Library: wxCore
Category: Graphics Device Interface (GDI)

See Also
  wxBitmap, wxImage

## Classes
class | Iterator
| The iterator of class wxPixelData. More...

## Public Types
typedef Image | ImageType
| The type of the class we're working with.

## Public Member Functions
| wxPixelData (Image &image)
| Create pixel data object representing the entire image.
| wxPixelData (Image &i, const wxRect &rect)
| Create pixel data object representing the area of the image defined by rect.
| wxPixelData (Image &i, const wxPoint &pt, const wxSize &sz)
| Create pixel data object representing the area of the image defined by pt and sz.
| operator bool () const
| Return true of if we could get access to bitmap data successfully.
Iterator | GetPixels () const
| Return the iterator pointing to the origin of the image.
wxPoint | GetOrigin () const
| Returns origin of the rectangular region this wxPixelData represents.
int | GetWidth () const
| Return width of the region this wxPixelData represents.
int | GetHeight () const
| Return height of the region this wxPixelData represents.
wxSize | GetSize () const
| Return the area which this wxPixelData represents in the image.
int | GetRowStride () const
| Return the distance between two rows.

## Member Typedef Documentation

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

typedef Image wxPixelData< Image, PixelFormat >::ImageType

The type of the class we're working with.

## Constructor & Destructor Documentation

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

wxPixelData< Image, PixelFormat >::wxPixelData | ( | Image & | image | ) |

Create pixel data object representing the entire image.

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

wxPixelData< Image, PixelFormat >::wxPixelData | ( | Image & | i,
|  | const wxRect & | rect
| ) |  |

Create pixel data object representing the area of the image defined by rect.

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

wxPixelData< Image, PixelFormat >::wxPixelData | ( | Image & | i,
|  | const wxPoint & | pt,
|  | const wxSize & | sz
| ) |  |

Create pixel data object representing the area of the image defined by pt and sz.

## Member Function Documentation

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

int wxPixelData< Image, PixelFormat >::GetHeight | ( |  | ) | const

Return height of the region this wxPixelData represents.

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

wxPoint wxPixelData< Image, PixelFormat >::GetOrigin | ( |  | ) | const

Returns origin of the rectangular region this wxPixelData represents.

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

Iterator wxPixelData< Image, PixelFormat >::GetPixels | ( |  | ) | const

Return the iterator pointing to the origin of the image.

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

int wxPixelData< Image, PixelFormat >::GetRowStride | ( |  | ) | const

Return the distance between two rows.

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

wxSize wxPixelData< Image, PixelFormat >::GetSize | ( |  | ) | const

Return the area which this wxPixelData represents in the image.

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

int wxPixelData< Image, PixelFormat >::GetWidth | ( |  | ) | const

Return width of the region this wxPixelData represents.

template<class Image , class PixelFormat = wxPixelFormatFor<Image>>

wxPixelData< Image, PixelFormat >::operator bool | ( |  | ) | const

Return true of if we could get access to bitmap data successfully.