c4d.bitmaps.GeClipMap

This class stores and manipulates a bitmap, providing more advanced drawing tools than BaseBitmap. Just like for bitmaps x = y = 0 is the top left corner. Be sure to call GeClipMap.Init(), GeClipMap.InitWith() or GeClipMap.InitWithBitmap() before you attempt to use a newly allocated clip map.

Note

Though clip maps support other bit depths than 32, the functionality is severly limited. It is recommended that the clip map class is only used for 32 bit bitmaps. (Please note that the default bit depth for BaseBitmap is 24. You need to manually set it to 32 if you use Init to initialize the clip map.)

Inheritance

  • c4d.bitmaps.GeClipMap

Members

GeClipMap.__init__()

Creates a new instance of GeClipMap.

Return type: GeClipMap
Returns: The new clipmap.
GeClipMap.Init(w, h[, bits=32])

Initializes the clip map bitmap to the given dimensions and depth. Any previous data is lost.

Parameters:
  • w (int) – Width
  • h (int) – height
  • bits (int) – 32
Return type:

bool

Returns:

True if the initialization was successfull.

GeClipMap.InitWith(name, frame)

Loads the clip map bitmap from the file specified by name. The file can be either a movie or a picture. The file format is automatically detected. Any previous data is lost:

result, ismovie = clmap.InitWith(path)
if result==c4d.IMAGERESULT_OK: #int check
    # picture loaded
    if ismovie==True: #bool check
        pass # file is a movie
    else:
        pass # file is no movie
Parameters:
  • name (str) – The path to the image.
  • frame (int) – The frame number to load in a movie.
Return type:

tuple(int, bool)

Returns:

Return the image result and a boolean value if the file is a movie.

GeClipMap.InitWithBitmap(bm[, alpha_channel=None])

Loads the clip map bitmap from bm. Any previous data is lost.

Parameters:
  • bm (BaseBitmap) – The bitmap to initalize the clip map with.
  • alpha_channel (BaseBitmap) – The alpha channel to use in bm.
Return type:

bool

Returns:

True if the clip map was initialized, otherwise False.

GeClipMap.Destroy()

Resets the clip map to its initial state and frees allocated memory. Requires a new call to Init() before the clip map can be used again.

GeClipMap.GetBitmap()

Returns the internal bitmap object.

Note

The clip map alpha channel won’t be encoded in this bitmap. This is a limitation.

Return type: BaseBitmap
Returns: The bitmap.
GeClipMap.BeginDraw()

Must be called before any drawing commands. After you called a sequence of drawing commands you should call GeClipMap.EndDraw().

GeClipMap.EndDraw()

Must be called after any drawing commands. Before you called a sequence of drawing commands you should call GeClipMap.BeginDraw().

GeClipMap.GetDim()

Retrieves the pixel dimensions of the clip map:

x, y = clmap.GetDim()
GeClipMap.GetBw()

Retrieves the pixel width of the clip map.

Return type: int
Returns: The width.
GeClipMap.GetBh()

Retrieves the pixel height of the clip map.

Return type: int
Returns: The height.
GeClipMap.Blit(dx, dy, s_dp, sx1, sy1, sx2, sy2, rop)

Blits from s_dp to this clip map. The region (sx1, sy1) to (sx2, sy2) from the source will be copied into the region with the top left corner at (dx, dy) in the destination. Additionally you can specify a raster operation with rop.

Parameters:
  • dx (int) – Top left destination X coordinate.
  • dy (int) – Top left destination Y coordinate.
  • s_dp (GeClipMap) – Source.
  • sx1 (int) – Top left source X coordinate.
  • sy1 (int) – Top left source Y coordinate.
  • sx2 (int) – Bottom right source X coordinate.
  • sy2 (int) – Bottom right source Y coordinate.
  • rop (int) –

    Raster operation:

    GE_CM_BLIT_COPY Source overwrites destination.
    GE_CM_BLIT_COL Source overwrites destination everywhere where source doesn’t equal the background color.
    GE_CM_BLIT_FG Sets pixels to the foreground color if the color is not the background color.
GeClipMap.SetColor(r, g, b[, alpha=255])

Checks if the draw operation mode is initialized.

Note

Call BeginDraw() before

Parameters:
  • r (int) – Red. (Between 0 and 255.).
  • g (int) – Green. (Between 0 and 255.)
  • b (int) – Blue. (Between 0 and 255.)
  • alpha (int) – Alpha value. (Between 0 and 255.)
GeClipMap.SetOffset(off_x, off_y)

Offsets all the following draw commands by this amount.

Note

The clip region isn’t offset.

Parameters:
  • off_x (int) – X distance in pixels.
  • off_y (int) – Y distance in pixels.
GeClipMap.SetDrawMode(mode, par)

Sets the draw mode for the following drawing operations.

