This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com
The bitmap class can be used to load, read, draw and save bitmap pictures of various formats. The constructor of BaseBitmap allows you to create a Bitmap object that contains a reference to a Bitmap object.
Note
Bitmaps are organized so that x = y = 0 is the top left corner.
MultipassBitmap
| Return type: | BaseBitmap |
|---|---|
| Returns: | The new bitmap. |
THis is similar to GetPixel(). An example:
x, y, z = bmp[5, 5] #returns the color of a pixel at position x(5), y(5)
| Raises IndexError: | |
|---|---|
| Raise this error when the pixel position is out of the bitmap. | |
| Parameter: | key (int) – The pixel position. |
| Return type: | list of int |
| Returns: | The color of a pixel. Range between 0-255. |
THis is similar to GetPixel(). An example:
bmp[5, 5] = (50, 255, 50) #returns the color of a pixel at position x(5), y(5)
| Raises IndexError: | |
|---|---|
Raise this error when the pixel position is out of the bitmap. |
|
| Parameters: |
|
Sets the pixel at (x, y) to the color specified by (r,g,b) (0 <= r/g/b <= 255). Similar to the __setitem__()
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if successful, otherwise False. |
Retrieves the color at (x,y) and assigns it to the passed pointers (r,g,b) (0 <= r/g/b <= 255). Similar to the __getitem__()
| Parameters: |
|
|---|---|
| Return type: | list of int |
| Returns: | The color of the pixel. Range between 0-255. |
Get the alpha value at (x,y) to val. The valid range of val is 0 to 255.
| Parameters: |
|
|---|---|
| Return type: | int |
| Returns: | The alpha value. |
Sets the alpha value at (x,y) to val. The valid range of val is 0 to 255.
| Parameters: |
|
|---|
Note
The bitmap class only supports up to 4 channels. Also, most image loaders will only load one alpha channel.
Initializes the bitmap to the given dimensions and depth. Any previous data in the bitmap object is lost.
| Parameters: |
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | int |
||||||||||||
| Returns: | The result:
|
Note
The bitmap class only supports up to 4 channels. Also, most image loaders will only load one alpha channel.
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('example_path')
if result==bitmaps.IMAGE_OK: #int check
# picture loaded
if ismovie==True: #bool check
pass # file is a movie
else:
pass # file is no movie
| Parameters: |
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | list |
||||||||||||
| Returns: | The result for first element:
|
Returns a bool if the object is empty. Requires a call to BaseBitmap.init() before the bitmap can be used again.
| Return type: | bool |
|---|---|
| Returns: | True if BaseBitmap is not empty, otherwise False. |
Clones the Bitmap and returns a new instance.
| Return type: | BaseBitmap |
|---|---|
| Returns: | The clone. |
Copies a part of the bitmap, specified by the rectangle (x,y) to (x+w,y+h).
| Parameters: |
|
|---|---|
| Return type: | BaseBitmap or None |
| Returns: | The cloned bitmap, or None if an error occured. |
Returns a bool if the object is empty. Requires a call to BaseBitmap.Init() before the bitmap can be used again:
FILTER_TIF TIF FILTER_TGA TGA FILTER_BMP BMP FILTER_IFF IFF FILTER_JPG JPG FILTER_PICT PICT FILTER_PSD PSD FILTER_RLA RLA FILTER_RPF RPF FILTER_B3D Bodypaint
| Parameters: |
|
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | int |
||||||||||||||
| Returns: | True if BaseBitmap is not empty, otherwise False.
|
Returns the number of alpha channels in the bitmap, including the internal channel.
| Return type: | int |
|---|---|
| Returns: | Number of alpha channels. |
Checks if a position is in the bitmap.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the coordinate is in the bitmap. |
Returns the size of the bitmap in pixels. 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.get_size()
| Return type: | list of int |
|---|---|
| Returns: | Bitmap width and height in pixels, or 0 if the bitmap isn’t initialized. |
Returns the width of the bitmap in pixels. 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 isn’t initialized. |
Returns the height of the bitmap in pixels.
| Return type: | int |
|---|---|
| Returns: | Bitmap height in pixels. |
Returns the number of bits per pixel.
| Return type: | int |
|---|---|
| Returns: | The number of bits. |
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: |
|
|---|
Returns the number of bytes per line.
| Return type: | int |
|---|---|
| Returns: | Number of bytes per line. |
Returns the height of the bitmap in pixels.
| Parameters: |
|
||||||
|---|---|---|---|---|---|---|---|
| Return type: | bool |
||||||
| Returns: | True if the data could be set, otherwise False. |
Gets bitmap data.
| Parameters: |
|
||||||
|---|---|---|---|---|---|---|---|
| Return type: | float or type(default) |
||||||
| Returns: | the retrieved data, or default. |
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.
Note
This function can currently only scale down, i.e. the destination needs to be smaller or equal to the source in size.
| Parameters: |
|
|---|
Scales the bitmap to fit in the destination bitmap and copies it there. The destination needs to be initialized with the destination size before calling this function.
| Parameters: |
|
|---|---|
| Return type: | BaseBitmap |
| Returns: | The scaled bitmap. |
Adds a new alpha channel to the image.
| Parameters: |
|
|---|---|
| Return type: | int |
| Returns: | The new channel. |
Removes the specified channel from the bitmap.
| Parameter: | channel (BaseBitmap) – The alpha channels to use. |
|---|
Returns the channel ID from the channel index.
| Parameters: |
|
|---|
Private.
| Return type: | int |
|---|---|
| Returns: | Dirty count, incremented when the bitmap changes. |
Checks if the image is a MultipassBitmap.
| Return type: | bool |
|---|---|
| Returns: | True if the image is a MultipassBitmap, otherwise False |
Returns the color mode of the bitmap.
| Return type: | int |
||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns: | Color mode
|
Returns a line of pixels.
| Parameter: | mode (int) – The mode. Currently only DEZ_MODE is avaible. |
|---|---|
| Return type: | list of type Vector |
| Returns: | The element count is equal to get_width |
Get the size of the memory used by the bitmap.
| Return type: | long |
|---|---|
| Returns: | Memory size of the bitmap. |
Get the updated region of a bitmap.
| Return type: | BaseBitmap |
|---|---|
| Returns: | The updated region. |