background image
C H A P T E R 1 3
Drawing and Graphics
Using the Drawing Interface
Using Bitmaps
You can dynamically create and destroy bitmaps, draw into them, and perform
operations on them such as rotating, flipping, and sizing. This flexible treatment of
bitmaps allows you to use them as offscreen buffers and for storage of documents
such as fax pages.
You can create and use bitmap images with the drawing bitmap functions. To create
a bitmap you first allocate a bitmap that will contain the drawing with the
function. Then create a shape with the
takes the drawing and draws it into the bitmap. The final step
is to draw the bitmap on the Newton screen with the
The following example shows how to draw a bitmap. It creates a bitmap by drawing
a shape and draws it onto the screen. This example then rotates the shape, scales it,
and redraws it on the Newton:
bitmapWidth := 90;
bitmapHeight := 120;
vfBlack := 5;
// allocate a new bitmap
bitmap := MakeBitmap(bitmapWidth, bitmapHeight, nil);
// make a shape and draw it into the bitmap
shapes := MakeOval(0, 0, 50, 75);
DrawIntoBitmap(shapes, {fillPattern: vfBlack}, bitmap);
// draw the bitmap
GetRoot():DrawShape(bitmap, {transform: [100, 100]});
// Rotation is a destructive operation: it replaces the
// old bitmap with the new rotated bitmap.
MungeBitmap(bitmap, 'rotateRight, nil);
// translate and scale the bitmap
fromRect := SetBounds(0, 0, bitmapWidth, bitmapHeight);
toRight := 100 + floor(bitmapWidth * 1.25);
toBottom := 200 + floor(bitmapHeight * 1.25);
toRight := 100 + bitmapWidth * 5 div 4;
toBottom := 200 + bitmapHeight * 5 div 4;
toRect := SetBounds(100, 200, toRight, toBottom);
// draw the bitmap again
GetRoot():DrawShape(bitmap, {transform: [fromRect,
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна