Class: Toybox.WatchUi.Bitmap

Overview

Bitmap is the class representation of a bitmap resource.

A Bitmap can be constructed using the resource compiler and loaded through the resource (Rez) module.

See Also:

Example:

// The bitmap.xml file contents:
// <resources>
//     <bitmap id="myBitmap" filename="images/myBitmap.png" />
// </resources>

using Toybox.Graphics;
using Toybox.WatchUi;

class MyWatchView extends WatchUi.View {

    var myBitmap;

    function initialize() {
        View.initialize();
        myBitmap = new WatchUi.Bitmap({
            :rezId=>Rez.Drawables.myBitmap,
            :locX=>10,
            :locY=>30
        });
    }

    // Update the view
    function onUpdate(dc) {
        myBitmap.draw(dc);
    }
}

Since:

API Level 1.0.0

Instance Method Summary collapse

Instance Method Details

draw(dc as Graphics.Dc) as Void

Draw a Bitmap to the device context (Dc).

Parameters:

Since:

API Level 1.0.0

getDimensions() as Lang.Array<Lang.Number>

Get the dimensions of a Bitmap.

Returns:

  • Lang.Array

    A two element array containing the width and height of the Bitmap object

Since:

API Level 1.0.0

initialize(settings as { :rezId as Lang.Symbol, :bitmap as Graphics.BitmapType, :identifier as Lang.Object, :locX as Lang.Numeric, :locY as Lang.Numeric, :width as Lang.Numeric, :height as Lang.Numeric, :visible as Lang.Boolean })

Constructor

Parameters:

  • settings(Lang.Dictionary)

    A Dictionary containing the settings for the Bitmap object

    • :rezId(Lang.Symbol)

      The resource identifier for the Bitmap object

    • :bitmap(Graphics.BitmapType)

      The BitmapResource, BufferedBitmap, BitmapReference, or BufferedBitmapReference object to use

See Also:

Since:

API Level 1.0.0

setBitmap(identifier as Graphics.BitmapType or Lang.Symbol) as Void

Set the resource associated with the Bitmap.

Parameters:

Since:

API Level 1.0.0


Generated Sep 25, 2023 12:31:47 PM