AgateLib.ImplementationBase.SurfaceImpl Class Reference

Base class for implementing a Surface structure. More...

Inheritance diagram for AgateLib.ImplementationBase.SurfaceImpl:

AgateLib.ImplementationBase.IRenderTargetImpl

List of all members.

Public Member Functions

 SurfaceImpl ()
 Constructs a SurfaceImpl object.
abstract void Dispose ()
 Frees unmanaged resources.
virtual void Draw (Rectangle destRect)
 For function use, see documentation of Surface.
virtual void Draw (Rectangle srcRect, Rectangle destRect)
 For function use, see documentation of Surface.
abstract void Draw (float x, float y, Rectangle srcRect, float rotationCenterX, float rotationCenterY)
 For function use, see documentation of Surface.
abstract void Draw (RectangleF srcRect, RectangleF destRect)
 For function use, see documentation of Surface.
virtual void Draw (Point destPt)
 For function use, see documentation of Surface.
virtual void Draw (float destX, float destY)
 For function use, see documentation of Surface.
abstract void Draw (float destX, float destY, float rotationCenterX, float rotationCenterY)
 For function use, see documentation of Surface.
virtual void DrawPoints (Point[] destPts)
 For function use, see documentation of Surface.
virtual void Draw ()
 For function use, see documentation of Surface.
virtual void DrawRects (Rectangle[] srcRects, Rectangle[] destRects, int start, int length)
 For function use, see documentation of Surface.
virtual void DrawRects (RectangleF[] srcRects, RectangleF[] destRects, int start, int length)
 For function use, see documentation of Surface.
void BeginQueueRects ()
 Sets up data structures to queue rects to draw to the screen.
void BeginQueueRects (int guessCount)
 Sets up data structures to queue rects to draw to the screen.
void QueueRect (Rectangle src_rect, Rectangle dest_rect)
 Adds a src/dest rectangle pair to the queue. Make sure to call BeginQueueRects first.
void EndQueueRects ()
 Ends adding rects to the queue and draws all of them to the screen.
abstract void SaveTo (string filename, ImageFileFormat format)
 Saves the surface data to the specified file in the specified format.
abstract SurfaceImpl CarveSubSurface (Rectangle srcRect)
 Creates a new SurfaceImpl object which comes from a small sub-rectangle on this surface.
abstract void SetSourceSurface (SurfaceImpl surf, Rectangle srcRect)
 Used by Display.BuildPackedSurface.
virtual PixelBuffer ReadPixels (PixelFormat format)
 Creates a PixelBuffer object with a copy of the pixel data, in the specified format.
abstract PixelBuffer ReadPixels (PixelFormat format, Rectangle rect)
 Creates a PixelBuffer object with a copy of the pixel data in the specified rectangle, in the specified format.
abstract void WritePixels (PixelBuffer buffer)
 Writes pixel data to the surface.
virtual void WritePixels (PixelBuffer buffer, Point startPoint)
 Writes pixel data to the surface.
void SetScale (double width, double height)
 Sets the amount of scaling when this surface is drawn. 1.0 is no scaling. Scale values can be negative, this causes the surface to be mirrored in that direction. This does not affect how the surface is aligned; eg. if DisplayAlignment is top-left and ScaleWidth < 0, the surface will still be drawn to the right of the point supplied to Draw(Point).
void GetScale (out double width, out double height)
 Gets the amount of scaling when this surface is drawn. 1.0 is no scaling. Scale values can be negative, this causes the surface to be mirrored in that direction. This does not affect how the surface is aligned; eg. if DisplayAlignment is top-left and ScaleWidth < 0, the surface will still be drawn to the right of the point supplied to Draw(Point).
void IncrementRotationAngle (double radians)
 Increments the rotation angle of this surface.
void IncrementRotationAngleDegrees (double degrees)
 Increments the rotation angle of this surface. Value supplied is in degrees.
