Derived from: public BObject
Declared in: <interface/Picture.h>
A BPicture object holds a set of drawing instructions in the Application Server, where they can be reused over and over again simply by passing the object to BView's DrawPicture() function. Because it contains instructions for producing an image, not the rendered result of those instructions, a picture (unlike a bitmap) is independent of the resolution of the display device.
Drawing instructions are captured by bracketing them with calls to a BView's BeginPicture() and EndPicture() functions. An empty BPicture object is passed to BeginPicture(); EndPicture() returns the same object, fully initialized. For example:
BPicture *myPict; someView->BeginPicture(new BPicture); /* drawing code goes here */ myPict = someView->EndPicture();
The BPicture object records all of the drawing instructions given to the BView following the BeginPicture() call and preceding the EndPicture() call. Only the drawing that the BView does is recorded; drawing done by children and other views attached to the window is ignored, as is everything except drawing code.
If the BPicture object passed to BeginPicture() isn't empty, the new drawing is appended to the code that's already in place.
The picture captures everything that affects the image that's drawn. It takes a snapshot of the BView's graphics parameters--the pen size, high and low colors, font size, and so on--at the time BeginPicture() is called. It then captures all subsequent modifications to those parameters, such as calls to MovePenTo(), SetLowColor() , and SetFontSize() . However, changes to the coordinate system (ScrollBy() and ScrollTo()) are ignored.
The picture records all primitive drawing instructions--such as, DrawBitmap(), StrokeEllipse() , FillRect() , and DrawString() . It can even include a call to DrawPicture(); one picture can incorporate another.
The BPicture traces exactly what BView drew and reproduces it precisely. For example, whatever pen size happens to be in effect when a line is stroked will be the pen size that the picture records, whether it was explicitly set while the BPicture was being recorded or assumed from the BView's graphics environment.
The picture makes its own copy of any data that's passed during the recording session. For example, it copies the bitmap passed to DrawBitmap() and the picture passed to DrawPicture(). If that bitmap or picture later changes, it won't affect what was recorded.
See also: BView::BeginPicture(), BView::DrawPicture(), the BPictureButton class
BPicture(void) BPicture(const BPicture &picture) BPicture(void *data, long size)
Initializes the BPicture object by ensuring that it's empty, by copying data from another picture, or by copying size bytes of picture data. The data should be taken, directly or indirectly, from another BPicture object.
virtual ~BPicture(void)
Destroys the Application Server's record of the BPicture object and deletes all its picture data.
void *Data(void) const
Returns a pointer to the data contained in the BPicture. The data can be copied from the object, stored on disk (perhaps as a resource), and later used to initialize another BPicture object.
See also: the BPicture constructor
long DataSize(void) const
Returns how many bytes of data the BPicture object contains.
See also: Data()
The Be Book, HTML Edition, for Developer Release 8 of the Be Operating System.
Copyright © 1996 Be, Inc. All rights reserved.
Be, the Be logo, BeBox, BeOS, BeWare, and GeekPort are trademarks of Be, Inc.
Last modified September 6, 1996.