c4d.bitmaps.BaseBitmap

class c4d.bitmaps.BaseBitmap
The bitmap class can be used to load, read, draw and save bitmap pictures of various formats.
Be sure to call BaseBitmap.Init() before you attempt to use a newly allocated bitmap.

Note

Bitmaps are organized so that x = y = 0 is the top left corner.

Note

Though the bitmap class can work with other bit depths than 24 and 32, please note that only these function support other bit depths: BaseBitmap.GetBw(), BaseBitmap.GetBh(), BaseBitmap.GetBt(), BaseBitmap.GetBpz(), BaseBitmap.Init(), BaseBitmap.GetPixelCnt(), BaseBitmap.SetPixelCnt(), BaseBitmap.SetCMAP(), BaseBitmap.AddChannel(), BaseBitmap.RemoveChannel(), BaseBitmap.GetAlphaPixel(), BaseBitmap.SetAlphaPixel(), BaseBitmap.GetChannelCount(), BaseBitmap.GetChannelNum() (to use higher bit depths or multiple channels, see MultipassBitmap).

See also

Copy32BitImage.py for an example showing how to copy the internal data of an image to a new one.

Methods Signatures

BaseBitmap.__init__(self,)
rtype:BaseBitmap
BaseBitmap.__getitem__(self, key) This is similar to GetPixel().
BaseBitmap.__setitem__(self, key, value) This is similar to GetPixel().
BaseBitmap.__eq__(self, other)  
BaseBitmap.__ne__(self, other) Check if two references point to the same bitmap.
BaseBitmap.SetPixel(self, x, y, r, g, b)
Sets the pixel at (x, y) to the color specified by (r,g,b) (0 <= r/g/b <= 255).
BaseBitmap.GetPixel(self, x, y) Retrieves the color at (x,y). Similar to the __getitem__().
BaseBitmap.GetPixelCnt(self, x, y, cnt, ...[, ...]) Reads cnt pixels from (x, y) in the bitmap to the buffer with mode dstmode, incrementing inc bytes for each pixel.
BaseBitmap.SetPixelCnt(self, x, y, cnt, ...) Sets cnt pixels at (x, y) in the bitmap from buffer with mode srcmode, incrementing inc bytes for each pixel.
BaseBitmap.GetInternalChannel(self,)
Get the internal read-only alpha channel.
BaseBitmap.GetAlphaPixel(self, channel, x, y) Get the alpha value at (x,y).
BaseBitmap.SetAlphaPixel(self, channel, x, y, val) Sets the alpha value at (x,y) to val. The valid range of val is 0 to 255.
BaseBitmap.Init(self, x, y[, depth, flags]) Initializes the bitmap to the given dimensions and depth.
BaseBitmap.InitWith(self, name[, frame])
Loads a file into the bitmap. The file can be either a movie or a picture.
BaseBitmap.FlushAll(self,) Resets the bitmap to its initial state and frees allocated memory.
BaseBitmap.SetColorProfile(self, profile) Copy the color profile to the bitmap.
BaseBitmap.GetColorProfile(self,) Get a new color profile instance of the bitmap.
BaseBitmap.CopyTo(self, dst) Copies the image to dst.
BaseBitmap.CopyPartTo(self, dst, x, y, w, h) Copies a part of the image to dst.
BaseBitmap.GetClone(self,) Clones the Bitmap and returns a new instance.
BaseBitmap.GetClonePart(self, x, y, w, h) Clones a part of the bitmap, specified by the rectangle (x,y) to (x+w,y+h).
BaseBitmap.Save(self, name, format[, ...]) Saves the bitmap to a file. Valid formats are:
BaseBitmap.GetChannelCount(self,) Returns the number of alpha channels in the bitmap, including the internal channel.
BaseBitmap.Within(self, x, y) Checks if a position is in the bitmap.
BaseBitmap.GetSize(self,) Returns the size of the bitmap in pixels.
BaseBitmap.GetBw(self,) Returns the width of the bitmap in pixels.
BaseBitmap.GetBh(self,) Returns the height of the bitmap in pixels.
BaseBitmap.GetBt(self,) Returns the number of bits per pixel.
BaseBitmap.SetCMAP(self, i, r, g, b)
If the image in the bitmap has 8 bit indexed color, this function can be used to set the palette entries.
BaseBitmap.GetBpz(self,) Returns the number of bytes per line.
BaseBitmap.SetData(self, id, data) Sets bitmap data. Private.
BaseBitmap.GetData(self, id, default) Gets bitmap data. Private.
BaseBitmap.ScaleBicubic(self, dst, src_xmin, ...)
Scales the bitmap rectangle (src_xmin, src_ymin, src_xmax, src_ymax) to fit in the destination bitmap rectangle (dst_xmin, dst_ymin, dst_xmax, dst_ymax) and copies it there.
BaseBitmap.ScaleIt(self, dst, intens, ...) Scales the bitmap to fit in the destination bitmap and copies it there.
BaseBitmap.AddChannel(self, internal, straight) Adds a new alpha channel to the image.
BaseBitmap.RemoveChannel(self, channel) Removes the specified channel from the bitmap.
BaseBitmap.GetChannelNum(self, num) Returns the channel ID from the channel index.
BaseBitmap.GetDirty(self,) Private.
BaseBitmap.SetDirty(self,) Makes the bitmap dirty.
BaseBitmap.IsMultipassBitmap(self,) Checks if the image is a MultipassBitmap.
BaseBitmap.GetColorMode(self,) Returns the color mode of the bitmap.
BaseBitmap.GetMemoryInfo(self,) Get the size of the memory used by the bitmap.
BaseBitmap.GetUpdateRegionBitmap(self,) Get the updated region of a bitmap.