abstract bool IsSurfaceBlank ()
 Checks to see whether the surface pixels all have alpha value less than the value of the AlphaThreshold of the display object..
abstract bool IsSurfaceBlank (int alphaThreshold)
 Checks to see whether the surface pixels all have alpha value less than the given value.
abstract bool IsRowBlank (int row)
 Checks to see whether all the pixels along the given row are all transparent, within the threshold.
abstract bool IsColumnBlank (int col)
 Checks to see whether all the pixels along the given column are all transparent, within the threshold.
abstract void BeginRender ()
 Utility function which can be called by BeginFrame to begin a render pass.
abstract void EndRender ()
 Utility function which can be called by EndFrame to end a render pass.

Protected Member Functions

bool IsRowBlankScanARGB (IntPtr pixelData, int row, int cols, int strideInBytes, int alphaThreshold, uint alphaMask, int alphaShift)
 Scans a memory area to see if it entirely contains pixels which won't be seen when drawn.
bool IsColBlankScanARGB (IntPtr pixelData, int col, int rows, int strideInBytes, int alphaThreshold, uint alphaMask, int alphaShift)
 Scans a memory area to see if it entirely contains pixels which won't be seen when drawn.

Properties

virtual InterpolationMode InterpolationHint [get, set]
int TesselateFactor [get, set]
 Gets or sets how many squares the surface should be broken into when drawn.
bool IsDisposed [get]
 Returns true if Dispose() has been called on this surface.
bool ShouldBePacked [get, set]
 Gets or sets a bool value which indicates whether or not this surface should be considered for packing when Display.PackAllSurfaces() is called.
int DisplayWidth [get, set]
 Get or sets the width of the surface in pixels when it will be displayed on screen.
int DisplayHeight [get, set]
 Gets or sets the height of the surface in pixels when it is displayed on screen.
Size DisplaySize [get, set]
 Gets or sets the Size of the area used by this surface when displayed on screen.
double Alpha [get, set]
 Alpha value for displaying this surface. Valid values range from 0.0 (completely transparent) to 1.0 (completely opaque). Internally stored as a byte, so granularity is only 1/255.0. If a gradient is used, getting this property returns the alpha value for the top left corner of the gradient.
virtual double RotationAngle [get, set]
 Gets or sets the rotation angle in radians. Positive angles indicate rotation in the Counter-Clockwise direction.
double RotationAngleDegrees [get, set]
 Gets or sets the rotation angle in degrees. Positive angles indicate rotation in the Counter-Clockwise direction.
virtual OriginAlignment RotationCenter [get, set]
 Gets or sets the point on the surface which is used to rotate around.
virtual OriginAlignment DisplayAlignment [get, set]
 Gets or sets the point where the surface is aligned to when drawn.
double ScaleWidth [get, set]
 Gets or sets the amount the width is scaled when this surface is drawn. 1.0 is no scaling. Scale values can be negative, this causes the surface to be mirrored in that direction. This does not affect how the surface is aligned; eg. if DisplayAlignment is top-left and ScaleWidth < 0, the surface will still be drawn to the right of the point supplied to Draw(Point).
double ScaleHeight [get, set]
 Gets or sets the amount the height is scaled when this surface is drawn. 1.0 is no scaling.
virtual Color Color [get, set]
 Gets or sets the multiplicative color for this surface. Setting this is equivalent to setting the ColorGradient property with a gradient with the same color in all corners. If a gradient is being used, getting this property returns the top-left color in the gradient.
virtual Gradient ColorGradient [get, set]
 Gets or sets the gradient for this surface.
virtual int SurfaceWidth [get]
 Gets the width of the source surface in pixels.
virtual int SurfaceHeight [get]
 Gets the height of the source surface in pixels.
abstract Size SurfaceSize [get]
 Gets the Size of the source surface in pixels.


Detailed Description

Base class for implementing a Surface structure.


Constructor & Destructor Documentation

AgateLib.ImplementationBase.SurfaceImpl.SurfaceImpl (  ) 

