In file uta/programmer.doc:

namespace uta class Surface


Inheritance:


Public Fields

friend class Painter
friend class Application
friend class DirectSurface

Public Methods

Surface()
create an empty surface
Surface(unsigned w, unsigned h, int pixelformat=Pixelformat::ABGR8888)
Surface(const Surface& surf)
Surface(void* pixels, unsigned w, unsigned h, unsigned pitch, int pixelformat)
Create a surface with the given pixel data
Surface* createChildSurface(const Rect& rect)
Create a child surface
bool readFromXPM(char** data)
Read from included XPM
bool readFromHeader(char* header_data, unsigned w, unsigned h)
Read from included gimp header file
bool readFromFile(const std::string&)
Load surface from a PNG or BMP file.
bool load(const std::string& filename)
Load surface from a PNG or BMP file
bool writeToFile(const std::string&)
Write surface to a png formatted file.
bool write(const std::string& filename)
Write surface to a png formatted file
Surface& operator = (const Surface& surf)
void setPalette(const std::vector<Color>& pal)
Change palette of this surface
bool empty() const
check for existing pixeldata
virtual int width() const
virtual int height() const
virtual int pitch() const
return surface pitch
const Pixelformat& pixelformat() const
return pixelformat of this surface
virtual bool convert(const Pixelformat& pixelformat, bool dither = true)
Convert surface into given pixelformat
bool mirror()
mirror this surface horizontally
bool scale(int new_width, int new_height)
scale this surface to the new size
bool scale(float n)
scale this surface by given factor
void setTransparency(bool transp)
enable transparent blits
void setTransColor(const Color& color)
set transparent color (enables transparent blits)
const Color& transparentColor() const
void setAlpha(unsigned char alpha)
set alpha in procent (0..100)
bool usesTransparency() const
bool hasAlphaChannel() const
check if surface contains an alpha channel
void useRLEAcceleration(bool flag)
virtual Rect blit(Surface*) const
virtual Rect blit(Surface*, const Rect& dest) const
virtual Rect blit(Surface*, const Rect& dest, const Rect& src) const
virtual Rect scaledBlit(Surface*) const
virtual Rect scaledBlit(Surface*, const Rect& dest) const
virtual Rect scaledBlit(Surface*, const Rect& dest, const Rect& src) const
virtual Rect textureBlit(Surface*, const Point&, const Point&, const Point&, const Point&) const
virtual Rect textureBlit(Surface*, const Point&, const Point&, const Point&, const Point&, const Rect& src) const
void clear()
clear surface to background color
void clear(const Rect& r)
clear given rect
void fill(const Color&)
fill whole surface with the given color
void fill(const Rect&, const Color&)
fill the given area
void* pixels()
this allows pixelaccess
const void* pixels() const
this allows pixelaccess
virtual void lock() const
lock pixel data for direct access
virtual void unlock() const
unlock pixel data

Protected Fields

Pixelformat format
SDL_Surface* sdlSurface_
Color transCol_
bool transparent_
unsigned char alpha_
bool RLEAccelerated_

Protected Methods

void clearSurfaceData()
delete surface data
void writePixel(Uint32 pixeladdr, Uint32 pixel)
pixel address in bytes
Uint32 readPixel(Uint32 pixeladdr)
pixel address in bytes
void applyPalette()
apply Surface's palette to the surface data
void gatherPalette()
extract palette (if any) from the surface data

Documentation

friend class Painter

friend class Application

friend class DirectSurface

Surface()
create an empty surface

Surface(unsigned w, unsigned h, int pixelformat=Pixelformat::ABGR8888)

Surface(const Surface& surf)

Surface(void* pixels, unsigned w, unsigned h, unsigned pitch, int pixelformat)
Create a surface with the given pixel data. The pixels are _not_ copied ! This uses interally SDL_CreateRGBSurfaceFrom(..). When this surface gets deleted, the pixel data gets not freed, because it is not owned by this surface.

