Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

PixelIterator Class Reference

Inheritance diagram for PixelIterator:

Inheritance graph
[legend]
Collaboration diagram for PixelIterator:

Collaboration graph
[legend]

Detailed Description

Iterator over surface pixels.

Definition at line 14 of file PixelIterator.h.

Public Member Functions

 PixelIterator (SDL_Surface *surface)
 Creates new pixel iterator and locks the surface.
virtual ~PixelIterator ()
 Unlocks surface.
void setPos (const V2 &pos)
bool isValid () const
void inc ()
bool isTransparent () const
SDL_Color getColor () const
Uint32 getPixel () const
void putColor (const SDL_Color &color)
void putPixel (Uint32 pixel)


Constructor & Destructor Documentation

PixelIterator::PixelIterator SDL_Surface *  surface  ) 
 

Creates new pixel iterator and locks the surface.

Definition at line 20 of file PixelIterator.cpp.

00021 {
00022     m_surface = surface;
00023     m_lock = new SurfaceLock(m_surface);
00024     m_p = static_cast<Uint8*>(surface->pixels);
00025     m_end = m_p + m_surface->h * m_surface->pitch;
00026     m_bpp = surface->format->BytesPerPixel;
00027 }

PixelIterator::~PixelIterator  )  [virtual]
 

Unlocks surface.

Definition at line 32 of file PixelIterator.cpp.

00033 {
00034     delete m_lock;
00035 }


Member Function Documentation

SDL_Color PixelIterator::getColor  )  const
 

Definition at line 56 of file PixelIterator.cpp.

00057 {
00058     SDL_Color color;
00059     SDL_GetRGBA(getPixel(), m_surface->format,
00060             &color.r, &color.g, &color.b, &color.unused);
00061     return color;
00062 }

Uint32 PixelIterator::getPixel  )  const
 

Definition at line 65 of file PixelIterator.cpp.

00066 {
00067     return PixelTool::unpackPixel(m_bpp, m_p);
00068 }

void PixelIterator::inc  )  [inline]
 

Definition at line 26 of file PixelIterator.h.

00026 { m_p += m_bpp; }

bool PixelIterator::isTransparent  )  const
 

Definition at line 50 of file PixelIterator.cpp.

00051 {
00052     return getPixel() == m_surface->format->colorkey;
00053 }

bool PixelIterator::isValid  )  const [inline]
 

Definition at line 25 of file PixelIterator.h.

00025 { return m_p < m_end; }

void PixelIterator::putColor const SDL_Color &  color  ) 
 

Definition at line 71 of file PixelIterator.cpp.

00072 {
00073     Uint32 pixel = SDL_MapRGBA(m_surface->format,
00074             color.r, color.g, color.b, color.unused);
00075     putPixel(pixel);
00076 }

void PixelIterator::putPixel Uint32  pixel  ) 
 

Definition at line 79 of file PixelIterator.cpp.

00080 {
00081     PixelTool::packPixel(m_bpp, m_p, pixel);
00082 }

void PixelIterator::setPos const V2 pos  ) 
 

Definition at line 38 of file PixelIterator.cpp.

00039 {
00040     int x = pos.getX();
00041     int y = pos.getY();
00042     assert((0 <= x && x < m_surface->w) && (0 <= y && y < m_surface->h));
00043 
00044     m_p = static_cast<Uint8*>(m_surface->pixels) +
00045         y * m_surface->pitch +
00046         x * m_bpp;
00047 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:56:15 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2