Constructs a SurfaceImpl object.


Member Function Documentation

void AgateLib.ImplementationBase.SurfaceImpl.BeginQueueRects ( int  guessCount  ) 

Sets up data structures to queue rects to draw to the screen.

Parameters:
guessCount A good guess for how many rects you are going to draw.

void AgateLib.ImplementationBase.SurfaceImpl.BeginQueueRects (  ) 

Sets up data structures to queue rects to draw to the screen.

abstract void AgateLib.ImplementationBase.SurfaceImpl.BeginRender (  )  [pure virtual]

Utility function which can be called by BeginFrame to begin a render pass.

Implements AgateLib.ImplementationBase.IRenderTargetImpl.

abstract SurfaceImpl AgateLib.ImplementationBase.SurfaceImpl.CarveSubSurface ( Rectangle  srcRect  )  [pure virtual]

Creates a new SurfaceImpl object which comes from a small sub-rectangle on this surface.

Parameters:
surface 
srcRect 
Returns:

abstract void AgateLib.ImplementationBase.SurfaceImpl.Dispose (  )  [pure virtual]

Frees unmanaged resources.

virtual void AgateLib.ImplementationBase.SurfaceImpl.Draw (  )  [virtual]

For function use, see documentation of Surface.

Info for developers: This method draws the surface at (0, 0). The base class implementation simply calls Draw(Point.Empty).

abstract void AgateLib.ImplementationBase.SurfaceImpl.Draw ( float  destX,
float  destY,
float  rotationCenterX,
float  rotationCenterY 
) [pure virtual]

For function use, see documentation of Surface.

Info for developers: This method should draw the surface to the screen, using all the scaling, rotation, etc. state data in the stored Surface object, except for RotationCenter. Use the point passed for the center of rotation.

This method must be overriden.

Parameters:
destX 
destY 
rotationCenterX 
rotationCenterY 

virtual void AgateLib.ImplementationBase.SurfaceImpl.Draw ( float  destX,
float  destY 
) [virtual]

For function use, see documentation of Surface.

Info for developers: This method should draw the surface to the screen, using all the scaling, rotation, etc. state data in the stored Surface object.

Parameters:
destX 
destY 

virtual void AgateLib.ImplementationBase.SurfaceImpl.Draw ( Point  destPt  )  [virtual]

For function use, see documentation of Surface.

Info for developers: This method should draw the surface to the screen, using all the scaling, rotation, etc. state data in the stored Surface object. The base class method calls Draw(PointF).

This method may be overriden, if it is convenient to provide an alternate implementation which takes integral drawing values.

Parameters:
destPt 

abstract void AgateLib.ImplementationBase.SurfaceImpl.Draw ( RectangleF  srcRect,
RectangleF  destRect 
) [pure virtual]

For function use, see documentation of Surface.

Info for developers: This method should draw a portion of the surface to the screen, ignoring all scaling, rotation and alignment state data. Color and Alpha are still to be used.

This method must be overriden.

Parameters:
srcRect 
destRect 

abstract void AgateLib.ImplementationBase.SurfaceImpl.Draw ( float  x,
float  y,
Rectangle  srcRect,
float  rotationCenterX,
float  rotationCenterY 
) [pure virtual]

For function use, see documentation of Surface.

Info for developers: This method should draw a portion of the surface to the screen, using all scaling, rotation and alignment state data.

This method must be overriden.

Parameters:
x 
y 
srcRect 
rotationCenterX 
rotationCenterY 

virtual void AgateLib.ImplementationBase.SurfaceImpl.Draw ( Rectangle  srcRect,
Rectangle  destRect 
) [virtual]

For function use, see documentation of Surface.

Info for developers: This method should draw a portion of the surface to the screen, ignoring all scaling, rotation and alignment state data. Color and Alpha are still to be used.

This method automatically converts Rectangle structures into RectangleF structures and calls the Draw overload which takes them. This can be overriden if the implementation is more natural to use integral values.