Parameters:
  • mode (int) –

    Mode.

    GE_CM_DRAWMODE_COPY New pixels overwrite old ones. The parameter isn’t used.
    GE_CM_DRAWMODE_BLEND New pixels blend with old ones, taking the alpha value of the new pixels in account as well as the blend factor specified by the parameter (between 0 and 255, where 255 = new pixels).
    GE_CM_DRAWMODE_MASK New pixels overwrite the old ones at the bits where the mask specified by the parameter equals 1.
  • par (int) – Parameter (Depends on mode)
GeClipMap.SetPixel(x, y)

Sets the pixel at (x,y) to the draw color.

Note

Currently this method does no range check of x and y. This might be added in the future. Please do the check on your own.

Parameters:
  • x (int) – X coordinate.
  • y (int) – Y coordinate.
GeClipMap.Line(x1, y1, x2, y2)

Draws a line from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – First X coordinate.
  • y1 (int) – First Y coordinate.
  • x2 (int) – Second X coordinate.
  • y2 (int) – Second Y coordinate.
GeClipMap.Rect(x1, y1, x2, y2)

Draws the outline of a rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
GeClipMap.FillRect(x1, y1, x2, y2)

Fills a rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
GeClipMap.Arc(x1, y1, x2, y2, seg)

Fills a rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
  • seg

    The arc is drawn in the direction given by:

    0 (x1,y1) -> (x2,y1) -> (x2,y2)
    1 (x2,y1) -> (x2,y2) -> (x1,y2)
    2 (x2,y2) -> (x1,y2) -> (x1,y1)
    3 (x1,y2) -> (x1,y1) -> (x2,y1)
GeClipMap.FillArc(x1, y1, x2, y2, seg)

Draws an arc within the rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
  • seg

    The arc is drawn in the direction given by:

    0 (x1,y1) -> (x2,y1) -> (x2,y2)
    1 (x2,y1) -> (x2,y2) -> (x1,y2)
    2 (x2,y2) -> (x1,y2) -> (x1,y1)
    3 (x1,y2) -> (x1,y1) -> (x2,y1)
GeClipMap.Ellipse(x1, y1, x2, y2)

Draws an ellipse within the rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
GeClipMap.FillEllipse(x1, y1, x2, y2)

Fills an ellipse within the rectangle from (x1,y1) to (x2,y2) with the draw color.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
GeClipMap.SetPixelRGBA(x, y, r, g, b[, a=255])

Sets the pixel at (x,y) to the specified color.

Note

Currently this method does no range check of x and y. This might be added in the future. Please do the check on your own.

Parameters:
  • x (int) – X coordinate.
  • y (int) – Y coordinate.
  • r (int) – Red. (Between 0 and 255.)
  • g (int) – Green. (Between 0 and 255.)
  • b (int) – Blue. (Between 0 and 255.)
  • a (int) – Alpha value. (Between 0 and 255.)
GeClipMap.GetPixelRGBA(x, y)

Retrieves the color of the pixel at (x,y):

r, g, b, a = clmap.GetPixelRGBA(5, 5)

Note

Currently this method does no range check of x and y. This might be added in the future. Please do the check on your own.

Parameters:
  • x (int) – X coordinate.
  • y (int) – Y coordinate.
Return type:

list of int

Returns:

The color.

GeClipMap.TextAt(x, y, txt)

Prints the string txt with the top left corner at (x,y) in the current draw color.

Parameters:
  • x (int) – Top left X coordinate.
  • y (int) – Top left Y coordinate.
  • txt (str) – Text to print.
GeClipMap.TextWidth(txt)

Calculates the width of the string txt in the current font.

Parameters: txt (str) – The string.
Return type: int
Returns: Calculates the maximum height of a string in the current font.
GeClipMap.TextHeight()

Calculates the maximum height of a string in the current font.

GeClipMap.TextAscent()

Calculates the ascent in the current font. This is the distance from the baseline to the ascender line and usually represents the the height of capital letters.

GeClipMap.ClipPoint(x, y)

Checks if a point is inside the clip region.

Parameters:
  • x (int) – X coordinate.
  • y (int) – Y coordinate.
Return type:

bool

Returns:

True if the point is inside the region, otherwise False.

GeClipMap.ClipArea(x1, y1, x2, y2)

Checks if a rectangle is inside the clip region.

Parameters:
  • x1 (int) – Top left X coordinate.
  • y1 (int) – Top left Y coordinate.
  • x2 (int) – Bottom right X coordinate.
  • y2 (int) – Bottom right Y coordinate.
Return type:

int

Returns:

The result:

GE_CLIP_OUT

Completely outside.

GE_CLIP_ALLIN

Completely inside.

GE_CLIP_PARTIN

Partially inside.

GeClipMap.SetFont(font_description, font_size)

New in version R13.029.

Sets the current font.

Parameters:
  • font_description (BaseContainer) – Font description. Can be None for the default font.
  • font_size (float) – Font size, or 0.0 for the default height.
Return type:

bool

Returns:

True if successful, otherwise False.

GeClipMap.GetFont(font_description)

New in version R13.029.

Returns the current font description.

Parameters: font_description (BaseContainer) – Assigned the current font description.
Return type: float
Returns: The font size.

Table Of Contents