Inheritance

Inheritance

Child Class:

Methods Documentation

BaseBitmap.__init__(self)
Return type:BaseBitmap
Returns:The new bitmap.
BaseBitmap.__getitem__(self, key)

This is similar to GetPixel().

r, g, b = bmp[5, 5] #returns the color of a pixel at position x(5), y(5)
Raises:IndexError – If the pixel position is out of the bitmap boundaries. See GetSize(), GetBw() and GetBh().
Parameters:key (int) – The pixel position.
Return type:tuple(int, int, int)
Returns:The color of a pixel. Range between 0-255.
BaseBitmap.__setitem__(self, key, value)

This is similar to GetPixel().

bmp[5, 5] = (50, 255, 50) #returns the color of a pixel at position x(5), y(5)

Note

The Vector objects does not support item deletion.
For instance by calling del(bmp[5,5]).
Raises:

IndexError – If the pixel position is out of the bitmap boundaries. See GetSize(), GetBw() and GetBh().

Parameters:
  • key (int) – The pixel position.
  • value (tuple(int, int, int)) – The color of the pixel. Range between 0-255.
BaseBitmap.__eq__(self, other)
BaseBitmap.__ne__(self, other)

Check if two references point to the same bitmap.

Note

Does not compare if two references are equal.

BaseBitmap.SetPixel(self, x, y, r, g, b)
Sets the pixel at (x, y) to the color specified by (r,g,b) (0 <= r/g/b <= 255).
Similar to the __setitem__().

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) – The X coordinate.
  • y (int) – The Y coordinate.
  • r (int) – The red component.
  • g (int) – The green component.
  • b (int) – The blue component.
Return type:

bool

Returns:

True if successful, otherwise False.

BaseBitmap.GetPixel(self, x, y)

Retrieves the color at (x,y). Similar to the __getitem__().

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) – The X coordinate.
  • y (int) – The Y coordinate.
Return type:

List[int]

Returns:

The color of the pixel. Range between 0-255.

BaseBitmap.GetPixelCnt(self, x, y, cnt, buffer, inc, dstmode, flags, conversion=None)

Reads cnt pixels from (x, y) in the bitmap to the buffer with mode dstmode, incrementing inc bytes for each pixel.