Parameters:
srcRect 
destRect 

virtual void AgateLib.ImplementationBase.SurfaceImpl.Draw ( Rectangle  destRect  )  [virtual]

For function use, see documentation of Surface.

Info for developers: This method should Draw the surface to the screen, ignoring all scaling, rotation and alignment state data. Color and Alpha are still to be used.

It is recommended to override this method, as the base class implementation saves the state, draws, then restores the state.

Parameters:
destRect 

virtual void AgateLib.ImplementationBase.SurfaceImpl.DrawPoints ( Point[]  destPts  )  [virtual]

For function use, see documentation of Surface.

Info for developers: This method should draw the surface to the screen, with the same result as if Draw was called once for each Point passed.

Parameters:
destPts 

virtual void AgateLib.ImplementationBase.SurfaceImpl.DrawRects ( RectangleF[]  srcRects,
RectangleF[]  destRects,
int  start,
int  length 
) [virtual]

For function use, see documentation of Surface.

Info for developers: This method should draw the surface to the screen, with the same result as if Draw was called once for each src and dest rect pairs. It should be overridden, to minimize calls across managed/unmanaged boundaries.

Parameters:
srcRects 
destRects 
start Element in the arrays to start with.
length Number of elements in the arrays to use.

virtual void AgateLib.ImplementationBase.SurfaceImpl.DrawRects ( Rectangle[]  srcRects,
Rectangle[]  destRects,
int  start,
int  length 
) [virtual]

For function use, see documentation of Surface.

Info for developers: This method should draw the surface to the screen, with the same result as if Draw was called once for each src and dest rect pairs. It should be overridden, to minimize calls across managed/unmanaged boundaries.

Parameters:
srcRects 
destRects 
start Element in the array to start with.
length Number of elements in the arrays to use.

void AgateLib.ImplementationBase.SurfaceImpl.EndQueueRects (  ) 

Ends adding rects to the queue and draws all of them to the screen.

abstract void AgateLib.ImplementationBase.SurfaceImpl.EndRender (  )  [pure virtual]

Utility function which can be called by EndFrame to end a render pass.

Implements AgateLib.ImplementationBase.IRenderTargetImpl.

void AgateLib.ImplementationBase.SurfaceImpl.GetScale ( out double  width,
out double  height 
)

Gets the amount of scaling when this surface is drawn. 1.0 is no scaling. Scale values can be negative, this causes the surface to be mirrored in that direction. This does not affect how the surface is aligned; eg. if DisplayAlignment is top-left and ScaleWidth < 0, the surface will still be drawn to the right of the point supplied to Draw(Point).

Parameters:
width 
height 

void AgateLib.ImplementationBase.SurfaceImpl.IncrementRotationAngle ( double  radians  ) 

Increments the rotation angle of this surface.

Parameters:
radians Value in radians to increase the rotation by.

void AgateLib.ImplementationBase.SurfaceImpl.IncrementRotationAngleDegrees ( double  degrees  ) 

Increments the rotation angle of this surface. Value supplied is in degrees.

Parameters:
degrees 

bool AgateLib.ImplementationBase.SurfaceImpl.IsColBlankScanARGB ( IntPtr  pixelData,
int  col,
int  rows,
int  strideInBytes,
int  alphaThreshold,
uint  alphaMask,
int  alphaShift 
) [protected]

Scans a memory area to see if it entirely contains pixels which won't be seen when drawn.

Parameters:
pixelData Pointer to the data
col Which col to check
rows How many columns to check
strideInBytes The stride of each row
alphaThreshold The maximum value of alpha to consider a pixel transparent.
alphaMask The mask to use to extract the alpha value from the data.
alphaShift How many bits to shift it to get alpha in the range of 0-255. For example, if alphaMask = 0xff000000 then alphaShift should be 24.
Returns:

