ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Graphics::Surface Struct Reference

An arbitrary graphics surface, which can be the target (or source) of blit operations, font rendering, etc. More...

#include <surface.h>

Inheritance diagram for Graphics::Surface:
Collaboration diagram for Graphics::Surface:

List of all members.

Public Member Functions

 Surface ()
 Construct a simple Surface object.
const void * getPixels () const
 Return a pointer to the pixel data.
void * getPixels ()
 Return a pointer to the pixel data.
void setPixels (void *newPixels)
 Sets the pixel data.
const void * getBasePtr (int x, int y) const
 Return a pointer to the pixel at the specified point.
void * getBasePtr (int x, int y)
 Return a pointer to the pixel at the specified point.
void create (uint16 width, uint16 height, const PixelFormat &format)
 Allocate memory for the pixel data of the surface.
void free ()
 Release the memory used by the pixels memory of this surface.
void init (uint16 width, uint16 height, uint16 pitch, void *pixels, const PixelFormat &format)
 Set up the Surface with user specified data.
void copyFrom (const Surface &surf)
 Copy the data from another Surface.
Surface getSubArea (const Common::Rect &area)
 Creates a Surface which represents a sub-area of this Surface object.
const Surface getSubArea (const Common::Rect &area) const
 Creates a Surface which represents a sub-area of this Surface object.
void copyRectToSurface (const void *buffer, int srcPitch, int destX, int destY, int width, int height)
 Copies a bitmap to the Surface internal buffer.
void copyRectToSurface (const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect)
 Copies a bitmap to the Surface internal buffer.
void convertToInPlace (const PixelFormat &dstFormat, const byte *palette=0)
 Convert the data to another pixel format.
Graphics::SurfaceconvertTo (const PixelFormat &dstFormat, const byte *palette=0) const
 Convert the data to another pixel format.
void drawLine (int x0, int y0, int x1, int y1, uint32 color)
 Draw a line.
void drawThickLine (int x0, int y0, int x1, int y1, int penX, int penY, uint32 color)
 Draw a thick line.
void hLine (int x, int y, int x2, uint32 color)
 Draw a horizontal line.
void vLine (int x, int y, int y2, uint32 color)
 Draw a vertical line.
void fillRect (Common::Rect r, uint32 color)
 Fill a rect with a given color.
void frameRect (const Common::Rect &r, uint32 color)
 Draw a frame around a specified rect.
void move (int dx, int dy, int height)

Public Attributes

uint16 w
 The width of the surface.
uint16 h
 The height of the surface.
uint16 pitch
 The number of bytes a pixel line has.
PixelFormat format
 The pixel format of the surface.

Protected Attributes

void * pixels
 The surface's pixel data.

Detailed Description

An arbitrary graphics surface, which can be the target (or source) of blit operations, font rendering, etc.

Definition at line 42 of file surface.h.


Constructor & Destructor Documentation

Graphics::Surface::Surface (  )  [inline]

Construct a simple Surface object.

Definition at line 82 of file surface.h.


Member Function Documentation

Graphics::Surface * Graphics::Surface::convertTo ( const PixelFormat dstFormat,
const byte palette = 0 
) const

Convert the data to another pixel format.

The calling code must call free on the returned surface and then delete it.

Parameters:
dstFormat The desired format
palette The palette (in RGB888), if the source format has a Bpp of 1

Reimplemented in Graphics::TransparentSurface.

Definition at line 423 of file surface.cpp.

void Graphics::Surface::convertToInPlace ( const PixelFormat dstFormat,
const byte palette = 0 
)

Convert the data to another pixel format.

This works in-place. This means it will not create an additional buffer for the conversion process. The value of 'pixels' might change though (that means it might realloc the pixel data).

Note that you should only use this, when you created the Surface data via create! Otherwise this function has undefined behavior.

Parameters:
dstFormat The desired format
palette The palette (in RGB888), if the source format has a Bpp of 1

