About
A BaseBitmap object stores raster graphics image data. It can support multiple alpha channels. The BaseBitmap class is used in many different application areas inside Cinema 4D. An extensions of this class is MultipassBitmap which also supports multiple layers (see MultipassBitmap Manual).
- Warning
- For MAXON API image classes see Images Manual. For MAXON API media input and output see Media Sessions Manual.
Allocation/Deallocation
A BaseBitmap can be created with the usual tools:
After the BaseBitmap was created it has to be initiated with BaseBitmap::Init(). This can be done by
- defining the dimensions of the new BaseBitmap
- or by defining the file name of an image file to load
Also a static version of BaseBitmap::Init() exists that loads a image defined by a Filename into a given BaseBitmap object.
if (bitmap == nullptr)
maxon::Url MaxonConvert(const Filename &fn, MAXONCONVERTMODE convertMode)
@ NONE
No check if file exists under case-sensitive drives.
Bool ShowBitmap(const Filename &fn)
Definition: ge_autoptr.h:37
Manages file and path names.
Definition: c4d_file.h:94
Bool FileSelect(FILESELECTTYPE type, FILESELECT flags, const maxon::String &title, const maxon::String &force_suffix=maxon::String())
return OK
Definition: apibase.h:2690
@ OK
Image loaded/created.
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
if (bitmap == nullptr)
const Int32 height = 1080;
{
for (
Int32 y = 0; y < height; ++y)
{
bitmap->SetPixel(
x, y, red, green, blue);
}
}
Definition: c4d_tools.h:812
PyObject * x
Definition: bytesobject.h:38
Py_UCS4 * res
Definition: unicodeobject.h:1113
maxon::Int32 Int32
Definition: ge_sys_math.h:60
IMAGERESULT
Definition: ge_prepass.h:3914
unsigned long Py_ssize_t width
Definition: pycore_traceback.h:88
AutoBitmap can be used to create a BaseBitmap from an image file in the plugin resource path or a resource ID. This is typically used in a "Register" function, see Registration.
if (bitmap == nullptr)
if (localIcon == nullptr)
A simple BaseBitmap wrapper created from a filename or resource ID.
Definition: c4d_basebitmap.h:1530
Definition: c4d_basebitmap.h:428
Copy
The content of a BaseBitmap can be copied and with these functions:
const Int32 height = sourceBitmap->GetBh();
if (leftBitmap == nullptr)
const Int32 rightHalfWidth =
width - leftHalfWidth;
if (rightBitmap == nullptr)
BaseBitmap * GetClonePart(Int32 x, Int32 y, Int32 w, Int32 h) const
static void Free(BaseBitmap *&bm)
Read-Only Properties
The basic properties of a BaseBitmap are accessed with:
const Int32 bytesPerPixel = bitsPerPixel / 8;
for (
Int32 y = 0; y <= height; ++y)
{
InvertLineRGB(lineBuffer,
width);
}
void GetPixelCnt(Int32 x, Int32 y, Int32 cnt, UChar *buffer, Int32 inc, COLORMODE dstmode, PIXELCNT flags, ColorProfileConvert *conversion=nullptr) const
Definition: c4d_basebitmap.h:754
Int32 GetBw() const
Definition: c4d_basebitmap.h:567
Int32 GetBh() const
Definition: c4d_basebitmap.h:573
Bool SetPixelCnt(Int32 x, Int32 y, Int32 cnt, UChar *buffer, Int32 inc, COLORMODE srcmode, PIXELCNT flags)
Definition: c4d_basebitmap.h:767
Int32 GetBpz() const
Definition: c4d_basebitmap.h:585
COLORMODE GetColorMode() const
Int32 GetBt() const
Definition: c4d_basebitmap.h:579
#define NewMemClear(T, cnt)
Definition: defaultallocator.h:204
UChar PIX
8-bit integer pixel type.
Definition: ge_math.h:31
COLORMODE
Definition: ge_prepass.h:456
void DeleteMem(T *&p)
Definition: defaultallocator.h:257
#define iferr_return
Definition: resultbase.h:1519
The used color profile is managed with:
See also ColorProfile and ColorProfileConvert.
if (linearWorkflow)
else
DrawBitmap(_bitmap, 0, 0,
width, height, 0, 0,
width, height, drawMode);
Definition: c4d_basecontainer.h:47
Bool GetBool(Int32 id, Bool preset=false) const
Definition: c4d_basecontainer.h:295
static const ColorProfile * GetDefaultLinearRGB()
static const ColorProfile * GetDefaultSRGB()
@ DOCUMENT_LINEARWORKFLOW
Definition: ddoc.h:64
maxon::Bool Bool
Definition: ge_sys_math.h:55
@ BMP_APPLY_COLORPROFILE
Applies the color profile.
Definition: gui.h:176
const char * doc
Definition: pyerrors.h:226
Functionality
Bitmap
The content of a BaseBitmap can be scaled into another BaseBitmap:
- Warning
- MultipassBitmap overwrites these functions. The overwritten functions will scale the layers but not the alpha channels.
if (scaledBitmap == nullptr)
const Int32 originalWidth = sourceBitmap->GetBw();
const Int32 originalHeight = sourceBitmap->GetBh();
const Int32 scaledWidth = originalWidth * scale;
const Int32 scaledHeight = originalHeight * scale;
const IMAGERESULT res = scaledBitmap->Init(scaledWidth, scaledHeight);
const Int32 defaultBrightness = 256;
sourceBitmap->ScaleIt(scaledBitmap, defaultBrightness, true, false);
One can perform basic drawing operations with these functions:
- Note
- For more advanced drawing operations use a GeClipMap, see GeClipMap Manual.
bitmap->
Clear(255, 255, 255);
bitmap->
Line(100, 100, 300, 100);
bitmap->
Line(100, 200, 300, 200);
bitmap->
Arc(300, 150, 50.0, quarterCircle, -quarterCircle, 20);
bitmap->
Arc(100, 150, 50.0, quarterCircle, threeQuarterCircle, 20);
void SetPen(Int32 r, Int32 g, Int32 b)
Definition: c4d_basebitmap.h:638
void Arc(Int32 x, Int32 y, Float radius, Float angle_start, Float angle_end, Int32 subdiv=32)
Definition: c4d_basebitmap.h:683
void Clear(Int32 r, Int32 g, Int32 b)
void Line(Int32 x1, Int32 y1, Int32 x2, Int32 y2)
Definition: c4d_basebitmap.h:672
maxon::Float Float
Definition: ge_sys_math.h:66
Float32 DegToRad(Float32 r)
Definition: apibasemath.h:256
Properties
A BaseBitmap is used as the target buffer of a rendering process. Details of that rendering process are stored with the bitmap itself and are displayed by the Picture Viewer. So these settings are mostly only relevant to the rendering pipeline were the given VPBuffer can be cast into a BaseBitmap / MultipassBitmap.
The settings are:
if (bitmapButtonGUI)
{
if (bitmap)
{
const Float pixelRatio = GetPixelRatio();
if (pixelRatio == 1.0)
else
{
bitmapButtonGUI->
SetImage(bitmap,
true,
false);
}
}
}
PyCompilerFlags const char * filename
Definition: ast.h:15
Definition: c4d_string.h:39
#define BASEBITMAP_DATA_GUIPIXELRATIO
Float.
Definition: c4d_basebitmap.h:104
@ BFH_SCALEFIT
Scale fit. BFH_SCALE|BFH_FIT.
Definition: gui.h:315
Dirty
A BaseBitmap stores an incremental dirty state that is used in some scenarios to indicate that the BaseBitmap has changed.
UInt32 dirtyState = bitmap->GetDirty();
bitmap->Clear(255, 255, 255);
bitmap->SetDirty();
dirtyState = bitmap->GetDirty();
static String UIntToString(UInt32 v)
Definition: c4d_string.h:511
maxon::UInt32 UInt32
Definition: ge_sys_math.h:61
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
Pixel Data
The internally stored bitmap data of a BaseBitmap can be accessed with:
Typically used pixel formats can be defined with:
- PIX: 8-bit integer pixel type.
- PIX_C: 8-bit integer pixel type.
- PIX_W: 16-bit integer pixel type.
- PIX_F: 32-bit float pixel type.
See also COLORBYTES for macros defining bytes per pixel and ::COLORMODE for a definition of the color mode.
if (bitmap == nullptr)
const Int32 height = 1024;
const Int32 pixelBits = pixelBytes * 8;
for (
Int32 y = 0; y <= height; ++y)
{
{
lineBuffer[offset] = red;
lineBuffer[offset + 1] = green;
lineBuffer[offset + 2] = 0.0;
offset += 3;
}
}
Float32 PIX_F
32-bit float pixel type.
Definition: ge_math.h:34
maxon::UChar UChar
Definition: ge_sys_math.h:57
maxon::Float32 Float32
Definition: ge_sys_math.h:68
#define COLORBYTES_RGBf
Floating point RGB.
Definition: c4d_basebitmap.h:93
@ RGBf
32-bit floating point RGB channels.
Alpha Channels
A BaseBitmap can contain up to four alpha channels. They are represented also with BaseBitmap instances:
bitmap->Clear(255, 255, 255);
BaseBitmap* alphaChannel = bitmap->AddChannel(
true,
false);
if (alphaChannel)
{
for (
Int32 y = 0; y < height; ++y)
{
const Int32 alphaValueInt =
Int32(alphaValueFloat);
bitmap->SetAlphaPixel(alphaChannel,
x, y, alphaValueInt);
}
}
#define FILTER_PNG
PNG.
Definition: ge_prepass.h:203
@ ALPHA
Save the alpha channel(s) in the file. (For filter plugins, do not save an alpha channel if this is n...
Convert
BaseBitmap is the base class of MultipassBitmap. If a pointer to a BaseBitmap is handed over one can check if it is actually a MultipassBitmap:
{
}
else
{
}
static IMAGERESULT Init(BaseBitmap *&res, const Filename &name, Int32 frame=-1, Bool *ismovie=nullptr, BitmapLoaderPlugin **loaderplugin=nullptr, const maxon::Delegate< void(Float progress)> &progressCallback=nullptr)
Bool IsMultipassBitmap() const
Definition: c4d_basebitmap.h:968
Int32 GetLayerCount() const
Definition: c4d_basebitmap.h:1012
static String IntToString(Int32 v)
Definition: c4d_string.h:495
PyObject PyObject * result
Definition: abstract.h:43
A BaseBitmap also represents a maxon::ImageRef. This is obtained with:
Disc I/O
A BaseBitmap can read the content of an image file and save its content to an image file.
if (bitmap == nullptr)
{
Filename jpgFileName = selectedImageFile;
}
{
Filename pngFileName = selectedImageFile;
}
Filename GeFilterSetSuffix(const Filename &name, Int32 id)
void SetInt32(Int32 id, Int32 l)
Definition: c4d_basecontainer.h:505
Bool CheckSuffix(const maxon::String &str) const
#define FILTER_JPG
JPEG.
Definition: ge_prepass.h:190
#define JPGSAVER_QUALITY
Quality of JPEG images. A value between 0 (lowest) and 100 (highest).
Definition: ge_prepass.h:244
- Note
- An alternative way of loading image files is to use SendPainterCommand() with PAINTER_LOADTEXTURE.
A BaseBitmap can also be stored in a HyperFile using:
Display
A BaseBitmap or MultipassBitmap can easily displayed in the Picture Viewer:
Further Reading