abstract bool AgateLib.ImplementationBase.SurfaceImpl.IsColumnBlank ( int  col  )  [pure virtual]

Checks to see whether all the pixels along the given column are all transparent, within the threshold.

Parameters:
col Which column. Valid range is between 0 and SurfaceSize.Width - 1.
Returns:

abstract bool AgateLib.ImplementationBase.SurfaceImpl.IsRowBlank ( int  row  )  [pure virtual]

Checks to see whether all the pixels along the given row are all transparent, within the threshold.

Parameters:
row Which row. Valid range is between 0 and SurfaceSize.Height - 1.
Returns:

bool AgateLib.ImplementationBase.SurfaceImpl.IsRowBlankScanARGB ( IntPtr  pixelData,
int  row,
int  cols,
int  strideInBytes,
int  alphaThreshold,
uint  alphaMask,
int  alphaShift 
) [protected]

Scans a memory area to see if it entirely contains pixels which won't be seen when drawn.

Parameters:
pixelData Pointer to the data
row Which row to check
cols How many columns to check
strideInBytes The stride of each row
alphaThreshold The maximum value of alpha to consider a pixel transparent.
alphaMask The mask to use to extract the alpha value from the data.
alphaShift How many bits to shift it to get alpha in the range of 0-255. For example, if alphaMask = 0xff000000 then alphaShift should be 24.
Returns:

abstract bool AgateLib.ImplementationBase.SurfaceImpl.IsSurfaceBlank ( int  alphaThreshold  )  [pure virtual]

Checks to see whether the surface pixels all have alpha value less than the given value.

Parameters:
alphaThreshold The alpha value below which to consider a pixel blank. In the range 0 <= alphaThreshold <= 255.
Returns:

abstract bool AgateLib.ImplementationBase.SurfaceImpl.IsSurfaceBlank (  )  [pure virtual]

Checks to see whether the surface pixels all have alpha value less than the value of the AlphaThreshold of the display object..

Returns:

void AgateLib.ImplementationBase.SurfaceImpl.QueueRect ( Rectangle  src_rect,
Rectangle  dest_rect 
)

Adds a src/dest rectangle pair to the queue. Make sure to call BeginQueueRects first.

Parameters:
src_rect 
dest_rect 

abstract PixelBuffer AgateLib.ImplementationBase.SurfaceImpl.ReadPixels ( PixelFormat  format,
Rectangle  rect 
) [pure virtual]

Creates a PixelBuffer object with a copy of the pixel data in the specified rectangle, in the specified format.

Parameters:
format 
rect 
Returns:

virtual PixelBuffer AgateLib.ImplementationBase.SurfaceImpl.ReadPixels ( PixelFormat  format  )  [virtual]

Creates a PixelBuffer object with a copy of the pixel data, in the specified format.

Parameters:
format 
Returns:

abstract void AgateLib.ImplementationBase.SurfaceImpl.SaveTo ( string  filename,
ImageFileFormat  format 
) [pure virtual]

Saves the surface data to the specified file in the specified format.

Parameters:
filename 
format 

void AgateLib.ImplementationBase.SurfaceImpl.SetScale ( double  width,
double  height 
)

Sets the amount of scaling when this surface is drawn. 1.0 is no scaling. Scale values can be negative, this causes the surface to be mirrored in that direction. This does not affect how the surface is aligned; eg. if DisplayAlignment is top-left and ScaleWidth < 0, the surface will still be drawn to the right of the point supplied to Draw(Point).

Parameters:
width 
height 

abstract void AgateLib.ImplementationBase.SurfaceImpl.SetSourceSurface ( SurfaceImpl  surf,
Rectangle  srcRect 
) [pure virtual]

Used by Display.BuildPackedSurface.

Parameters:
surf 
srcRect 

virtual void AgateLib.ImplementationBase.SurfaceImpl.WritePixels ( PixelBuffer  buffer,
Point  startPoint 
) [virtual]

Writes pixel data to the surface.

