BPicture

Derived From:
Mix-in Classes:BArchivable
Declared In:interface/Picture.h
Library:libbe.so
Allocation:
Class Overview

Constructor and Destructor

BPicture()

BPicture(); BPicture(const BPicture& picture); BPicture(BMessagearchive);

Initializes the BPicture object by ensuring that it's empty, or by copying data from another picture or archive of a BPicture object.

~BPicture()

virtual ~BPicture();

Destroys the Application Server's record of the BPicture object and deletes all its picture data.


Member Functions

Archive()

virtual status_t Archive(BMessagearchive,
                         bool deep = true) const;

Archives the BPicture by recording its current settings in the BMessage archive.

See also: BArchivable::Archive(), Instantiate() static function

Play()

virtual status_t* Play(void** callBackTable,
                       int32 tableEntries,
                       void* user);

Plays back a picture using a user's rendering functions. The functions are passed in callBackTable, an array of function pointers. tableEntries contains the number of functions in the table. The functions perform various tasks such as drawing lines and text. user is passed to each function, providing a hook for passing additional data to the call back functions. The functions, along with their positions in the call back table, are detailed below.

IndexFunction prototype
0no operation
1MovePenBy(void* user, BPoint delta)
2StrokeLine(void* user, BPoint start, BPoint end)
3StrokeRect(void* user, BRect rect)
4FillRect(void* user, BRect rect)
5StrokeRoundRect(void* user, BRect rect, BPoint radii)
6FillRoundRect(void* user, BRect rect, BPoint radii)
7StrokeBezier(void* user, BPoint* control)
8FillBezier(void* user, BPoint* control)
9StrokeArc(void* user, BPoint center, BPoint radii, float startTheta, float arcTheta)
10FillArc(void* user, BPoint center, BPoint radii, float startTheta, float arcTheta)
11StrokeEllipse(void* user, BPoint center, BPoint radii)
12FillEllipse(void* user, BPoint center, BPoint radii)
13StrokePolygon(void* user, int32 numPoints, BPoint* points, bool isClosed)
14FillPolygon(void* user, int32 numPoints, BPoint* points, bool isClosed)
15Reserved
16Reserved
17DrawString(void* user, char* string, float deltax, float deltay)
18DrawPixels(void* user, BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void* data)
19Reserved
20SetClippingRects(void* user, BRect* rects, uint32 numRects)
21Reserved
22PushState(void* user)
23PopState(void* user)
24EnterStateChange(void* user)
25ExitStateChange(void* user)
26EnterFontState(void* user)
27ExitFontState(void* user)
28SetOrigin(void* user, BPoint pt)
29SetPenLocation(void* user, BPoint pt)
30SetDrawingMode(void* user, drawing_mode mode)
31SetLineMode(void* user, cap_mode capMode, join_mode joinMode, float miterLimit)
32SetPenSize(void* user, float size)
33SetForeColor(void* user, rgb_color color)
34SetBackColor(void* user, rgb_color color)
35SetStipplePattern(void* user, pattern p)
36SetScale(void* user, float scale)
37SetFontFamily(void* user, char* family)
38SetFontStyle(void* user, char* style)
39SetFontSpacing(void* user, int32 spacing)
40SetFontSize(void* user, float size)
41SetFontRotate(void* user, float rotation)
42SetFontEncoding(void* user, int32 encoding)
43SetFontFlags(void* user, int32 flags)
44SetFontShear(void* user, float shear)
45Reserved
46SetFontFace(void* user, int32 flags)

While many of these functions are similar to those found in BView, there are some important differences:

  • The return value of the functions is ignored.

  • The Fill…() and Stroke…() functions do not explicitly specify patterns. Instead, they should be drawn in the current pattern, as set by the SetStipplePattern() (callback #35). Note that there is no equivalent to SetStipplePattern() in BView.

  • The deltax and deltay arguments passed to DrawString() are escapement delta values; the string should be drawn at the current pen position.

  • MovePenBy() uses a BPoint to specify the amount to move the pen. The x component of the BPoint gives the x offset and the y component the y offset.

  • Similarly, …RoundRect() and …Ellipse() use a BPoint to specify the two separate radius components. The x component gives the x radius and the y component the y radius.

  • DrawPixels() is a BPicture-specific primitive for rendering bitmaps. It is a request to copy the src rectangle from the raw color information in data to the dest rectangle of the current rendering area. width, height, bytesPerRow, and pixelFormat provide all the information necessary to interpret data. flags is currently always zero and should be ignored. src and dest need not have the same dimensions; in these cases, the function should scale the bitmap appropriately.

  • SetClippingRects() is a BPicture-specific primitive approximating ConstrainClippingRegion(). It instructs the renderer to replace the current clipping region with the union of the rectangles passed to SetClippingRects().

  • Changes in the graphics state are sandwiched between calls to EnterStateChange() and ExitStateChange(). State change functions will only be called between these functions. No other call backs will be called between these functions. State change functions are all Set…() functions in addition to EnterFontState() and ExitFontState().

  • Similarly, changes to the font state are sandwiched between calls to EnterFontState() and ExitFontState(). Font state change functions will only be called between these functions. No other call backs will be called between these functions. Font state change functions are all SetFont…() functions. Many of the font state functions are found in BFont rather than BView.

  • SetFontRotate() sets the rotation of the font. Unlike the BFont::SetRotation() function, the angle here is specified in radians, rather than in degrees. You can convert the value into degrees by using the forumla:

    degrees = (rotation*180.0) / 3.14159265369);


Static Functions

Instantiate()

static BArchivableInstantiate(BMessagearchive);

Returns a new BPicture object, allocated by new and created with the version of the constructor that takes a BMessage archive. However, if the archive message doesn't contain data for a BPicture object, this function returns NULL.

See also: BArchivable::Instantiate(), instantiate_object(), Archive()


Archived Fields

The Archive() function adds the following fields to its BMessage argument:

FieldType codeDescription
_verB_INT32_TYPEAlways 1.
_endianB_INT8_TYPEEndianness of the data. Always B_HOST_IS_BENDIAN.
_dataB_RAW_TYPEThe BPicture data.
Creative Commons License
Legal Notice
This work is licensed under a Creative Commons Attribution-Non commercial-No Derivative Works 3.0 License.