Class: Toybox::Graphics::BufferedBitmap

Inherits:
Lang::Object show all

Overview

This class represents an off-screen bitmap. It provides methods to modify the bitmap palette, and get a drawable context.

Examples:

Sets up an off-screen buffer using resources.

using Toybox.Graphics;

var screenShape;
var offscreenBuffer;
var dateBuffer;

    if (Toybox.Graphics has :BufferedBitmap) {              // check to see if device has BufferedBitmap enabled
        offscreenBuffer = new Graphics.BufferedBitmap(
                {:width=>dc.getWidth(),
                 :height=>dc.getHeight(),
                 :palette=>[Graphic.COLOR_DK_GRAY,
                            Graphics.COLOR_LT_GRAY,
                            Graphics.COLOR_BLACK,
                            Graphics.COLOR_WHITE]} );       // create an off-screen buffer with a palette of four colors

        stringBuffer = new Graphics.BufferedBitmap(         // Buffer will have full color support as no palette is defined
                {:width=>dc.getWidth(),
                 :height=>Graphics.getFontHeight(Graphics.FONT_MEDIUM)} );
    } else {
        offscreenBuffer = null;                             // handle devices without BufferedBitmap
        stringBuffer = null;
    }

See Also:

Since:

  • 2.3.0

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(options) ⇒ BufferedBitmap

Returns a new instance of BufferedBitmap

Parameters:

  • options (Toybox::Lang::Dictionary)

    Dictionary of options. Must contain width and height, with optional palette, or a BitmapResource. This resource is not allowed to have an alpha channel.

Options Hash (options):

  • :width (Toybox::Lang::Number)

    The width of the surface in pixels

  • :height (Toybox::Lang::Number)

    The height of the surface in pixels

  • :palette (Toybox::Lang::Array)

    The colors used in this surface. Using less will reduce the bitmap size. The bitmap will use the system default if not provided. The maximum palette size allowed is 256 colors. If a palette is provided, the number of colors must also be <= to the number of system colors.

  • :bitmapResource (Toybox::WatchUi::BitmapResource)

    A BitmapResource to initialize

Raises:

Since:

  • 2.3.0


6141
6142
# File 'Monkeybrains.rb', line 6141

def initialize(options)
end

Instance Method Details

getDcToybox::Graphics::Dc

Get the Dc to draw on the buffered bitmap.

Returns:

Since:

  • 2.3.0


6163
6164
# File 'Monkeybrains.rb', line 6163

def getDc()
end

getPaletteToybox::Lang::Array

null if this surface uses the system palette

Returns:

Since:

  • 2.3.0


6147
6148
# File 'Monkeybrains.rb', line 6147

def getPalette()
end

setPalette(palette) ⇒ Object

Parameters:

  • palette (Toybox::Lang::Array)

    A palette for this bitmap. The number of colors must match the current palette. Each color in the image will be replaced with the colors specified in the new palette.

Raises:

Since:

  • 2.3.0


6157
6158
# File 'Monkeybrains.rb', line 6157

def setPalette(palette)
end