Parameters:
  • x (int) – X coordinate of the first pixel to set.
  • y (int) – Y coordinate of the first pixel to set.
  • cnt (int) – Number of pixels to set.
  • buffer (c4d.storage.ByteSeq) – The destination buffer.
  • inc (int) – The byte increment per pixel in the buffer.
  • dstmode (int) –

    The destination mode:

    COLORMODE_ILLEGAL Illegal 8-bit mode.
    COLORMODE_ALPHA Only 8-bit alpha channel.
    COLORMODE_GRAY 8-bit grayscale channel.
    COLORMODE_AGRAY 8-bit grayscale channel with 8-bit alpha.
    COLORMODE_RGB 8-bit RGB channels.
    COLORMODE_ARGB 8-bit RGB channels with 8-bit alpha.
    COLORMODE_CMYK 8-bit CMYK channel.
    COLORMODE_ACMYK 8-bit CMYK channel with 8-bit alpha.
    COLORMODE_MASK 8-bit grayscale map as mask.
    COLORMODE_AMASK 8-bit grayscale map as mask with 8-bit alpha.
    COLORMODE_ILLEGALw Illegal 16-bit mode.
    COLORMODE_GRAYw 16-bit grayscale channel.
    COLORMODE_AGRAYw 16-bit grayscale channel with 16-bit alpha.
    COLORMODE_RGBw 16-bit RGB channels.
    COLORMODE_ARGBw 16-bit RGB channels with 16-bit alpha.
    COLORMODE_MASKw 16-bit grayscale map as mask with 16-bit alpha.
    COLORMODE_ILLEGALf Illegal 32-bit mode.
    COLORMODE_GRAYf 32-bit floating point grayscale channel.
    COLORMODE_AGRAYf 32-bit floating point grayscale channel with floating point alpha.
    COLORMODE_RGBf 32-bit floating point RGB channels.
    COLORMODE_ARGBf 32-bit floating point RGB channels with floating point alpha.
    COLORMODE_MASKf 32-bit floating point grayscale map as mask.
  • flags (int) –

    Flags:

    PIXELCNT_NONE None.
    PIXELCNT_DITHERING Allow dithering.
    PIXELCNT_B3DLAYERS Merge BodyPaint 3D layers (MultipassBitmap).
    PIXELCNT_APPLYALPHA Apply alpha layers to the result (PaintLayerBmp).
    PIXELCNT_INTERNAL_SETLINE Internal SetLine indicator. Private.
    PIXELCNT_INTERNAL_ALPHAVALUE Get also the alpha value (RGBA 32-bit). Private.
  • conversion (c4d.bitmaps.ColorProfileConvert) –

    New in version R17.032.

    This should be normally set to None. Pass a color profile only if a conversion is wanted before retrieving the pixel data.
    This only works if either the bitmap is 32-bit per component (so no 8/16-bit images) or the dstmode is 32-bit per component.
    The conversion is done before color reduction (e.g. if dstmode is 16-bit the profile is first applied and then the data resampled to 16-bit).
Return type:

bool

Returns:

True if successful, otherwise False.

BaseBitmap.SetPixelCnt(self, x, y, cnt, buffer, inc, srcmode, flags)

Sets cnt pixels at (x, y) in the bitmap from buffer with mode srcmode, incrementing inc bytes for each pixel.

The following example shows you how to read/write from/into an image.

'''
Test Example:
BaseBitmap.SetPixelCnt()/BaseBitmap.GetPixelCnt()

This example shows how to copy the internal data of a 32 bit per-channel image to a new one.
'''

import c4d, struct

