_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Classes | Public Member Functions | Public Attributes | Protected Member Functions | Friends | List of all members
CGraphic Class Reference

#include <video.h>

Inheritance diagram for CGraphic:
gcn::Image CPlayerColorGraphic

Classes

struct  frame_pos_t
 

Public Member Functions

bool IsLoaded (bool flipped=false) const
 
virtual void_getData () const
 
virtual int getWidth () const
 
virtual int getHeight () const
 
- Public Member Functions inherited from gcn::Image
 Image (void *data, int width, int height)
 
 Image (const std::string &filename)
 
virtual ~Image ()
 
virtual bool isDirty () const
 

Public Attributes

std::string File
 
std::string HashFile
 Filename. More...
 
SDL_Surface * Surface
 Filename used in hash. More...
 
SDL_Surface * SurfaceFlip
 Surface. More...
 
frame_pos_tframe_map
 Flipped surface. More...
 
frame_pos_tframeFlip_map
 
int Width
 
int Height
 Width of a frame. More...
 
int NumFrames
 Height of a frame. More...
 
int GraphicWidth
 Number of frames. More...
 
int GraphicHeight
 Original graphic width. More...
 
int Refs
 Original graphic height. More...
 
bool Resized
 Uses of this graphic. More...
 

Protected Member Functions

 CGraphic ()
 
 ~CGraphic ()
 
- Protected Member Functions inherited from gcn::Image
 Image ()
 

Friends

class CFont
 Image has been resized. More...
 

graphic.cpp - The general graphic functions.

void DrawClip (int x, int y, SDL_Surface *surface=TheScreen) const
 
void DrawSub (int gx, int gy, int w, int h, int x, int y, SDL_Surface *surface=TheScreen) const
 
void DrawSubCustomMod (int gx, int gy, int w, int h, int x, int y, pixelModifier modifier, const uint32_t param, SDL_Surface *surface=TheScreen) const
 
void DrawSubClip (int gx, int gy, int w, int h, int x, int y, SDL_Surface *surface=TheScreen) const
 
void DrawSubTrans (int gx, int gy, int w, int h, int x, int y, unsigned char alpha, SDL_Surface *surface=TheScreen) const
 
void DrawSubClipTrans (int gx, int gy, int w, int h, int x, int y, unsigned char alpha, SDL_Surface *surface=TheScreen) const
 
void DrawSubClipCustomMod (int gx, int gy, int w, int h, int x, int y, pixelModifier modifier, const uint32_t param, SDL_Surface *surface=TheScreen) const
 
void DrawFrame (unsigned frame, int x, int y, SDL_Surface *surface=TheScreen) const
 
void DrawFrameClip (unsigned frame, int x, int y, SDL_Surface *surface=TheScreen) const
 
void DrawFrameTrans (unsigned frame, int x, int y, int alpha, SDL_Surface *surface=TheScreen) const
 
void DrawFrameClipTrans (unsigned frame, int x, int y, int alpha, SDL_Surface *surface=TheScreen) const
 
void DrawFrameClipCustomMod (unsigned frame, int x, int y, pixelModifier modifier, const uint32_t param, SDL_Surface *surface=TheScreen) const
 
void DrawFrameX (unsigned frame, int x, int y, SDL_Surface *surface=TheScreen) const
 
void DrawFrameClipX (unsigned frame, int x, int y, SDL_Surface *surface=TheScreen) const
 
void DrawFrameTransX (unsigned frame, int x, int y, int alpha, SDL_Surface *surface=TheScreen) const
 
void DrawFrameClipTransX (unsigned frame, int x, int y, int alpha, SDL_Surface *surface=TheScreen) const
 
void Load (bool grayscale=false)
 
void Flip ()
 
void Resize (int w, int h)
 
void SetOriginalSize ()
 
bool TransparentPixel (int x, int y)
 
void SetPaletteColor (int idx, int r, int g, int b)
 
void MakeShadow (int xOffset, int yOffset)
 
void OverlayGraphic (CGraphic *other, bool mask=false)
 
void GenFramesMap ()
 
static CGraphicNew (const std::string &file, int w=0, int h=0)
 
static CGraphicForceNew (const std::string &file, int w=0, int h=0)
 
static CGraphicGet (const std::string &file)
 
static void Free (CGraphic *g)
 

Additional Inherited Members

- Static Public Member Functions inherited from gcn::Image
static ImageLoader_getImageLoader ()
 
static void setImageLoader (ImageLoader *imageLoader)
 
- Protected Attributes inherited from gcn::Image
voidmData
 
int mWidth
 
int mHeight
 
bool mLoadedWithImageLoader
 
- Static Protected Attributes inherited from gcn::Image
static ImageLoadermImageLoader = NULL
 

