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.Numeric, Lang.Numeric ]

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(options as { :rezId as Lang.ResourceId, :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:

  • options(Lang.Dictionary)

    A Dictionary containing the options for the Bitmap object

    • :rezId(Lang.ResourceId)

      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(bitmap as Graphics.BitmapType or Lang.ResourceId or Null) as Void

Set the resource associated with the Bitmap.

Note:

A null value passed for the bitmap parameter is only supported with ConnectIQ 5.0.0 and later.

Parameters:

Since:

API Level 1.0.0

Throws:


Generated Jun 6, 2024 10:31:54 AM