About
GeClipMap is a utility class that allows to perform advanced drawing operations.
Allocation/Deallocation
A GeClipMap can be created with the usual tools:
The created GeClipMap can be initiated in multiple ways:
if (clipMap == nullptr)
const Int32 width = 1024;
const Int32 height = 1024;
clipMap->
FillRect(0, 0, width - 1, height - 1);
if (bitmap == nullptr)
A GeClipMap is easily cleared with:
Read-Only Properties
The basic settings of a GeClipMap are accessed with:
The bitmap data is stored internally as a BaseBitmap:
Drawing
Every drawing operation performed with a GeClipMap must be encapsulated between these two functions:
The drawing operations can be modified with:
clipMap->
FillRect(0, 0, width - 1, height - 1);
for (
Int32 i = 0; i < elementCnt; ++i)
{
const Int32 offsetX = 10 + (i * 100);
const Int32 offsetY = 10;
}
A clipping region defines the part of the GeClipMap which will be affected by the following drawing operations.
Single pixels of the GeClipMap can be accessed with:
clipMap->
GetDim(&clipMapWidth, &clipMapHeight);
for (
Int32 x = 0; x < clipMapWidth; ++x)
{
for (
Int32 y = 0; y < clipMapHeight; ++y)
{
}
}
A blit operations allows to easily copy a part of a GeClipMap into another GeClipMap.
const IMAGERESULT resSource = sourceClipMap->Init(sourceBitmap);
const IMAGERESULT resTarget = targetClipMap->Init(targetWidth, targetHeight, 32);
if (sourceImageOK && targetImageOK)
{
targetClipMap->BeginDraw();
targetClipMap->Blit(0, 0, *sourceClipMap, 0, 0, targetWidth, targetHeight,
GE_CM_BLIT::COPY);
targetClipMap->EndDraw();
}
Drawing Operations
These drawing operations allow to create basic shapes. The use the current color defined with GeClipMap::SetColor().
Drawing Text
These functions are used to handle and draw text:
The currently used font is defined with:
if (clipMap == nullptr)
clipMap->
SetFont(&fontSettings, 20.0);
res = clipMap->
Init(textWidth, textHeight, 32);
clipMap->
FillRect(0, 0, textWidth - 1, textHeight - 1);
clipMap->
SetFont(&fontSettings, 20.0);
These static functions are used to manage fonts:
See also FontData and GeChooseFont().
while (browse.GetNext(&containerElement, &fontData))
{
}
Further Reading
@ GE_FONT_NAME_FAMILY
Font family name (e.g. "Helvetica").
Definition: lib_clipmap.h:110
@ OK
Image loaded/created.
IMAGERESULT Init(Int32 w, Int32 h, Int32 bits)
@ GE_FONT_NAME_DISPLAY
Human readable font name (e.g. "Helvetica Bold").
Definition: lib_clipmap.h:109
@ HIERARCHICAL
One BaseContainer per font, no order guaranteed.
void Arc(Int32 x1, Int32 y1, Int32 x2, Int32 y2, GE_CM_ARCSEGMENT seg)
void SetPixelRGBA(Int32 x, Int32 y, Int32 r, Int32 g, Int32 b, Int32 a=255)
@ RIGHTBOTTOM
(x2,y1) -> (x2,y2) -> (x1,y2)
BaseContainer * GetContainerInstance(Int32 id)
Definition: c4d_basecontainer.h:425
@ LEFTBOTTOM
(x2,y2) -> (x1,y2) -> (x1,y1)
#define iferr_return
Definition: resultbase.h:1465
@ COPY
New pixels overwrite old ones.
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:66
static Bool GetFontName(BaseContainer const *font_description, GeFontNameType type, String *dst)
void GetDim(Int32 *w, Int32 *h) const
static Bool GetFontDescription(String const &name, GeFontNameType type, BaseContainer *dst)
void BeginDraw()
Must be called before any drawing functions.
void TextAt(Int32 x, Int32 y, const String &txt)
Definition: c4d_string.h:38
void SetColor(Int32 r, Int32 g, Int32 b, Int32 a=255)
Definition: c4d_gedata.h:82
@ COPY
Source overwrites destination.
maxon::Int32 Int32
Definition: ge_sys_math.h:60
void SetOffset(Int32 off_x, Int32 off_y)
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:208
Bool ShowBitmap(const Filename &fn)
void FillRect(Int32 x1, Int32 y1, Int32 x2, Int32 y2)
static void EnumerateFonts(BaseContainer *dst, GE_CM_FONTSORT sort_mode)
@ GE_FONT_NAME_POSTSCRIPT
Font postscript name (e.g. "Helvetica-Bold").
Definition: lib_clipmap.h:112
Int32 GetTextWidth(const String &txt)
Definition: c4d_basebitmap.h:413
Definition: ge_autoptr.h:36
maxon::Bool Bool
Definition: ge_sys_math.h:55
void EndDraw()
Must be called after a sequence of drawing functions to free the memory allocated by BeginDraw().
Definition: c4d_gedata.h:673
Definition: c4d_tools.h:811
IMAGERESULT
Definition: ge_prepass.h:3696
Bool SetFont(BaseContainer const *font_description, Float font_size=0.0)
BaseContainer * GetContainer(void) const
Definition: c4d_gedata.h:487
Definition: c4d_basecontainer.h:46
void FillEllipse(Int32 x1, Int32 y1, Int32 x2, Int32 y2)