Creating a New Bitmap
The Bitmap Editor is also able to create new documents, that is, to create new bitmaps. In order to simplify the tutorial, newly-created bitmaps are considered to have a size of 128x128 pixels in this step. Step 4 will show how to introduce a dialog box that lets the user set the bitmap dimensions.
A new document is created when the user performs one of the following actions:
*Selection of File > New from the menu bar
*Selection of the New button from the main toolbar
*CTRL+N accelerator
The association between the user action and the document creation is handled transparently by Application Framework, which calls the BitmapDocument::initializeDocument method. This method creates a new IlvBitmap object and stores it in the bitmap member field of the Bitmap Editor using BitmapDocument::setBitmap:
IlvBoolean
BitmapDocument::initializeDocument(IlvAny data)
{
if (!IlvDvDocument::initializeDocument(data))
return IlvFalse;
 
IlvDisplay* display = getDisplay();
// Creates the bitmap with a default size of 128x128
IlvDim width = 128;
IlvDim height = 128;
IlvBitmap* bitmap =
new IlvBitmap(display, width, height, display->screenDepth());
setBitmap(bitmap);
 
// Initialize it with the display palette
setPalette(display->defaultPalette());
getPalette()->invert();
bitmap->fillRectangle(getPalette(), IlvRect(0, 0, width, height));
getPalette()->invert();
 
return IlvTrue;
}
Published date: 05/24/2022
Last modified date: 02/24/2022