Parameters:
buffer 
startPoint 

abstract void AgateLib.ImplementationBase.SurfaceImpl.WritePixels ( PixelBuffer  buffer  )  [pure virtual]

Writes pixel data to the surface.

Parameters:
buffer 


Property Documentation

double AgateLib.ImplementationBase.SurfaceImpl.Alpha [get, set]

Alpha value for displaying this surface. Valid values range from 0.0 (completely transparent) to 1.0 (completely opaque). Internally stored as a byte, so granularity is only 1/255.0. If a gradient is used, getting this property returns the alpha value for the top left corner of the gradient.

virtual Color AgateLib.ImplementationBase.SurfaceImpl.Color [get, set]

Gets or sets the multiplicative color for this surface. Setting this is equivalent to setting the ColorGradient property with a gradient with the same color in all corners. If a gradient is being used, getting this property returns the top-left color in the gradient.

virtual Gradient AgateLib.ImplementationBase.SurfaceImpl.ColorGradient [get, set]

Gets or sets the gradient for this surface.

virtual OriginAlignment AgateLib.ImplementationBase.SurfaceImpl.DisplayAlignment [get, set]

Gets or sets the point where the surface is aligned to when drawn.

int AgateLib.ImplementationBase.SurfaceImpl.DisplayHeight [get, set]

Gets or sets the height of the surface in pixels when it is displayed on screen.

Size AgateLib.ImplementationBase.SurfaceImpl.DisplaySize [get, set]

Gets or sets the Size of the area used by this surface when displayed on screen.

int AgateLib.ImplementationBase.SurfaceImpl.DisplayWidth [get, set]

Get or sets the width of the surface in pixels when it will be displayed on screen.

bool AgateLib.ImplementationBase.SurfaceImpl.IsDisposed [get]

Returns true if Dispose() has been called on this surface.

virtual double AgateLib.ImplementationBase.SurfaceImpl.RotationAngle [get, set]

Gets or sets the rotation angle in radians. Positive angles indicate rotation in the Counter-Clockwise direction.

double AgateLib.ImplementationBase.SurfaceImpl.RotationAngleDegrees [get, set]

Gets or sets the rotation angle in degrees. Positive angles indicate rotation in the Counter-Clockwise direction.

virtual OriginAlignment AgateLib.ImplementationBase.SurfaceImpl.RotationCenter [get, set]

Gets or sets the point on the surface which is used to rotate around.

double AgateLib.ImplementationBase.SurfaceImpl.ScaleHeight [get, set]

Gets or sets the amount the height is scaled when this surface is drawn. 1.0 is no scaling.

double AgateLib.ImplementationBase.SurfaceImpl.ScaleWidth [get, set]

Gets or sets the amount the width is scaled when this surface is drawn. 1.0 is no scaling. Scale values can be negative, this causes the surface to be mirrored in that direction. This does not affect how the surface is aligned; eg. if DisplayAlignment is top-left and ScaleWidth < 0, the surface will still be drawn to the right of the point supplied to Draw(Point).

bool AgateLib.ImplementationBase.SurfaceImpl.ShouldBePacked [get, set]

Gets or sets a bool value which indicates whether or not this surface should be considered for packing when Display.PackAllSurfaces() is called.

virtual int AgateLib.ImplementationBase.SurfaceImpl.SurfaceHeight [get]

Gets the height of the source surface in pixels.

abstract Size AgateLib.ImplementationBase.SurfaceImpl.SurfaceSize [get]

Gets the Size of the source surface in pixels.

virtual int AgateLib.ImplementationBase.SurfaceImpl.SurfaceWidth [get]

Gets the width of the source surface in pixels.

int AgateLib.ImplementationBase.SurfaceImpl.TesselateFactor [get, set]

Gets or sets how many squares the surface should be broken into when drawn.


The documentation for this class was generated from the following file:
AgateLib
Awesome Game and Tool Engine Library
SourceForge.net Logo