def main():
    path = c4d.storage.LoadDialog(type=c4d.FILESELECTTYPE_IMAGES, title="Please Choose a 32 Bit Image:")
    if not path: return

    # Create and initialize selected image
    orig = c4d.bitmaps.BaseBitmap()
    if orig.InitWith(path)[0] != c4d.IMAGERESULT_OK:
        c4d.gui.MessageDialog("Cannot load image "" + path + "".")
        return

    # Check if channel depth is really 32 bit
    if orig.GetBt()/3 != 32:
        c4d.gui.MessageDialog("The image "" + path + "" is not a 32 bit per-channel image.")
        return

    # Get selected image infos
    width, height = orig.GetSize()
    bits = orig.GetBt()

    # Create the copy and initialize it
    copy = c4d.bitmaps.BaseBitmap()
    copy.Init(width, height, bits)

    # Calculate the number of bytes per pixel
    inc = orig.GetBt()/8 # Each pixel has RGB bits, so we need an offset of 'inc' bytes per pixel
                                              # the image has 32 bits per-channel : (32*3)/8 = 12 bytes per pixel (1 byte = 8 bits)
                                              # the image has 3 channels per pixel (RGB) : 12/3 = 4 bytes per component = 1 float

    # Create a byte sequence buffer large enough to store the copied image pixels
    sq = c4d.storage.ByteSeq(None, width*height*inc)

    for row in xrange(height):
        offset = sq.GetOffset(row*(width*inc)) # Offset on bitmap row + offset bytes per pixel
        orig.GetPixelCnt(0, row, width, offset, inc, c4d.COLORMODE_RGBf, c4d.PIXELCNT_NONE) # Read pixels from the original bitmap to the buffer

    #Example: RGB value of first pixel (only for 32 bits)
    #import struct
    #r, g, b = struct.unpack("fff", sq[0:12])
    #print r, g, b

    for row in xrange(height):
        offset = sq.GetOffset(row*(width*inc)) # Offset on bitmap row + offset bytes per pixel
        copy.SetPixelCnt(0, row, width, offset, inc, c4d.COLORMODE_RGBf, c4d.PIXELCNT_NONE) # Set pixels in bitmap copy

    c4d.bitmaps.ShowBitmap(orig) # Show original
    c4d.bitmaps.ShowBitmap(copy) # Show copied image


if __name__=='__main__':
    main()
Parameters:
  • x (int) – X coordinate of the first pixel to set.
  • y (int) – Y coordinate of the first pixel to set.
  • cnt (int) – Number of pixels to set.
  • buffer (c4d.storage.ByteSeq) – The source buffer.
  • inc (int) – The byte increment per pixel in the buffer.
  • srcmode (int) –

    The source mode.

    Note

    None of the alpha modes are supported.

    COLORMODE_ILLEGAL Illegal 8-bit mode.
    COLORMODE_ALPHA Only 8-bit alpha channel.
    COLORMODE_GRAY 8-bit grayscale channel.
    COLORMODE_AGRAY 8-bit grayscale channel with 8-bit alpha.
    COLORMODE_RGB 8-bit RGB channels.
    COLORMODE_ARGB 8-bit RGB channels with 8-bit alpha.
    COLORMODE_CMYK 8-bit CMYK channel.
    COLORMODE_ACMYK 8-bit CMYK channel with 8-bit alpha.
    COLORMODE_MASK 8-bit grayscale map as mask.
    COLORMODE_AMASK 8-bit grayscale map as mask with 8-bit alpha.
    COLORMODE_ILLEGALw Illegal 16-bit mode.
    COLORMODE_GRAYw 16-bit grayscale channel.
    COLORMODE_AGRAYw 16-bit grayscale channel with 16-bit alpha.
    COLORMODE_RGBw 16-bit RGB channels.
    COLORMODE_ARGBw 16-bit RGB channels with 16-bit alpha.
    COLORMODE_MASKw 16-bit grayscale map as mask with 16-bit alpha.
    COLORMODE_ILLEGALf Illegal 32-bit mode.
    COLORMODE_GRAYf 32-bit floating point grayscale channel.
    COLORMODE_AGRAYf 32-bit floating point grayscale channel with floating point alpha.
    COLORMODE_RGBf 32-bit floating point RGB channels.
    COLORMODE_ARGBf 32-bit floating point RGB channels with floating point alpha.
    COLORMODE_MASKf 32-bit floating point grayscale map as mask.
  • flags (int) –

    Flags:

    PIXELCNT_NONE None.
    PIXELCNT_DITHERING Allow dithering.
    PIXELCNT_B3DLAYERS Merge BodyPaint 3D layers (MultipassBitmap).
    PIXELCNT_APPLYALPHA Apply alpha layers to the result (PaintLayerBmp).
    PIXELCNT_INTERNAL_SETLINE Internal SetLine indicator. Private.
    PIXELCNT_INTERNAL_ALPHAVALUE Get also the alpha value (RGBA 32-bit). Private.