Definition at line 357 of file surface.cpp.

void Graphics::Surface::copyFrom ( const Surface surf  ) 

Copy the data from another Surface.

Note that this calls free on the current surface, to assure it being clean. So be sure the current data was created via create, otherwise the results are undefined.

See also:
create
free
Parameters:
surf Surface to copy from.

Definition at line 94 of file surface.cpp.

void Graphics::Surface::copyRectToSurface ( const Graphics::Surface srcSurface,
int  destX,
int  destY,
const Common::Rect  subRect 
)

Copies a bitmap to the Surface internal buffer.

The pixel format of buffer must match the pixel format of the Surface.

Parameters:
srcSurface The source of the bitmap data
destX The x coordinate of the destination rectangle
destY The y coordinate of the destination rectangle
subRect The subRect of surface to be blitted

Definition at line 155 of file surface.cpp.

void Graphics::Surface::copyRectToSurface ( const void *  buffer,
int  srcPitch,
int  destX,
int  destY,
int  width,
int  height 
)

Copies a bitmap to the Surface internal buffer.

The pixel format of buffer must match the pixel format of the Surface.

Parameters:
buffer The buffer containing the graphics data source
srcPitch The pitch of the buffer (number of bytes in a scanline)
destX The x coordinate of the destination rectangle
destY The y coordinate of the destination rectangle
width The width of the destination rectangle
height The height of the destination rectangle

Definition at line 137 of file surface.cpp.

void Graphics::Surface::create ( uint16  width,
uint16  height,
const PixelFormat format 
)

Allocate memory for the pixel data of the surface.

Note that you are responsible for calling free yourself.

See also:
free
Parameters:
width Width of the surface object.
height Height of the surface object.
format The pixel format the surface should use.

Definition at line 65 of file surface.cpp.

void Graphics::Surface::drawLine ( int  x0,
int  y0,
int  x1,
int  y1,
uint32  color 
)

Draw a line.

Parameters:
x0 The x coordinate of the start point.
y0 The y coordiante of the start point.
x1 The x coordinate of the end point.
y1 The y coordinate of the end point.
color The color of the line.
Note:
This is just a wrapper around Graphics::drawLine

Definition at line 43 of file surface.cpp.

void Graphics::Surface::drawThickLine ( int  x0,
int  y0,
int  x1,
int  y1,
int  penX,
int  penY,
uint32  color 
)

Draw a thick line.

Parameters:
x0 The x coordinate of the start point.
y0 The y coordiante of the start point.
x1 The x coordinate of the end point.
y1 The y coordinate of the end point.
penX The width of the pen (thickness in the x direction)
penY The height of the pen (thickness in the y direction)
color The color of the line.
Note:
This is just a wrapper around Graphics::drawThickLine
The x/y coordinates of the start and end points are the upper-left most part of the pen

Definition at line 54 of file surface.cpp.

void Graphics::Surface::fillRect ( Common::Rect  r,
uint32  color 
)

Fill a rect with a given color.

Parameters:
r Rect to fill
color The color of the rect's contents.

Definition at line 228 of file surface.cpp.

void Graphics::Surface::frameRect ( const Common::Rect r,
uint32  color 
)

Draw a frame around a specified rect.

Parameters:
r Rect to frame
color The color of the frame.

Definition at line 272 of file surface.cpp.

void Graphics::Surface::free (  ) 

Release the memory used by the pixels memory of this surface.

This is the counterpart to create().

Note that you should only use this, when you created the Surface data via create! Otherwise this function has undefined behavior.

See also:
create

Definition at line 79 of file surface.cpp.

void* Graphics::Surface::getBasePtr ( int  x,
int  y 
) [inline]

Return a pointer to the pixel at the specified point.

Parameters:
x The x coordinate of the pixel.
y The y coordinate of the pixel.
Returns:
Pointer to the pixel.

Definition at line 130 of file surface.h.

const void* Graphics::Surface::getBasePtr ( int  x,
int  y 
) const [inline]

