Haiku API Bindings
Bitmap
Not logged in

Documentation | InterfaceKit | Bitmap

SYNOPSIS

Perl

use HaikuR1::Bitmap;

my $bitmap = HaikuR1::Bitmap->new(
    bounds          => $bounds,
    colorSpace      => $color_space,
    acceptsViews    => $accepts_views,
    needsContiguous => $needs_contiguous,
);
$bitmap->AddChild($view);

# draw to $view to draw to $bitmap

Python

from HaikuR1.InterfaceKit import Bitmap

bitmap = Bitmap(
    bounds          = bounds,
    colorSpace      = color_space,
    acceptsViews    = accepts_views,
    needsContiguous = needs_contiguous,
)
bitmap.AddChild(view)

# draw to view to draw to bitmap

DESCRIPTION

Exposes the BBitmap object.

There are three ways to get image data into a Bitmap:

For more information on Bitmap, see the Be Book class description, the Be Book overview, and the Haiku Book class description.

METHODS

Constructor

Creates a Bitmap object.

Perl

HaikuR1::Bitmap->new(
    bounds          => $bounds,
    colorSpace      => $colorSpace,
    acceptsViews    => $acceptsViews,
    needsContiguous => $needsContiguous,
);
HaikuR1::Bitmap->new(
    bounds      => $bounds,
    flags       => $flags,
    colorSpace  => $colorSpace,
    bytesPerRow => $bytesPerRow,
    screenID    => $screenID,
);
HaikuR1::Bitmap->new(
    source => $source,
    flags  => $flags
);
HaikuR1::Bitmap->new(
    source          => $source,
    acceptsViews    => $acceptsViews,
    needsContiguous => $needsContiguous,
);
HaikuR1::Bitmap->new($archive);

Python

Bitmap(
    bounds          = bounds,
    colorSpace      = colorSpace,
    acceptsViews    = acceptsViews,
    needsContiguous = needsContiguous,
)
Bitmap(
    bounds      = bounds,
    flags       = flags,
    colorSpace  = colorSpace,
    bytesPerRow = bytesPerRow,
    screenID    = screenID,
)
Bitmap(
    source = source,
    flags  = flags
)
Bitmap(
    source          = source,
    acceptsViews    = acceptsViews,
    needsContiguous = needsContiguous,
)
Bitmap(archive)

Note that the non-archive parameters naturally fall into three groups:

First, you can define the bitmap either with a bounds Rect and a color space, or with a source Bitmap. In the first case, the data will be empty; in the second case, the bounds, color space, and picture data will be copied from the source.

Second, you can specify the bitmap's behavior either by directyl passing flags or by passing a couple of booleans that set the most useful flags.

Third, if you use the bounds and boolean version, you can pass two additional options, bytesPerRow and screenID. These are ignored in the other cases.

Note that you can specify either a bounds Rect or a source Bitmap, and you can specify either a pair of booleans that set the most useful flags or set the flags directly for more control.

copy

Copies the contents of another object into this object.

Perl

$bitmap->copy($copy_from);

Python

bitmap.copy(copy_from)

Area

Returns the id of the shared memory area where the system stores bitmaps.

Perl

$bitmap->Area();

Python

bitmap.Area()

Bits

BitsLength

SetBits

ImportBits

Bits returns the raw bitmap data as a byte string. BitsLength returns the length of the raw bitmap data.

SetBits and ImportBits will convert the given bitmap data, overwriting the current bitmap data (or a portion of it).

Currently only the following color spaces are supported for conversion; if you need to convert other data, you will need to write your own converstion code.

Perl

$bitmap->Bits();
$bitmap->BitsLength();
$bitmap->SetBits($data, $offset, $colorSpace);
$bitmap->ImportBits(
    data        => $data,
    bytesPerRow => $bytesPerRow,
    colorSpace  => $colorSpace,
    offset      => $offset,
);
$bitmap->ImportBits(
    data        => $data,
    bytesPerRow => $bytesPerRow,
    colorSpace  => $colorSpace,
    from        => $from,
    to          => $to,
    width       => $width,
    height      => $height,
);
$bitmap->ImportBits(
    bitmap => $bitmap,
);
$bitmap->ImportBits(
    bitmap => $bitmap,
    from   => $from,
    to     => $to,
    width  => $width,
    height => $height,
);

Python

bitmap.Bits()
bitmap.BitsLength()
bitmap.SetBits(data, offset, colorSpace)
bitmap.ImportBits(
    data        = data,
    bytesPerRow = bytesPerRow,
    colorSpace  = colorSpace,
    offset      = offset,
)
bitmap.ImportBits(
    data        = data,
    bytesPerRow = bytesPerRow,
    colorSpace  = colorSpace,
    from        = from,
    to          = to,
    width       = width,
    height      = height,
)
bitmap.ImportBits(
    bitmap = bitmap,
)
bitmap.ImportBits(
    bitmap = bitmap,
    from   = from,
    to     = to,
    width  = width,
    height = height,
)

Python

Since Python will not accept from as a parameter name, in Python these parameters are named srcLoc and dstLoc.

The parameters naturally fall into two groups:

First, for bitmap data you can either use raw data, the number of bytes per row, and the color space, or you can pass another bitmap.

Second, you can specify the part of the data to overwrite either with a byte offset or with a pixel origin, destination, width, and height. (However, when your data source is another bitmap, you cannot pass an offset; you must either delimit with pixels or copy the entire bitmap.

Bounds

Returns the bounds Rect.

Perl

$bitmap->Bounds();

Python

bitmap.Bounds()

BytesPerRow

Returns the number of bytes per row.

Perl

$bitmap->BytesPerRow();

Python

bitmap.BytesPerRow()

ColorSpace

Returns the color space (one of the color space constants).

Perl

$bitmap->ColorSpace();

Python

bitmap.ColorSpace()

Flags

SetDrawingFlags

Flags returns the flags value.

Do not use SetDrawingFlags. The underlying C++ method has not been implemented.

Perl

$bitmap->Flags();
$bitmap->SetDrawingFlags($flags);

Python

bitmap.Flags()
bitmap.SetDrawingFlags(flags)

GetOverlayRestrictions

Get the overlay_restrictions for the bitmap. The bitmap must have been created with the B_BITMAP_WILL_OVERLAY flag or this method will fail.

Perl

$bitmap->GetOverlayRestrictions();

Python

bitmap.GetOverlayRestrictions()

IsValid

Returns true if the Bitmap is properly set up; false otherwise.

Perl

$bitmap->IsValid();

Python

bitmap.IsValid()

WINDOW-like INTERFACE

These methods mimic the same methods from Window and Looper. They are used when drawing to a Bitmap.

ARCHIVABLE INTERFACE

Bitmap inherits the Archive methods from Archivable.

CONSTANTS

Bitmap flags

Perl

use HaikuR1::Bitmap qw(:flags)

Python

Python does not support export tags.

Other constants

These constants do not have an export tag.

Tells the Bitmap not to care about the number of bytes per row. If this number is necessary, the Bitmap will either calculate the value itself or generate an error.