Return type:

bool

Returns:

True if successful, otherwise False.

BaseBitmap.GetInternalChannel(self)
Get the internal read-only alpha channel.
The internal alpha channel is the one that’s saved together with the picture, with those formats that support this.

Note

If no internal alpha is available, None is returned.

Return type:c4d.bitmaps.BaseBitmap
Returns:The internal alpha channel.
BaseBitmap.GetAlphaPixel(self, channel, x, y)

Get the alpha value at (x,y).

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:
  • bmp (c4d.bitmaps.BaseBitmap) – The alpha channels to use. Has to be an alpha bitmap.
  • x (int) – X coordinate.
  • y (int) – Y coordinate.
Return type:

int

Returns:

The alpha value. Range is 0 to 255.

BaseBitmap.SetAlphaPixel(self, channel, x, y, val)

Sets the alpha value at (x,y) to val. The valid range of val is 0 to 255.

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:
  • bmp (c4d.bitmaps.BaseBitmap) – The alpha channels to use. Has to be an alpha bitmap.
  • x (int) – X coordinate.
  • y (int) – Y coordinate.
  • val (int) – The alpha value. Range is 0 to 255.
BaseBitmap.Init(self, x, y, depth=24, flags=INITBITMAPFLAGS_NONE)

Initializes the bitmap to the given dimensions and depth.

Warning

Any previous data in the bitmap object is lost.

Note

The bitmap class only supports up to 4 channels.
Also, most image loaders will only load one alpha channel.
Parameters:
  • x (int) – The requested width in pixels. (Max 16000 pixels.).
  • y (int) – The requested width in pixels. (Max 16000 pixels.).
  • depth (int) –
    The requested bit depth (24 default).
    The possible values are {1,4,8,16,24,32}.
    On some platforms 32 bits will be used even if 24 is requested, to allow for padding.
  • flags (int) –

    Flags:

    INITBITMAPFLAGS_NONE None.
    INITBITMAPFLAGS_GRAYSCALE Initializes as grayscale bitmap.
    INITBITMAPFLAGS_SYSTEM Private.
Return type:

int

Returns:

The result:

IMAGERESULT_OK Image loaded/created.
IMAGERESULT_NOTEXISTING Image does not exist.
IMAGERESULT_WRONGTYPE Image has the wrong type.
IMAGERESULT_OUTOFMEMORY Not enough memory.
IMAGERESULT_FILEERROR File error.
IMAGERESULT_FILESTRUCTURE Invalid file structure.
IMAGERESULT_MISC_ERROR Unknown error.
IMAGERESULT_PARAM_ERROR Parameter error.
IMAGERESULT_THREADCANCELED Thread canceled while working.

BaseBitmap.InitWith(self, name, frame=-1)
Loads a file into the bitmap. The file can be either a movie or a picture.
The file format is automatically detected
result, isMovie = bmp.InitWith(path)
if result == c4d.IMAGERESULT_OK: #int check
    # picture loaded

    if isMovie: #bool check
        pass # file is a movie
    else:
        pass # file is no movie

Note

The bitmap class only supports up to 4 channels.
Also, most image loaders will only load one alpha channel.
Parameters:
Return type:

tuple(int, bool)

Returns:

The result for first element:

IMAGERESULT_OK Image loaded/created.
IMAGERESULT_NOTEXISTING Image does not exist.
IMAGERESULT_WRONGTYPE Image has the wrong type.
IMAGERESULT_OUTOFMEMORY Not enough memory.
IMAGERESULT_FILEERROR File error.
IMAGERESULT_FILESTRUCTURE Invalid file structure.
IMAGERESULT_MISC_ERROR Unknown error.
IMAGERESULT_PARAM_ERROR Parameter error.
IMAGERESULT_THREADCANCELED Thread canceled while working.

The second element is True if the loaded picture was a movie.

BaseBitmap.FlushAll(self)

Resets the bitmap to its initial state and frees allocated memory.

Warning

Requires a call to Init() before the bitmap can be used again.