Return a pointer to the pixel at the specified point.

Parameters:
x The x coordinate of the pixel.
y The y coordinate of the pixel.
Returns:
Pointer to the pixel.

Definition at line 119 of file surface.h.

void* Graphics::Surface::getPixels (  )  [inline]

Return a pointer to the pixel data.

Returns:
Pointer to the pixel data.

Definition at line 99 of file surface.h.

const void* Graphics::Surface::getPixels (  )  const [inline]

Return a pointer to the pixel data.

Returns:
Pointer to the pixel data.

Definition at line 90 of file surface.h.

Surface Graphics::Surface::getSubArea ( const Common::Rect area  ) 

Creates a Surface which represents a sub-area of this Surface object.

The pixel (0, 0) of the returned Surface will be the same as Pixel (area.x, area.y) of this Surface. Changes to any of the Surface objects will change the shared pixel data.

Note that the Surface returned is only valid as long as this Surface object is still alive (i.e. its pixel data is not destroyed or reallocated). Do *never* try to free the returned Surface.

Parameters:
area The area which should be represented. Note that the area will get clipped in case it does not fit!

Definition at line 109 of file surface.cpp.

const Surface Graphics::Surface::getSubArea ( const Common::Rect area  )  const

Creates a Surface which represents a sub-area of this Surface object.

The pixel (0, 0) of the returned Surface will be the same as Pixel (area.x, area.y) of this Surface.

Note that the Surface returned is only valid as long as this Surface object is still alive (i.e. its pixel data is not destroyed or reallocated). Do *never* try to free the returned Surface.

Parameters:
area The area which should be represented. Note that the area will get clipped in case it does not fit!

Definition at line 122 of file surface.cpp.

void Graphics::Surface::hLine ( int  x,
int  y,
int  x2,
uint32  color 
)

Draw a horizontal line.

Parameters:
x The start x coordinate of the line.
y The y coordiante of the line.
x2 The end x coordinate of the line. In case x > x2 the coordinates are swapped.
color The color of the line.

Definition at line 161 of file surface.cpp.

void Graphics::Surface::init ( uint16  width,
uint16  height,
uint16  pitch,
void *  pixels,
const PixelFormat format 
)

Set up the Surface with user specified data.

Note that this simply sets the 'internal' attributes of the Surface. It will not take care of freeing old data via free or similar!

Parameters:
width Width of the pixel data.
height Height of the pixel data.
pitch The pitch of the pixel data.
pixels The pixel data itself.
format The pixel format of the pixel data.

Definition at line 86 of file surface.cpp.

void Graphics::Surface::move ( int  dx,
int  dy,
int  height 
)

Definition at line 279 of file surface.cpp.

void Graphics::Surface::setPixels ( void *  newPixels  )  [inline]

Sets the pixel data.

Note that this is a simply a setter. Be careful what you are doing!

Parameters:
newPixels The new pixel data.

Definition at line 110 of file surface.h.

void Graphics::Surface::vLine ( int  x,
int  y,
int  y2,
uint32  color 
)

Draw a vertical line.

Parameters:
x The x coordinate of the line.
y The start y coordiante of the line.
y2 The end y coordinate of the line. In case y > y2 the coordinates are swapped.
color The color of the line.

Definition at line 191 of file surface.cpp.


Member Data Documentation

The pixel format of the surface.

Definition at line 77 of file surface.h.

The height of the surface.

Definition at line 58 of file surface.h.

The number of bytes a pixel line has.

Note that this might not equal w * bytesPerPixel.

Definition at line 65 of file surface.h.

void* Graphics::Surface::pixels [protected]

The surface's pixel data.

Definition at line 71 of file surface.h.

The width of the surface.

Definition at line 53 of file surface.h.


The documentation for this struct was generated from the following files:


Generated on Sat Sep 14 2019 05:04:13 for ResidualVM by doxygen 1.7.1
curved edge   curved edge