Surface* createChildSurface(const Rect& rect)
Create a child surface. This is a dangerous feature ... the created surface is only valid as long as the parent surface is alive. If you delete the parent surface and after that access the child surface bad things might happen ! Deleting the child surface after the parent surface is ok, though. ( ... I guess I need to add reference counting ...)

bool readFromXPM(char** data)
Read from included XPM. Use include "image.xpm" to compile images into your binaries.You may then construct your surface by surface.readFromXPM(image_xpm).

bool readFromHeader(char* header_data, unsigned w, unsigned h)
Read from included gimp header file. This is the alternative to readFromXPM; it uses header files generated by GIMP.

bool readFromFile(const std::string&)
Load surface from a PNG or BMP file.

bool load(const std::string& filename)
Load surface from a PNG or BMP file

bool writeToFile(const std::string&)
Write surface to a png formatted file.

bool write(const std::string& filename)
Write surface to a png formatted file

Surface& operator = (const Surface& surf)

void setPalette(const std::vector<Color>& pal)
Change palette of this surface. This does not change the pixel data !

bool empty() const
check for existing pixeldata. An empty surface results from an unsuccessfull file read for example.

virtual int width() const

virtual int height() const

virtual int pitch() const
return surface pitch

const Pixelformat& pixelformat() const
return pixelformat of this surface

virtual bool convert(const Pixelformat& pixelformat, bool dither = true)
Convert surface into given pixelformat. Since version 0.3.37 a instance of Pixelformat is passed; by this the palette of the target format can be set ! Per default floyd-steinberg dithering is used.

bool mirror()
mirror this surface horizontally

bool scale(int new_width, int new_height)
scale this surface to the new size

bool scale(float n)
scale this surface by given factor

void setTransparency(bool transp)
enable transparent blits

void setTransColor(const Color& color)
set transparent color (enables transparent blits)

const Color& transparentColor() const

void setAlpha(unsigned char alpha)
set alpha in procent (0..100)

bool usesTransparency() const

bool hasAlphaChannel() const
check if surface contains an alpha channel

void useRLEAcceleration(bool flag)

virtual Rect blit(Surface*) const

virtual Rect blit(Surface*, const Rect& dest) const

virtual Rect blit(Surface*, const Rect& dest, const Rect& src) const

virtual Rect scaledBlit(Surface*) const

virtual Rect scaledBlit(Surface*, const Rect& dest) const

virtual Rect scaledBlit(Surface*, const Rect& dest, const Rect& src) const

virtual Rect textureBlit(Surface*, const Point&, const Point&, const Point&, const Point&) const

virtual Rect textureBlit(Surface*, const Point&, const Point&, const Point&, const Point&, const Rect& src) const

void clear()
clear surface to background color

void clear(const Rect& r)
clear given rect

void fill(const Color&)
fill whole surface with the given color

void fill(const Rect&, const Color&)
fill the given area

void* pixels()
this allows pixelaccess.... you should know what you do here. pixels accesses should be enclosed in lock()/unlock() pairs

const void* pixels() const
this allows pixelaccess.... you should know what you do here. pixels accesses should be enclosed in lock()/unlock() pairs

virtual void lock() const
lock pixel data for direct access. This is also need for pure read access, so it seems acceptable to make lock() a const method.

virtual void unlock() const
unlock pixel data. Never forget to call this after a lock(), otherwise the application might run into a deadlock.

void clearSurfaceData()
delete surface data

Pixelformat format

SDL_Surface* sdlSurface_

Color transCol_

bool transparent_

unsigned char alpha_

void writePixel(Uint32 pixeladdr, Uint32 pixel)
pixel address in bytes

Uint32 readPixel(Uint32 pixeladdr)
pixel address in bytes

void applyPalette()
apply Surface's palette to the surface data

void gatherPalette()
extract palette (if any) from the surface data

bool RLEAccelerated_


Direct child classes:
ScreenSurface
DirectSurface

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de