You never directly allocate an object of this type, but you may want to derive an object from this class. It would allow you to be "painted on" by other objects.
The most useful objects that are derived from this object are GdcMemDC that defines a bitmap in memory and GdcGdiScreen or GdcViewDC (Win32 and BeOS respectively) screen DC's.
![]() |
class GdcBasePrimitives { public: // Blt virtual void Blt(int x, int y, GdcBasePrimitives *Src, GdcRegion *a = NULL) virtual void StretchBlt(GdcRegion *d, GdcBasePrimitives *Src, GdcRegion *s) // Curve virtual void Arc(double cx, double cy, double radius, double start, double end) virtual void Circle(double cx, double cy, double radius) virtual void Ellipse(double cx, double cy, double x, double y) virtual void FilledArc(double cx, double cy, double radius, double start, double end) virtual void FilledCircle(double cx, double cy, double radius) virtual void FilledEllipse(double cx, double cy, double x, double y) // Line virtual uint LineStyle(uint Bits) virtual uint LineStyle() virtual void HLine(int x1, int x2, int y) virtual void Line(int x1, int y1, int x2, int y2) virtual void VLine(int x, int y1, int y2) // Other virtual void Bezier(int Threshold, GdcPt2 *Pt) virtual void FloodFill(int x, int y, int Mode, COLOUR Border = 0, GdcRegion *Bounds = NULL) virtual void Polygon(int Points, GdcPt2 *Data) virtual void Text(GdcFont *pFont, int x, int y, char *Str, int Len) // Pixel virtual COLOUR Get(int x, int y) virtual void Set(int x, int y) // Properties virtual bool IsScreen() virtual COLOUR Colour() virtual GdcPalette *Palette() virtual GdcRegion ClipRgn() virtual GdcRegion ClipRgn(GdcRegion *Rgn) virtual int GetBits() virtual int Op() virtual int X() virtual int Y() virtual uchar *operator[](int y) virtual void Colour(COLOUR c, int Bits = 0) virtual void GetOrigin(int &x, int &y) virtual void Op(int Op) virtual void Palette(GdcPalette *pPal, bool bOwnIt = TRUE) virtual void SetOrigin(int x, int y) // Rectangular virtual void Box(int x1, int y1, int x2, int y2) virtual void Box(GdcRegion *a = NULL) virtual void Rectangle(int x1, int y1, int x2, int y2) virtual void Rectangle(GdcRegion *a = NULL) |
![]() |
// Win32 HBITMAP GetBitmap() HDC Handle() virtual HDC StartDC() virtual void EndDC() |
![]() |
// BeOS BBitmap *GetBitmap();() BView *Handle() |
  |
}; |
Argument | Description |
int x | x location of the destination |
int y | y location of the destination |
GdcBasePrimitives *Src | Source device. |
GdcRegion *a = NULL | Area in source device to copy from, if not specified or NULL then the whole source device is assumed. |
This function copies some or all the the source bitmap to this device. Colour depth conversion will be used if necessary.
Argument | Description |
GdcRegion *d | Destination region |
GdcBasePrimitives *Src | Source device |
GdcRegion *s | Source region |
Copies a bitmap from Src to this device, including scaling.
Argument | Description |
double cx, double cy | Center of the arc. |
double radius | Radius of the arc. |
double start, double end |
Start and end angles of the arc.
These are specified in degrees. Clockwise around the circle. With 0 at the top. |
Draws part of a circle.
Argument | Description |
double cx, double cy | Center of the circle |
double radius | Radius of the circle |
Draws an unfilled circle centered around cx, cy with a radius.
Argument | Description |
double cx, double cy | Center of the ellipse |
double x, double y | Length of the x and y axis. Specified as the distance from the center to the edge. |
Draws a unfilled ellipse.
Argument | Description |
double cx, double cy | Center of the arc |
double radius | Radius of the arc |
double start, double end | Start and end angles of the arc, specified in degrees starting from 0 at the top and progressing clockwise. |
Draws a filled section of a circle. The filled section is calculated by joining the ends of the arc segment to the center of the arc.
Argument | Description |
double cx, double cy | Center of the circle |
double radius | Radius of the circle |
Draws an filled circle centered around cx, cy with a radius.
Argument | Description |
double cx, double cy | The center of the ellipse |
double x, double y | The length of the x and y axis. From the center to the edge. |
Draws a filled ellipse.
Argument | Description |
uint Bits |
A bit pattern that says which pixels are drawn and which arn't.
Each bit in this integer is tested in sucession and used to decide what pixels in the line to switch on. |
Sets the pixels on the line that are drawn.
Note: Win32 screen DC's don't support this functionality.
Returns the current line style.
Argument | Description |
int x1 | Start x loc |
int x2 | End x loc |
int y | The y location of the line |
Draws a horizontal line.
Argument | Description |
int x1, int y1 | Start location of the line |
int x2, int y2 | End location of the line. The final pixel is drawn. |
Draws a line between 2 points.
Argument | Description |
int x | |
int y1 | |
int y2 |
Draws a vertical line.
Argument | Description |
int Threshold | Number of interations to "smooth" the line? |
GdcPt2 *Pt | Array of 3 points. Start, middle and end. |
I've forgotten how this works. Sorry.
Argument | Description |
int x, int y | Place to start fill from. |
int Mode |
Unused.
Currently the fill takes the colour at x, y and fills all surrounding pixels of that colour to the current DC colour. |
COLOUR Border = 0 |
Unused.
The colour of the border. For different fill rules. |
GdcRegion *Bounds = NULL | Returns the maximum boundry of filling. Really useful for screen update functions. |
Flood fills the DC.
Argument | Description |
int Points | Number of points in the array. |
GdcPt2 *Data | Array of points. |
Draws a polygon. Can be complex.
Argument | Description |
GdcFont *pFont | Font to draw text with. |
int x, int y | Top-left hand corner of text rectangle. |
char *Str | String to draw. |
int Len | Number of characters to draw, or -1. If -1 then the whole NULL terminated string is drawn. This parameter defaults to -1. |
Draws some text on the DC.
Argument | Description |
int x | X loc of pixel |
int y | Y loc of pixel |
Returns the pixel at the location specified. This function may fail on devices that don't support GetPixel, in this case the function returns 0.
Argument | Description |
int x | The x location of the pixel to set. |
int y | The y location of the pixel to set. |
Sets a single pixel to the current colour.
Returns true of the DC draws on the screen.
Gets the current drawing colour.
Returns the current palette. (Pointer is still owned by the DC, don't delete)
Returns the current clipping region.
Argument | Description |
GdcRegion *Rgn | New clipping region. |
Sets the Cliping region.
Returns:
The old clipping region.
Returns the bit depth of the DC.
Currently this also determines the colour space of the DC, because only one colour space is defined per bit depth. I know this is lame but it works reasonably well for me. One day there will be a colour space function as well. The colour spaces are defined in the gdc2.h header file. There are a bunch of accessor macros for the different colour spaces:
Returns the current operator to combine the source colour / data with the DC's bits.
Returns the width of the DC.
Returns the Height of the DC.
Argument | Description |
int y | Which scanline to return. |
Returns the address of the specified scanline or NULL if not available or index out of range.
Argument | Description |
COLOUR c | Colour to set current colour to. |
int Bits = 0 | The bit depth of the colour you are passing in. If 0 then the depth is assumed to be equal to the DC's. |
Sets the current drawing colour.
Argument | Description |
int &x, int &y |
Get the origin of the DC.
Argument | Description |
int Op |
New operator. Can be one of:
|
Sets the current operator to combine the source colour / data with the DC's bits.
Argument | Description |
GdcPalette *pPal | New palette. |
bool bOwnIt = TRUE |
If true the DC takes responsibility to delete the palette object.
If false then the DC makes a copy of the palette object. And ownership of the palette doesn't change. |
Sets the current palette.
Argument | Description |
int x, int y |
Set the DC's origin.
Argument | Description |
int x1, int y1 | The top-left corner of the rectangle |
int x2, int y2 |
The bottom-right corner of the rectangle.
Note: Coordinates are literal, unlike windows where the bottom-right coordinates are one pixel furthur right and down than the actual drawn rectangle. |
Draws the unfilled rectangle.
Argument | Description |
GdcRegion *a = NULL |
The rectangle's coordinates.
If NULL then the rectangle will fill the entire device context. Note: Coordinates are literal, unlike windows where the bottom-right coordinates are one pixel furthur right and down than the actual drawn rectangle. |
Draws the unfilled rectangle.
Argument | Description |
int x1, int y1 | The top-left corner of the rectangle |
int x2, int y2 |
The bottom-right corner of the rectangle.
Note: Coordinates are literal, unlike windows where the bottom-right coordinates are one pixel furthur right and down than the actual drawn rectangle. |
Draws a filled rectangle.
Argument | Description |
GdcRegion *a = NULL |
The rectangle's coordinates.
If NULL then the rectangle will fill the entire device context. Note: Coordinates are literal, unlike windows where the bottom-right coordinates are one pixel furthur right and down than the actual drawn rectangle. |
Draws a filled rectangle.
Returns the handle of bitmap in memory. Only relevent for memory contexts.
Returns the handle of the operating systems context, under windows this is a HDC.
This function allocates or returns a valid HDC under windows. This function needs to have a matching 'EndDC' call. ie:
HDC hDC = pDC->StartDC();
// do something with the DC
pDC->EndDC();
Returns:
A valid win32 device context.
Cleans up after a call to StartDC.
Returns a pointer to the bitmap is the DC is a memory bitmap.
Returns the operating systems context. Under BeOS this is a pointer to a BView.