BaseBitmap Manual

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:

  • BaseBitmap::Alloc(): Creates a new BaseBitmap.
  • BaseBitmap::Free(): Deletes the given BaseBitmap.

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.

// This example opens a dialog to select an image file.
// The selected file is loaded into a BaseBitmap and displayed
// in the Picture Viewer window.
Filename selectedImageFile;
// select image file
if (!selectedImageFile.FileSelect(FILESELECTTYPE::IMAGES, FILESELECT::LOAD, "Select Image"_s))
return maxon::OK;
AutoAlloc<BaseBitmap> bitmap;
if (bitmap == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// load image file into the given BaseBitmap
if (bitmap->Init(selectedImageFile) != IMAGERESULT::OK)
return maxon::IoError(MAXON_SOURCE_LOCATION, MaxonConvert(selectedImageFile, MAXONCONVERTMODE::NONE), "Could not load image file."_s);
// show BaseBitmap in the Picture Viewer
ShowBitmap(bitmap);
NONE
Definition: asset_browser.h:1
LOAD
Load.
Definition: c4d_filterdata.h:1
OK
User has selected a font.
Definition: customgui_fontchooser.h:0
IMAGES
Image files.
Definition: ge_prepass.h:1
return OK
Definition: apibase.h:2740
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
Bool ShowBitmap(const Filename &fn)
maxon::Url MaxonConvert(const Filename &fn, MAXONCONVERTMODE convertMode)
// This example creates a new BaseBitmap with Full HD resolution.
// If the BaseBitmap could be created, it is filled with a color.
AutoAlloc<BaseBitmap> bitmap;
if (bitmap == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// initialize the BaseBitmap with the given dimensions
const Int32 width = 1920;
const Int32 height = 1080;
const Int32 depth = 24;
const IMAGERESULT res = bitmap->Init(width, height, depth);
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// loop through all pixels
Random randomGen;
for (Int32 x = 0; x < width; ++x)
{
for (Int32 y = 0; y < height; ++y)
{
// set to a random color
const Int32 red = Int32(randomGen.Get01() * COLORTOINT_MULTIPLIER);
const Int32 green = Int32(randomGen.Get01() * COLORTOINT_MULTIPLIER);
const Int32 blue = Int32(randomGen.Get01() * COLORTOINT_MULTIPLIER);
bitmap->SetPixel(x, y, red, green, blue);
}
}
// show BaseBitmap in the Picture Viewer
ShowBitmap(bitmap);
PyObject * x
Definition: bytesobject.h:38
Py_UCS4 * res
Definition: unicodeobject.h:1113
IMAGERESULT
Definition: ge_prepass.h:3947
static const Float COLORTOINT_MULTIPLIER
Constant to convert from vectors color components to integers.
Definition: c4d_tools.h:26
maxon::Int32 Int32
Definition: ge_sys_math.h:51
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.

// This example loads registered and local icons using AutoBitmap.
// load a registered icon ("Cube")
AutoBitmap cubeIcon(5159);
BaseBitmap* const bitmap = cubeIcon;
if (bitmap == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
ShowBitmap(bitmap);
// load an image file in the plugin's "res" folder
AutoBitmap localIcon("icon.tif"_s);
if (localIcon == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
ShowBitmap(localIcon);

Copy

The content of a BaseBitmap can be copied and with these functions:

  • BaseBitmap::GetClone: Returns a clone of the BaseBitmap.
  • BaseBitmap::GetClonePart: Returns a clone of the defined part of the BaseBitmap.
  • BaseBitmap::CopyTo: Copies the image data into the given BaseBitmap.
  • BaseBitmap::CopyPartTo: Copies the defined part of the image data into the given BaseBitmap.
// This example creates two clones of the given source bitmap.
// The two clones contain the left and right part of the bitmap.
// get original bitmap dimensions
const Int32 width = sourceBitmap->GetBw();
const Int32 height = sourceBitmap->GetBh();
// calculate left half width
const Int32 leftHalfWidth = width / 2;
// create clone with the left half of the bitmap
BaseBitmap* leftBitmap = sourceBitmap->GetClonePart(0, 0, leftHalfWidth, height);
if (leftBitmap == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
ShowBitmap(leftBitmap);
BaseBitmap::Free(leftBitmap);
// create clone with the right half of the bitmap
const Int32 rightHalfWidth = width - leftHalfWidth;
BaseBitmap* rightBitmap = sourceBitmap->GetClonePart(leftHalfWidth, 0, rightHalfWidth, height);
if (rightBitmap == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
ShowBitmap(rightBitmap);
BaseBitmap::Free(rightBitmap);

Read-Only Properties

The basic properties of a BaseBitmap are accessed with:

  • BaseBitmap::GetBw(): Returns the width of the BaseBitmap.
  • BaseBitmap::GetBh(): Returns the height of the BaseBitmap.
  • BaseBitmap::GetBt(): Returns the image depth in bits per pixel.
  • BaseBitmap::GetBpz(): Returns the number of bytes per line.
  • BaseBitmap::GetColorMode(): Returns the color mode, see COLORMODE. Do not confuse with COLORBYTES.
  • BaseBitmap::GetMemoryInfo(): Returns the size of the memory used by the BaseBitmap.
// This example reads every line of the given BaseBitmap and
// inverts the RBG color.
// only handle 8-bit RGB bitmaps in this example
const COLORMODE colorMode = bitmap->GetColorMode();
if (colorMode != COLORMODE::RGB)
return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION);
// get bit depth and buffer size for one line
const Int32 bitsPerPixel = bitmap->GetBt();
const Int32 bytesPerPixel = bitsPerPixel / 8;
const Int32 bufferSize = bitmap->GetBpz();
// allocate memory for one line
PIX* lineBuffer = NewMemClear(PIX, bufferSize) iferr_return;
// get bitmap dimensions
const Int32 width = bitmap->GetBw();
const Int32 height = bitmap->GetBh();
// loop through all lines
for (Int32 y = 0; y <= height; ++y)
{
// read full line from the bitmap
bitmap->GetPixelCnt(0, y, width, lineBuffer, bytesPerPixel, COLORMODE::RGB, PIXELCNT::NONE);
// this is a custom function
InvertLineRGB(lineBuffer, width);
// write full line back into the bitmap
bitmap->SetPixelCnt(0, y, width, lineBuffer, bytesPerPixel, COLORMODE::RGB, PIXELCNT::NONE);
}
// delete line memory
DeleteMem(lineBuffer);
#define NewMemClear(T, cnt)
Definition: defaultallocator.h:216
COLORMODE
::Int32 Get/Set. The color mode: COLORMODE
Definition: ge_prepass.h:4
RGB
8-bit RGB channels.
Definition: ge_prepass.h:7
UChar PIX
8-bit integer pixel type.
Definition: ge_math.h:26
void DeleteMem(T *&p)
Definition: defaultallocator.h:269
#define iferr_return
Definition: resultbase.h:1531

The used color profile is managed with:

  • BaseBitmap::GetColorProfile(): Returns the used color profile.
  • BaseBitmap::SetColorProfile(): Sets the used color profile.

See also ColorProfile and ColorProfileConvert.

// This example sets the color profile according to the current
// settings of the given BaseDocument. The BaseBitmap is then drawn using
// this color profile inside a GeUserArea::DrawMsg() function.
// get linear workflow settings
const BaseContainer& docData = doc->GetDataInstanceRef();
const Bool linearWorkflow = docData.GetBool(DOCUMENT_LINEARWORKFLOW);
// set profile
if (linearWorkflow)
_bitmap->SetColorProfile(ColorProfile::GetDefaultLinearRGB());
else
_bitmap->SetColorProfile(ColorProfile::GetDefaultSRGB());
// draw bitmap using the profile
const Int32 drawMode = BMP_APPLY_COLORPROFILE;
DrawBitmap(_bitmap, 0, 0, width, height, 0, 0, width, height, drawMode);
@ DOCUMENT_LINEARWORKFLOW
Definition: ddoc.h:64
@ BMP_APPLY_COLORPROFILE
Applies the color profile.
Definition: gui.h:176
maxon::Bool Bool
Definition: ge_sys_math.h:46
const char * doc
Definition: pyerrors.h:226

Functionality

Bitmap

The content of a BaseBitmap can be scaled into another BaseBitmap:

  • BaseBitmap::ScaleIt(): Scales the image data and stores the result in the given BaseBitmap.
  • BaseBitmap::ScaleBicubic(): Scales the image data using bicubic interpolation and stores the result in the given BaseBitmap.
Warning
MultipassBitmap overwrites these functions. The overwritten functions will scale the layers but not the alpha channels.
// This example creates a new bitmap with twice the size of the source bitmap.
// The new bitmap is filled with the scaled content of the source bitmap.
// create new bitmap
AutoAlloc<BaseBitmap> scaledBitmap;
if (scaledBitmap == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// get source bitmap dimensions
const Int32 originalWidth = sourceBitmap->GetBw();
const Int32 originalHeight = sourceBitmap->GetBh();
// initialize new bitmap with twice the size
const Int32 scale = 2;
const Int32 scaledWidth = originalWidth * scale;
const Int32 scaledHeight = originalHeight * scale;
const IMAGERESULT res = scaledBitmap->Init(scaledWidth, scaledHeight);
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// fill new bitmap with scaled content of the source bitmap
const Int32 defaultBrightness = 256;
sourceBitmap->ScaleIt(scaledBitmap, defaultBrightness, true, false);

One can perform basic drawing operations with these functions:

  • BaseBitmap::Clear(): Fills the BaseBitmap with the given color.
  • BaseBitmap::SetPen(): Sets the color used with the following operations.
  • BaseBitmap::Line(): Draws a line.
  • BaseBitmap::Arc(): Draws an arc.
Note
For more advanced drawing operations use a GeClipMap, see GeClipMap Manual.
// This example fills a BaseBitmap and draws a shape.
// fill the bitmap with white pixels
bitmap->Clear(255, 255, 255);
// set the pen to black
bitmap->SetPen(0, 0, 0);
// draw lines
bitmap->Line(100, 100, 300, 100);
bitmap->Line(100, 200, 300, 200);
// draw arcs
const Float quarterCircle = DegToRad(90.0);
const Float threeQuarterCircle = DegToRad(270.0);
bitmap->Arc(300, 150, 50.0, quarterCircle, -quarterCircle, 20);
bitmap->Arc(100, 150, 50.0, quarterCircle, threeQuarterCircle, 20);
Float32 DegToRad(Float32 r)
Definition: apibasemath.h:256
maxon::Float Float
Definition: ge_sys_math.h:57

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.

  • BaseBitmap::GetData(): Returns the data for the given ID.
  • BaseBitmap::SetData(): Sets the data for the given ID.

The settings are:

// This example adds a BitmapButton to the layout of the GeDialog.
// Depending on the pixel ratio a low-res or high-res bitmap file is loaded
// and applied to the BitmapButton.
void* const customGUI = AddCustomGui(1000, CUSTOMGUI_BITMAPBUTTON, ""_s, BFH_SCALEFIT, 300, 300, settings);
BitmapButtonCustomGui* const bitmapButtonGUI = static_cast<BitmapButtonCustomGui*>(customGUI);
if (bitmapButtonGUI)
{
// allocate bitmap
AutoAlloc<BaseBitmap> bitmap;
if (bitmap)
{
String filename = "";
// get pixel ratio
const Float pixelRatio = GetPixelRatio();
// check if Retina or not
if (pixelRatio == 1.0)
filename = "lowRes.png";
else
filename = "highRes.png";
// load bitmap (GetFullFilename() is just a custom utility function)
const String fullFileName = GetFullFilename(filename);
if (bitmap->Init(fullFileName) == IMAGERESULT::OK)
{
// store ratio
bitmap->SetData(BASEBITMAP_DATA_GUIPIXELRATIO, pixelRatio);
// apply to BitmapButton
bitmapButtonGUI->SetImage(bitmap, true, false);
}
}
}
PyCompilerFlags const char * filename
Definition: ast.h:15
#define CUSTOMGUI_BITMAPBUTTON
Bitmap button custom GUI ID.
Definition: customgui_bitmapbutton.h:24
#define BASEBITMAP_DATA_GUIPIXELRATIO
::Float.
Definition: c4d_basebitmap.h:103
@ BFH_SCALEFIT
Scale fit. BFH_SCALE|BFH_FIT.
Definition: gui.h:316

Dirty

A BaseBitmap stores an incremental dirty state that is used in some scenarios to indicate that the BaseBitmap has changed.

  • BaseBitmap::GetDirty(): Returns the incremental dirty state.
  • BaseBitmap::SetDirty(): Increments the dirty state.
// This example changes the given BaseBitmap and uses dirty flags
// to detect the change.
// check dirty state
UInt32 dirtyState = bitmap->GetDirty();
ApplicationOutput("Dirty State: " + String::UIntToString(dirtyState));
// edit bitmap and make dirty
bitmap->Clear(255, 255, 255);
bitmap->SetDirty();
// check dirty state
dirtyState = bitmap->GetDirty();
ApplicationOutput("Dirty State: " + String::UIntToString(dirtyState));
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
maxon::UInt32 UInt32
Definition: ge_sys_math.h:52

Pixel Data

The internally stored bitmap data of a BaseBitmap can be accessed with:

  • BaseBitmap::GetPixel(): Gets the RGB values for the given coordinates.
  • BaseBitmap::SetPixel(): Sets the RGB values for the given coordinates.
  • BaseBitmap::GetPixelCnt(): Copies the data of multiple pixel in a row into the given buffer.
  • BaseBitmap::SetPixelCnt(): Copies the data of multiple pixels in a row from the given buffer into the BaseBitmap.

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.

// This example creates and fills a 32-bit RGBf BaseBitmap.
AutoAlloc<BaseBitmap> bitmap;
if (bitmap == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// define bitmap dimensions and bit depth
const Int32 width = 1024;
const Int32 height = 1024;
const Int32 pixelBytes = COLORBYTES_RGBf; // RGBf format
const Int32 pixelBits = pixelBytes * 8;
// initialize the BaseBitmap with the given dimensions and bit depth
const IMAGERESULT res = bitmap->Init(width, height, pixelBits);
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// allocate memory for one line
const Int32 bufferSize = width * 3;
PIX_F* lineBuffer = NewMemClear(PIX_F, bufferSize) iferr_return;
// loop through all lines
for (Int32 y = 0; y <= height; ++y)
{
// shade of red based on the position
const Float32 red = Float32(y) / Float32(height);
Int32 offset = 0;
for (Int32 x = 0; x < width; ++x)
{
// shade of green based on the position
const Float32 green = Float32(x) / Float32(width);
// fill buffer
lineBuffer[offset] = red;
lineBuffer[offset + 1] = green;
lineBuffer[offset + 2] = 0.0;
offset += 3;
}
// write full line into the bitmap
bitmap->SetPixelCnt(0, y, width, (UChar*)lineBuffer, pixelBytes, COLORMODE::RGBf, PIXELCNT::NONE);
}
// delete line memory
DeleteMem(lineBuffer);
RGBf
32-bit floating point RGB channels.
Definition: ge_prepass.h:30
#define COLORBYTES_RGBf
Floating point RGB.
Definition: c4d_basebitmap.h:92
maxon::UChar UChar
Definition: ge_sys_math.h:48
maxon::Float32 Float32
Definition: ge_sys_math.h:59
Float32 PIX_F
32-bit float pixel type.
Definition: ge_math.h:29

Alpha Channels

A BaseBitmap can contain up to four alpha channels. They are represented also with BaseBitmap instances:

  • BaseBitmap::AddChannel(): Adds a new alpha channel.
  • BaseBitmap::RemoveChannel(): Removes the given alpha channel.
  • BaseBitmap::GetInternalChannel(): Returns the internal alpha channel.
  • BaseBitmap::GetChannelCount(): Returns the number of alpha channels.
  • BaseBitmap::GetChannelNum(): Returns the alpha channel with the given index.
  • BaseBitmap::GetAlphaPixel(): Gets the alpha value from the given alpha channel and the given coordinates.
  • BaseBitmap::SetAlphaPixel(): Sets the alpha value for the given alpha channel and the given coordinates.
// This example adds an alpha channel to the given BaseBitmap
// and stores the bitmap as a PNG file.
// fill image
bitmap->Clear(255, 255, 255);
// add alpha channel
BaseBitmap* alphaChannel = bitmap->AddChannel(true, false);
if (!alphaChannel)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// set alpha value for each pixel
for (Int32 x = 0; x < width; ++x)
{
for (Int32 y = 0; y < height; ++y)
{
// create horizontal alpha gradient
const Float alphaValueFloat = (COLORTOINT_MULTIPLIER * Float(x)) / Float(width);
const Int32 alphaValueInt = Int32(alphaValueFloat);
bitmap->SetAlphaPixel(alphaChannel, x, y, alphaValueInt);
}
}
// save as PNG with alpha
Filename saveImageFile;
if (!saveImageFile.FileSelect(FILESELECTTYPE::IMAGES, FILESELECT::SAVE, "Save as PNG"_s))
return maxon::OK;
const IMAGERESULT saveRes = bitmap->Save(saveImageFile, FILTER_PNG, nullptr, SAVEBIT::ALPHA);
if (saveRes != IMAGERESULT::OK)
return maxon::IoError(MAXON_SOURCE_LOCATION, MaxonConvert(saveImageFile, MAXONCONVERTMODE::NONE), "Could not save image file."_s);
SAVE
::Bool Get/Set. Determines if the layer is saved with the image or not if SAVEBIT::USESELECTEDLAYERS ...
Definition: ge_prepass.h:1
#define FILTER_PNG
PNG.
Definition: ge_prepass.h:202
ALPHA
Definition: lib_birender.h:3

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:

  • BaseBitmap::IsMultipassBitmap(): Returns true if the BaseBitmap is a MultipassBitmap.
// This example lets the user select an image file that will be loaded.
// If the loaded image contains layers the layout count is printed.
Filename selectedImageFile;
// select image file
if (!selectedImageFile.FileSelect(FILESELECTTYPE::IMAGES, FILESELECT::LOAD, "Select Image"_s))
return maxon::OK;
// load image file
BaseBitmap* bitmap = nullptr;
const IMAGERESULT result = BaseBitmap::Init(bitmap, selectedImageFile);
// check success
return maxon::IoError(MAXON_SOURCE_LOCATION, MaxonConvert(selectedImageFile, MAXONCONVERTMODE::NONE), "Could not load image file."_s);
// check if it is a MultipassBitmap
if (bitmap->IsMultipassBitmap())
{
MultipassBitmap* const multipassBitmap = static_cast<MultipassBitmap*>(bitmap);
// get layer count
const Int32 layerCount = multipassBitmap->GetLayerCount();
ApplicationOutput("Layer Count: " + String::IntToString(layerCount));
}
else
{
// no MultipassBitmap, no layers
ApplicationOutput("No layers");
}
BaseBitmap::Free(bitmap);
PyObject PyObject * result
Definition: abstract.h:43

A BaseBitmap also represents a maxon::ImageRef. This is obtained with:

  • BaseBitmap::GetImageRef(): Returns the internally stored maxon::ImageRef. See Images Manual.

Disc I/O

A BaseBitmap can read the content of an image file and save its content to an image file.

  • BaseBitmap::Init(): Loads the content of the given image file.
  • BaseBitmap::Save(): Saves the bitmap data to the given image file.
// This example let's the user select an image file.
// The loaded bitmap data is then saved in another image file format.
Filename selectedImageFile;
// select an image file
if (selectedImageFile.FileSelect(FILESELECTTYPE::IMAGES, FILESELECT::LOAD, "Select Image File"_s))
return maxon::OK;
AutoAlloc<BaseBitmap> bitmap;
if (bitmap == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// load image file into the given BaseBitmap
if (bitmap->Init(selectedImageFile) != IMAGERESULT::OK)
return maxon::IoError(MAXON_SOURCE_LOCATION, MaxonConvert(selectedImageFile, MAXONCONVERTMODE::NONE), "Could not load image file."_s);
// save bitmap data in different formats
// if the original file is no JPEG, save as JPEG
if (selectedImageFile.CheckSuffix("jpg"_s) == false)
{
Filename jpgFileName = selectedImageFile;
jpgFileName = GeFilterSetSuffix(jpgFileName, FILTER_JPG);
BaseContainer jpgSettings;
jpgSettings.SetInt32(JPGSAVER_QUALITY, 80);
if (bitmap->Save(jpgFileName, FILTER_JPG, &jpgSettings, SAVEBIT::NONE) != IMAGERESULT::OK)
return maxon::IoError(MAXON_SOURCE_LOCATION, maxon::Url(jpgFileName.GetString()), "Could not save image file."_s);
}
// if the original file is no PNG, save as PNG
if (selectedImageFile.CheckSuffix("png"_s) == false)
{
Filename pngFileName = selectedImageFile;
pngFileName = GeFilterSetSuffix(pngFileName, FILTER_PNG);
if (bitmap->Save(pngFileName, FILTER_PNG, nullptr, SAVEBIT::NONE) != IMAGERESULT::OK)
return maxon::IoError(MAXON_SOURCE_LOCATION, MaxonConvert(pngFileName, MAXONCONVERTMODE::NONE), "Could not save image file."_s);
}
Definition: url.h:936
#define FILTER_JPG
JPEG.
Definition: ge_prepass.h:189
#define JPGSAVER_QUALITY
Quality of JPEG images. A value between 0 (lowest) and 100 (highest).
Definition: ge_prepass.h:243
Filename GeFilterSetSuffix(const Filename &name, Int32 id)
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:

  • HyperFile::ReadImage(): Gets the BaseBitma from the HyperFile.
  • HyperFile::WriteImage(): Writes the BaseBitmpa into the HyperFile.

Display

A BaseBitmap or MultipassBitmap can easily displayed in the Picture Viewer:

  • ShowBitmap(): Opens the Picture Viewer to display a copy of the given BaseBitmap.
// This example opens a dialog to select an image file.
// The selected file is loaded into a BaseBitmap and displayed
// in the Picture Viewer window.
Filename selectedImageFile;
// select image file
if (!selectedImageFile.FileSelect(FILESELECTTYPE::IMAGES, FILESELECT::LOAD, "Select Image"_s))
return maxon::OK;
AutoAlloc<BaseBitmap> bitmap;
if (bitmap == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// load image file into the given BaseBitmap
if (bitmap->Init(selectedImageFile) != IMAGERESULT::OK)
return maxon::IoError(MAXON_SOURCE_LOCATION, MaxonConvert(selectedImageFile, MAXONCONVERTMODE::NONE), "Could not load image file."_s);
// show BaseBitmap in the Picture Viewer
ShowBitmap(bitmap);

Further Reading