BaseBitmap.SetColorProfile(self, profile)

Copy the color profile to the bitmap.

Parameters:profile (c4d.bitmaps.ColorProfile) – The profile.
Return type:bool
Returns:True on success, otherwise False.
BaseBitmap.GetColorProfile(self)

Get a new color profile instance of the bitmap.

Return type:c4d.bitmaps.ColorProfile
Returns:The profile.
BaseBitmap.CopyTo(self, dst)

Copies the image to dst.

Parameters:dst (c4d.bitmaps.BaseBitmap) – The bitmap to copy the image to.
Return type:bool
Returns:Success of copying the image.
BaseBitmap.CopyPartTo(self, dst, x, y, w, h)

Copies a part of the image to dst.

Parameters:
  • dst (c4d.bitmaps.BaseBitmap) – The bitmap to copy the image to.
  • x (int) – The X position of the part to be copied from the source image.
  • y (int) – The Y position of the part to be copied from the source image.
  • w (int.) – The width of the part to be copied.
  • h (int) – The height of the part to be copied.
Return type:

bool

Returns:

Success of copying the image.

BaseBitmap.GetClone(self)

Clones the Bitmap and returns a new instance.

Return type:c4d.bitmaps.BaseBitmap
Returns:The clone.
BaseBitmap.GetClonePart(self, x, y, w, h)

Clones a part of the bitmap, specified by the rectangle (x,y) to (x+w,y+h).

Parameters:
  • x (int) – The upper X coordinate of the rectangle.
  • y (int) – The upper Y coordinate of the rectangle.
  • w (int.) – The width of the rectangle.
  • h (int) – The height of the rectangle.
Return type:

c4d.bitmaps.BaseBitmap

Returns:

The cloned bitmap, or None if an error occured.

BaseBitmap.Save(self, name, format, data=None, savebits=SAVEBIT_NONE)

Saves the bitmap to a file. Valid formats are:

FILTER_TIF TIFF.
FILTER_TGA TGA.
FILTER_BMP BMP.
FILTER_IFF IFF.
FILTER_JPG JPEG.
FILTER_PICT PICT.
FILTER_PSD PSD.
FILTER_RLA RLA.
FILTER_RPF RPF.
FILTER_B3D BodyPaint 3D.
FILTER_TIF_B3D TIFF BodyPaint 3D.
FILTER_PSB PSB.
FILTER_AVI AVI Movie.
FILTER_MOVIE Quicktime Movie.
FILTER_QTVRSAVER_PANORAMA QTVR Panorama.
FILTER_QTVRSAVER_OBJECT QTVR Object.
FILTER_HDR HDR.
FILTER_EXR_LOAD EXR (Load).
FILTER_EXR EXR.
FILTER_PNG PNG.
FILTER_IES IES.
FILTER_B3DNET BodyPaint 3D NET. Private.
FILTER_DPX DPX.
FILTER_DDS

New in version R19: DDS.

Parameters:
  • name (Union[str, c4d.storage.MemoryFileStruct]) – A file.
  • format (int) – The image format.
  • data (c4d.BaseContainer) – The data.
  • savebits (int) –

    Can be a combination of the following flags:

    SAVEBIT_NONE None.
    SAVEBIT_ALPHA Save the alpha channel(s) in the file. (For filter plugins, do not save an alpha channel if this is not set.)
    SAVEBIT_MULTILAYER Save multiple layers.
    SAVEBIT_USESELECTEDLAYERS Use selected layers.
    SAVEBIT_16BITCHANNELS Use 16-bit channels.
    SAVEBIT_GREYSCALE Save in grayscale mode.
    SAVEBIT_INTERNALNET Private.
    SAVEBIT_DONTMERGE Avoid merging of layers in BodyPaint 3D files.
    SAVEBIT_32BITCHANNELS Use 32-bit channels.
    SAVEBIT_SAVERENDERRESULT Private.
    SAVEBIT_FIRSTALPHA_ONLY Private.
Return type:

int

Returns:

True if BaseBitmap is not empty, otherwise False.

