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)
bounds
A Rect, the bounds of the rectangle. If you intend to draw to the Bitmap using a View, the left top corner should be at
0,0
.colorSpace
An integer, one of the color space constants.
source
A source Bitmap; the bounds, color space, and data will be copied to the new Bitmap.
flags
A integer, one or more of the bitmap flag constants.
acceptsViews
A boolean; if true, the
B_BITMAP_ACCEPTS_VIEWS
will be set.needsContiguous
A boolean; if true, the
B_BITMAP_IS_AREA
,B_BITMAP_IS_LOCKED
, andB_BITMAP_IS_CONTIGUOUS
flags will be set.bytesPerRow
An integer, the number of bytes per row; defaults to
B_ANY_BYTES_PER_ROW
.screenID
An integer, one of the screen_id constants, defaults to
B_MAIN_SCREEN_ID
.archive
A Message, contains an archived version of the Bitmap.
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)
copy_from
A Bitmap to copy.
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, )
data
A byte string, raw bitmap data.
bytesPerRow
An integer, the number of bytes per row; defaults to
B_ANY_BYTES_PER_ROW
.colorSpace
An integer, one of the color space constants.
bitmap
A source Bitmap.
offset
An integer, the byte offset into the data.
from
,to
A Point, the origin and destination pixels.
Python
Since Python will not accept from
as a parameter name, in Python these
parameters are named srcLoc
and dstLoc
.
width
,height
An integer, the width and height of the portion of data to copy.
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)
flags
An integer.
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.
B_BITMAP_CLEAR_TO_WHITE
Clears the bitmap to white after it is created.
B_BITMAP_ACCEPTS_VIEWS
Indicates the Bitmap will take Views
- B_BITMAP_IS_AREA
- B_BITMAP_IS_LOCKED
B_BITMAP_IS_CONTIGUOUS
These three are used to control how the bitmap data is stored in memory.
- B_BITMAP_IS_OFFSCREEN
- B_BITMAP_WILL_OVERLAY
B_BITMAP_RESERVE_OVERLAY_CHANNEL
These three are used for overlay bitmaps.
B_BITMAP_NO_SERVER_LINK
Allows you to create a Bitmap without having an Application present. However, you cannot draw to this kind of Bitmap, or draw it to a View.
Other constants
These constants do not have an export tag.
- B_ANY_BYTES_PER_ROW
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.