User manual

8 Graphics Quick Reference Guide
Primitive Layer
Primitive Layer Description
void InitGraph()
Initialize the display controller, sets the screen to BLACK,
sets current color to WHITE, sets the cursor at (0,0), sets
the line type to SOLID_LINE and sets the active page
and visual page to 0.
void ClearDevice()
Clears the screen with the current color and sets the
cursor at (0,0).
SHORT GetX()
Returns the graphic cursor x coordinates.
SHORT GetY()
Returns the graphic cursor y coordinates.
void MoveTo(
SHORT x,
SHORT y)
Moves the graphic cursor to the new x,y location.
void MovetoRel(SHORT x, SHORT y)
Moves the graphic cursor relative to the current location.
void SetFont(void *pFont)
Sets the current font to be used when rendering
characters.
void SetFontOrientation(WORD orient)
Sets the font orientation to vertical or horizontal
orientation.
orient denition
ORIENT_HOR horizontal
ORIENT_VER vertical
BYTE GetFontOrientation()
Returns the current font orientation (vertical or horizontal).
See SetFontOrientation().
WORD OutChar(XCHAR ch)
Renders the character represented by the character ID ch
on the current graphic cursor position using the current
set font and color.
WORD OutText(XCHAR *pString)
Renders a string of characters pointed to by pString on
the current graphic cursor location using the current set
font and color.
WORD OutTextXY(
SHORT x,
SHORT y,
XCHAR *pString)
Renders the specied string pointed to by pString on
the location specied by x,y using the current set font
and color.
SHORT GetTextHeight(void *pFont)
Returns the height of the specied font.
SHORT GetTextWidth(
XCHAR pString,
void *pFont)
Returns the width of the specied string for the specied
font.
void SetLineType(WORD lnType)
Sets the line type to render.
lnType denition
SOLID_LINE Solid line
DASHED_LINE Dashed line
void SetLineThickness(WORD lnThickness)
Sets the line thickness to render.
lnThickness denition
NORMAL_LINE 1 pixel thick
THICK_LINE 3 pixel thick
WORD Line(
SHORT x1,
SHORT y1,
SHORT x2,
SHORT y2)
Renders a line using the current set line type, line
thickness and color from x1,y1 to x2,y2.
WORD LineRel(
SHORT x,
SHORT y)
Renders a line using the current set line type, line
thickness and color from the current graphic cursor
position to the relative position specied by the given x
and y displacement.
WORD LineTo(
SHORT x,
SHORT y)
Renders a line using the current set line type, line
thickness and color from the current graphic cursor
position to the given x,y position.
Note:
1. This is an optional feature and is implemented only if the display controller supports alpha blending.
Primitive Layer Description
WORD Circle(
SHORT x,
SHORT y,
SHORT r)
Renders a circle using the current set line type, line
size and color located at center on x,y with a radius r.
WORD FillCircle(
SHORT x,
SHORT y,
SHORT r)
Renders a lled circle using the current set color
located at center on x,y with a radius r.
WORD DrawPoly(
SHORT numPoints,
SHORT *polyPoints)
Renders a polygon with the current line type, line
size and color where the number of points is given
by numPoints and the polygon points is given by the
array pointed to by polyPoints.
PolyPoints[n] = x0,y0,x1,y1,…xn,yn;
n = numPoints
WORD Arc(
SHORT xL,
SHORT yR,
SHORT xR,
SHORT yB,
SHORT r1,
SHORT r2,
BYTE octant)
Draws the octant arc of the beveled gure with the
given centers, radii and octant mask.
WORD PutImage(
SHORT left,
SHORT top,
void *pBitmap,
BYTE stretch)
Renders the image pointed to by pBitmap starting
from left, top position.
SHORT GetImageHeight(
void *pBitmap)
Returns the image height.
SHORT GetImageWidth(
void *pBitmap)
Returns the image width.
SHORT GetSineCosine(
SHORT v,
WORD type)
Returns the sine or cosine (type = GETSINE or
GETCOSINE) values of the given angle v. Return
values are normalized to 256.
SHORT Sine(
SHORT v)
Returns the sine value of the given angle v. Return
values are normalized to 256.
SHORT Cosine(
SHORT v)
Returns the sine value of the given angle v. Return
values are normalized to 256.
WORD AlphaBlendWindow(
DWORD foregroundWindowAddr,
DWORD backgroundWindowAddr,
DWORD destinationWindowAddr,
WORD width,
WORD height,
BYTE alphaPercentage)
Alpha blends the foreground and the background
images with the dimension specied by width and
height and writes the result to the destination.
Graphics Cong: USE_ALPHA_BLEND
(1)
DWORD GFXGetPageXYAddress(
SHORT pageNumber,
WORD x,
WORD y)
Calculates the address of the pixel located in x,y
position inside the buffer specied by pageNumber.
Graphics Cong: USE_ALPHA_BLEND
(1)
DWORD GFXGetPageOriginAddress(
SHORT pageNumber)
Calculates the address of the buffer specied by
pageNumber.
Graphics Cong: USE_ALPHA_BLEND
(1)
WORD ExternalMemoryCallback(
GFX_EXTDATA *memory,
LONG offset,
WORD nCount,
void *buffer)
When using external memory, this function must be
implemented in the application code and will contain
code to access external memory with the appropriate
external memory drivers.
Graphics Cong: USE_FONT_EXTERNAL or
USE_BITMAP_EXTERNAL
Microchip Graphics Library Quick Reference Guide