IMAGERESULT_OK Image loaded/created.
IMAGERESULT_NOTEXISTING Image does not exist.
IMAGERESULT_WRONGTYPE Image has the wrong type.
IMAGERESULT_OUTOFMEMORY Not enough memory.
IMAGERESULT_FILEERROR File error.
IMAGERESULT_FILESTRUCTURE Invalid file structure.
IMAGERESULT_MISC_ERROR Unknown error.
IMAGERESULT_PARAM_ERROR Parameter error.
IMAGERESULT_THREADCANCELED Thread canceled while working.

BaseBitmap.GetChannelCount(self)

Returns the number of alpha channels in the bitmap, including the internal channel.

Return type:int
Returns:Number of alpha channels.
BaseBitmap.Within(self, x, y)

Checks if a position is in the bitmap.

Parameters:
  • x (int) – The X Coordinate
  • y (int) – The Y Coordinate
Return type:

bool

Returns:

True if the coordinate is in the bitmap.

BaseBitmap.GetSize(self)

Returns the size of the bitmap in pixels.

Note

If the bitmap hasn’t been initialized the return values are 0. (This is the only way to see if a bitmap has been initialized.)

#bmp is a BaseBitmap instance
x, y = bmp.GetSize()
Return type:List[int]
Returns:Bitmap width and height in pixels, or 0 if the bitmap is not initialized.
BaseBitmap.GetBw(self)

Returns the width of the bitmap in pixels.

Note

If the bitmap hasn’t been initialized the return value is 0. (This is the only way to see if a bitmap has been initialized.)

Return type:int
Returns:Bitmap width in pixels, or 0 if the bitmap is not initialized.
BaseBitmap.GetBh(self)

Returns the height of the bitmap in pixels.

Return type:int
Returns:Bitmap height in pixels.
BaseBitmap.GetBt(self)

Returns the number of bits per pixel.

Return type:int
Returns:The number of bits.
BaseBitmap.SetCMAP(self, i, r, g, b)
If the image in the bitmap has 8 bit indexed color, this function can be used to set the palette entries.
All four parameters must be between 0 and 255.
Parameters:
  • i (int) – The index.
  • r (int) – The red component.
  • g (int) – The green component.
  • b (int) – The blue component.
BaseBitmap.GetBpz(self)

Returns the number of bytes per line.

Return type:int
Returns:Number of bytes per line.
BaseBitmap.SetData(self, id, data)

Sets bitmap data. Private.

Parameters:
  • id (int) – The data ID to set.
  • data (any) – The data to set.
Return type:

bool

Returns:

True if the data could be set, otherwise False.

BaseBitmap.GetData(self, id, default)

Gets bitmap data. Private.

Parameters:
  • id (int) – The data ID to get.
  • default (any) – Returned if data is not set.
Return type:

Any

Returns:

The retrieved data, or default.

BaseBitmap.ScaleBicubic(self, dst, src_xmin, src_ymin, src_xmax, src_ymax, dst_xmin, dst_ymin, dst_xmax, dst_ymax)
Scales the bitmap rectangle (src_xmin, src_ymin, src_xmax, src_ymax) to fit in the destination bitmap rectangle (dst_xmin, dst_ymin, dst_xmax, dst_ymax) and copies it there.
The scaling, if necessary, is done using bicubic interpolation.
The destination needs to be initialized before calling this function.
bmp.ScaleBicubic(dst, 0, 0, bmp.GetBw()-1, bmp.GetBh()-1, 0, 0, dst.GetBw()-1, dst.GetBh()-1)

Note

This function can currently only scale down, i.e. the destination needs to be smaller to the source in size.

../../../_images/basebitmap_scalebicubic.jpg
Parameters:
  • dst (c4d.bitmaps.BaseBitmap) – The destination bitmap.
  • src_xmin (int) – Source top left X coordinate.
  • src_ymin (int) – Source top left Y coordinate.
  • src_xmax (int) – Source bottom right X coordinate.
  • src_ymax (int) – Source bottom right Y coordinate.
  • dst_xmin (int) – Destination top left X coordinate.
  • dst_ymin (int) – Destination top left Y coordinate.
  • dst_xmax (int) – Destination bottom right X coordinate.
  • dst_ymax (int) – Destination bottom right Y coordinate.