Constructor & Destructor Documentation

◆ CGraphic()

CGraphic::CGraphic ( )
inlineprotected

◆ ~CGraphic()

CGraphic::~CGraphic ( )
inlineprotected

Member Function Documentation

◆ _getData()

virtual void* CGraphic::_getData ( ) const
inlinevirtual

Gets the data of the Image. Image data can be different things depending on what ImageLoader you use. If you for instance use the SDLImageLoader then an SDL_Surface will be returned.

Returns
a void pointer to the Image data.
See also
SDLImageLoader, AllegroImageLoader

Reimplemented from gcn::Image.

◆ DrawClip()

void CGraphic::DrawClip ( int  x,
int  y,
SDL_Surface *  surface = TheScreen 
) const

Video draw the graphic clipped.

Parameters
xX position on the target surface
yY position on the target surface
surfacetarget surface

◆ DrawFrame()

void CGraphic::DrawFrame ( unsigned  frame,
int  x,
int  y,
SDL_Surface *  surface = TheScreen 
) const

Draw graphic object unclipped.

Parameters
framenumber of frame (object index)
xx coordinate on the target surface
yy coordinate on the target surface
surfacetarget surface

◆ DrawFrameClip()

void CGraphic::DrawFrameClip ( unsigned  frame,
int  x,
int  y,
SDL_Surface *  surface = TheScreen 
) const

Draw graphic object clipped.

Parameters
framenumber of frame (object index)
xx coordinate on the target surface
yy coordinate on the target surface
surfacetarget surface

◆ DrawFrameClipCustomMod()

void CGraphic::DrawFrameClipCustomMod ( unsigned  frame,
int  x,
int  y,
pixelModifier  modifier,
const uint32_t  param,
SDL_Surface *  surface = TheScreen 
) const

◆ DrawFrameClipTrans()

void CGraphic::DrawFrameClipTrans ( unsigned  frame,
int  x,
int  y,
int  alpha,
SDL_Surface *  surface = TheScreen 
) const

◆ DrawFrameClipTransX()

void CGraphic::DrawFrameClipTransX ( unsigned  frame,
int  x,
int  y,
int  alpha,
SDL_Surface *  surface = TheScreen 
) const

◆ DrawFrameClipX()

void CGraphic::DrawFrameClipX ( unsigned  frame,
int  x,
int  y,
SDL_Surface *  surface = TheScreen 
) const

Draw graphic object clipped and flipped in X direction.

Parameters
framenumber of frame (object index)
xx coordinate on the target surface
yy coordinate on the target surface
surfacetarget surface

◆ DrawFrameTrans()

void CGraphic::DrawFrameTrans ( unsigned  frame,
int  x,
int  y,
int  alpha,
SDL_Surface *  surface = TheScreen 
) const

◆ DrawFrameTransX()

void CGraphic::DrawFrameTransX ( unsigned  frame,
int  x,
int  y,
int  alpha,
SDL_Surface *  surface = TheScreen 
) const

◆ DrawFrameX()

void CGraphic::DrawFrameX ( unsigned  frame,
int  x,
int  y,
SDL_Surface *  surface = TheScreen 
) const

Draw graphic object unclipped and flipped in X direction.

Parameters
framenumber of frame (object index)
xx coordinate on the target surface
yy coordinate on the target surface
surfacetarget surface

◆ DrawSub()

void CGraphic::DrawSub ( int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
SDL_Surface *  surface = TheScreen 
) const

Video draw part of graphic.

Parameters
gxX offset into object
gyY offset into object
wwidth to display
hheight to display
xX position on the target surface
yY position on the target surface
surfacetarget surface

◆ DrawSubClip()

void CGraphic::DrawSubClip ( int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
SDL_Surface *  surface = TheScreen 
) const

Video draw part of graphic clipped.

Parameters
gxX offset into object
gyY offset into object
wwidth to display
hheight to display
xX position on the target surface
yY position on the target surface
surfacetarget surface

◆ DrawSubClipCustomMod()

void CGraphic::DrawSubClipCustomMod ( int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
pixelModifier  modifier,
const uint32_t  param,
SDL_Surface *  surface = TheScreen 
) const

Video draw clipped part of graphic by custom pixel modifier. 32bpp only (yet?)

Parameters
gxX offset into object
gyY offset into object
wwidth to display
hheight to display
xX position on the target surface
yY position on the target surface
modifiermethod used to draw pixels instead of SDL_BlitSurface
paramparameter for modifier
surfacetarget surface

◆ DrawSubClipTrans()

void CGraphic::DrawSubClipTrans ( int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
unsigned char  alpha,
SDL_Surface *  surface = TheScreen 
) const

Video draw part of graphic with alpha and clipped.

