Home > Language Reference > Classes

Bitmap Class

  + Object
    + Display
      + Bitmap

Description

The Bitmap class manipulates images in memory. Using the methods inherited from the Display class, you can draw an image in memory or on screen, and copy parts of an image into another image or onto the screen. This class is instantiable and cloneable but not derivable.

A Bitmap object can be associated with a resource. When you insert an image into your project, a global Bitmap type variable with the name of the image is automatically created, and associated with the corresponding image in the application resources. The first time you access methods and properties of this object, the associated image is loaded. When you no longer need the image, you can free up memory by calling the Destroy method or the Unload function.

On the other hand, when you instantiate the Bitmap class yourself, the object obtained is not associated with any resource. In this case, you must explicitly create the image contained in the object using the Create method, specifying the width, height, an optional bit depth and density. You can then destroy it with the Destroy method. The Unload function has no effect on a Bitmap object which is not associated with a resource.

You can also create a bitmap using the CreateFromResource and CreateFromBitmapType methods, which initialize the Bitmap object from data packed accordingly to the Palm OS® resource format. This is typically used to access images or icons of a third party application, or to access images returned by a shared library such as a JPEG converter.

Starting with Palm OS® 3.5, you can specify a transparency color for images using the TransparencyColor property. When copying an image to screen or another image, all the pixels whose color corresponds to that specified by this property are not copied.

When duplicating of a Bitmap object with the Clone keyword, the image contained in the object is an exact copy, including bit depth, density, and transparency color.

The following example creates an image dynamically, and displays it in the middle of the form:

Private bm as New Bitmap

Private Sub Form_Load()
  bm.Create 100, 40
  bm.BackColor=hbColorBlue
  bm.ForeColor=hbColorBlack
  bm.Rectangle 0, 0, 99, 39, hbRectBorderSolid+hbRectFillSolid,5
  bm.TextColor=hbColorWhite
  bm.DrawFont=hbFontLargeBold
  bm.TextOut 50, 20, "Sample Bitmap",hbTextAlignCenter+hbTextAlignVCenter
  bm.Flush
End Sub

Private Sub Form_Unload()
  bm.Destroy
End Sub

Private Sub Form_Paint()
  CopyArea 30, 60, 100, 40, bm, 0, 0
End Sub

Note: The maximum bit depth of an image depends on the Palm OS® version, while the supported densities depends on the device your application is running on. Refer to the Create method for more information.

Members

MembersDescription
BitDepth Bit depth of the image.
Bits Returns a pointer to the image bits.
Create Creates an image.
CreateFromBitmapType Creates an image from a pointer to a Palm OS® BitmapType structure.
CreateFromGIF Creates an image from a GIF file.
CreateFromJPEG Creates an image from a JPEG file.
CreateFromPNG Creates an image from a PNG file.
CreateFromResource Creates an image from a resource.
Density Density of the image.
Destroy Destroys an image.
Height Image height.
SaveToBMP Saves the bitmap to a BMP file.
SaveToJPEG Saves the bitmap to a JPEG file.
SaveToPNG Saves the bitmap to a PNG file.
TransparencyColor Transparency color.
Width Image width.
Inherited from DisplayDescription
Arc Draws an arc.
BackColor Background color.
BatchLimit Size of the graphics instruction buffer.
CoordinateSystem Coordinates system.
CopyArea Efficiently copies part of a Display object to another.
DrawFont Font used to draw the text.
Flush Empties the graphics instruction buffer.
FontMetrics Returns a FontMetrics object describing the physical charateristics of the currently active font.
ForeColor Foreground color.
GetPixel Queries the color of a given pixel.
hWin Returns the window handle.
Line Draws a line.
Oval Draws a circle or ellipse.
Pattern Defines the pattern used to fill drawings.
Polygon Draws a polygon.
PutPixel Sets the color of a pixel.
Rectangle Draw a rectangle.
ResID Identifier of the resource associated with the object.
ScaleFont Enable or disable font scaling.
TextColor Text color.
TextOut Draw text.
Inherited from ObjectDescription
ClassID Returns the type identifier corresponding to the actual class of the object.
Implements Determines whether the object implements the features of a given class.
Iterate Event raised to iterate over the elements of a container object.
Recipient Recipient of events sent by the object.
Serialize Event raised to serialize the object content into a stream.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A