BaseBitmap.ScaleIt(self, dst, intens, sample, inprop)

Scales the bitmap to fit in the destination bitmap and copies it there.

Note

The destination needs to be initialized with the destination size before calling this function.

../../../_images/basebitmap_scaleit.jpg
Parameters:
  • dst (c4d.bitmaps.BaseBitmap) – The destination image. Must be initiated already with the destination size.
  • intens (int) – Lets you change brightness of the image (128 = 50% brightness, 256 = unchanged).
  • sample (bool) – If True a better scaling algorithm is used, which results in a better quality but is a bit slower.
  • inprop (bool) – Must be True if non-proportional scaling is wanted.
BaseBitmap.AddChannel(self, internal, straight)

Adds a new alpha channel to the image.

Parameters:
  • internal (bool) –
    Should only be True for the first alpha.
    The internal alpha will be stored within an image if the image format supports alphas.
  • straight (bool) –
    Should be True if the image has to be interpreted as straight.
    For information about straight alphas please take a look at the corresponding option in the render settings of Cinema 4D and the Cinema 4D manual.
Return type:

int

Returns:

The new channel.

BaseBitmap.RemoveChannel(self, channel)

Removes the specified channel from the bitmap.

Parameters:channel (c4d.bitmaps.BaseBitmap) – The alpha channels to use.
BaseBitmap.GetChannelNum(self, num)

Returns the channel ID from the channel index.

Parameters:num (int) – A number between 0 and GetChannelCount().
Return type:c4d.bitmaps.BaseBitmap
Returns:The requested channel.
BaseBitmap.GetDirty(self)

Private.

Return type:int
Returns:Dirty count, incremented when the bitmap changes.
BaseBitmap.SetDirty(self)

Makes the bitmap dirty.

BaseBitmap.IsMultipassBitmap(self)

Checks if the image is a MultipassBitmap.

Return type:bool
Returns:True if the image is a MultipassBitmap, otherwise False
BaseBitmap.GetColorMode(self)

Returns the color mode of the bitmap.

Return type:int
Returns:Color mode
COLORMODE_ILLEGAL Illegal 8-bit mode.
COLORMODE_ALPHA Only 8-bit alpha channel.
COLORMODE_GRAY 8-bit grayscale channel.
COLORMODE_AGRAY 8-bit grayscale channel with 8-bit alpha.
COLORMODE_RGB 8-bit RGB channels.
COLORMODE_ARGB 8-bit RGB channels with 8-bit alpha.
COLORMODE_CMYK 8-bit CMYK channel.
COLORMODE_ACMYK 8-bit CMYK channel with 8-bit alpha.
COLORMODE_MASK 8-bit grayscale map as mask.
COLORMODE_AMASK 8-bit grayscale map as mask with 8-bit alpha.
COLORMODE_ILLEGALw Illegal 16-bit mode.
COLORMODE_GRAYw 16-bit grayscale channel.
COLORMODE_AGRAYw 16-bit grayscale channel with 16-bit alpha.
COLORMODE_RGBw 16-bit RGB channels.
COLORMODE_ARGBw 16-bit RGB channels with 16-bit alpha.
COLORMODE_MASKw 16-bit grayscale map as mask with 16-bit alpha.
COLORMODE_ILLEGALf Illegal 32-bit mode.
COLORMODE_GRAYf 32-bit floating point grayscale channel.
COLORMODE_AGRAYf 32-bit floating point grayscale channel with floating point alpha.
COLORMODE_RGBf 32-bit floating point RGB channels.
COLORMODE_ARGBf 32-bit floating point RGB channels with floating point alpha.
COLORMODE_MASKf 32-bit floating point grayscale map as mask.
BaseBitmap.GetMemoryInfo(self)

Get the size of the memory used by the bitmap.

Return type:long
Returns:Memory size of the bitmap.
BaseBitmap.GetUpdateRegionBitmap(self)

Get the updated region of a bitmap.

Return type:c4d.bitmaps.BaseBitmap
Returns:The updated region.