Parameters
gxX offset into object
gyY offset into object
wwidth to display
hheight to display
xX position on the target surface
yY position on the target surface
alphaAlpha
surfacetarget surface

◆ DrawSubCustomMod()

void CGraphic::DrawSubCustomMod ( int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
pixelModifier  modifier,
const uint32_t  param,
SDL_Surface *  surface = TheScreen 
) const

Video draw part of graphic by custom pixel modifier. 32bpp only (yet?)

Parameters
gxX offset into object
gyY offset into object
wwidth to display
hheight to display
xX position on the target surface
yY position on the target surface
modifiermethod used to draw pixels instead of SDL_BlitSurface
paramparameter for modifier
surfacetarget surface

◆ DrawSubTrans()

void CGraphic::DrawSubTrans ( int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
unsigned char  alpha,
SDL_Surface *  surface = TheScreen 
) const

Video draw part of graphic with alpha.

Parameters
gxX offset into object
gyY offset into object
wwidth to display
hheight to display
xX position on the target surface
yY position on the target surface
alphaAlpha
surfacetarget surface

◆ Flip()

void CGraphic::Flip ( )

Flip graphic and store in graphic->SurfaceFlip

◆ ForceNew()

CGraphic * CGraphic::ForceNew ( const std::string &  file,
int  w = 0,
int  h = 0 
)
static

Make a new graphic object. Don't reuse a graphic from the hash table.

Parameters
fileFilename
wWidth of a frame (optional)
hHeight of a frame (optional)
Returns
New graphic object

◆ Free()

void CGraphic::Free ( CGraphic g)
static

Free a graphic

Parameters
gPointer to the graphic

◆ GenFramesMap()

void CGraphic::GenFramesMap ( )

◆ Get()

CGraphic * CGraphic::Get ( const std::string &  filename)
static

Get a graphic object.

Parameters
filenameFilename
Returns
Graphic object

◆ getHeight()

virtual int CGraphic::getHeight ( ) const
inlinevirtual

Gets the height of the Image.

Returns
the image height

Reimplemented from gcn::Image.

◆ getWidth()

virtual int CGraphic::getWidth ( ) const
inlinevirtual

Gets the width of the Image.

Returns
the image width

Reimplemented from gcn::Image.

◆ IsLoaded()

bool CGraphic::IsLoaded ( bool  flipped = false) const
inline

◆ Load()

void CGraphic::Load ( bool  grayscale = false)

Load a graphic

Parameters
grayscaleMake a grayscale surface

◆ MakeShadow()

void CGraphic::MakeShadow ( int  xOffset,
int  yOffset 
)

Make shadow sprite

Todo:
FIXME: 32bpp

◆ New()

CGraphic * CGraphic::New ( const std::string &  filename,
int  w = 0,
int  h = 0 
)
static

Make a new graphic object.

Parameters
filenameFilename
wWidth of a frame (optional)
hHeight of a frame (optional)
Returns
New graphic object

◆ OverlayGraphic()

void CGraphic::OverlayGraphic ( CGraphic other,
bool  mask = false 
)

◆ Resize()

void CGraphic::Resize ( int  w,
int  h 
)

Resize a graphic

Parameters
wNew width of graphic.
hNew height of graphic.

◆ SetOriginalSize()

void CGraphic::SetOriginalSize ( )

Sets the original size for a graphic

◆ SetPaletteColor()

void CGraphic::SetPaletteColor ( int  idx,
int  r,
int  g,
int  b 
)

Change a palette color.

◆ TransparentPixel()

bool CGraphic::TransparentPixel ( int  x,
int  y 
)

Check if a pixel is transparent

Parameters
xX coordinate
yY coordinate
Returns
True if the pixel is transparent, False otherwise

Friends And Related Function Documentation

◆ CFont

friend class CFont
friend

Image has been resized.

Member Data Documentation

◆ File

std::string CGraphic::File

◆ frame_map

frame_pos_t* CGraphic::frame_map

Flipped surface.

◆ frameFlip_map

frame_pos_t* CGraphic::frameFlip_map

◆ GraphicHeight

int CGraphic::GraphicHeight

Original graphic width.

◆ GraphicWidth

int CGraphic::GraphicWidth

Number of frames.

◆ HashFile

std::string CGraphic::HashFile

Filename.

◆ Height

int CGraphic::Height

Width of a frame.

◆ NumFrames

int CGraphic::NumFrames

Height of a frame.

◆ Refs

int CGraphic::Refs

Original graphic height.

◆ Resized

bool CGraphic::Resized

Uses of this graphic.

◆ Surface

SDL_Surface* CGraphic::Surface

Filename used in hash.

◆ SurfaceFlip

SDL_Surface* CGraphic::SurfaceFlip

Surface.

◆ Width

int CGraphic::Width

The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.