![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AROS Application Development ManualAdvertencia This document is not finished! It is highly likely that many parts are out-of-date, contain incorrect information or are simply missing altogether. If you want to help rectify this, please contact us. graphics.libraryBitmapsBitmaps are the drawing sheets of AROS. They are coordinate systems with the zero point in the upper left corner. The X axis goes from left to right, y axis from top to bottom. The number of possible colors depends on the depth of the bitmap:
The depths from 1 to 8 are LUT (look-up-table) modes. This means the red, green and blue (RGB) value for each color is stored in a table. The index will then be stored as pen number in the bitmap. The depths 15 and 16 are called high color, 24 is called true color. Unlike LUT mode the RGB value is stored directly in the bitmap. The graphics library has only a limited support for high-/true color modes. Some of the drawing functions work only with LUT modes. For a full access you need the functions from the cybergraphics library.
RastPortThe connection between the bitmaps and most drawing functions is done by a rastport. The rastport contains information about drawing pens, line and area patterns, drawing mode and text font. You can connect more than one rastport to a bitmap. This allows a fast switch between different drawing configurations. But in AROS you aren't allowed to just copy a rastport, you have to use the function CloneRastPort(). Some Intuition elements like screens and windows already have a RastPort element. You can immediately use it for your drawing operations.
If you create a bitmap and want to draw into it you have to create the rastport by yourself. Warning: this example is simplified and lacks checks of return values: struct BitMap *bm = AllocBitMap(400, 300, 8, BMF_CLEAR, NULL); struct RastPort *rp = CreateRastPort(); rp->BitMap = bm; ... WritePixel(rp, 50, 30); ... FreeRastPort(rp); FreeBitMap(bm); PensA rastport contains 3 pens. The A (foreground, primary) pen, B (background, secondary) pen and the O (area outline) pen. The latter is used by the area fill and flood fill functions. Drawing modes
TODO: check whether the drawing modes are really available. PatternThe line pattern can be set with the macro SetDrPt(). The second paramter is a 16 bit pattern: SetDrPt(&rastPort, 0xCCCC); The pattern can be reset with: SetDrPt(&rastPort, ~0); For area patterns exists the macro SetAfPt(). The width is 16 bit, the height a power of two (2, 4, 8, 16, ...). The third parameter is the n in 2^n=height:
UWORD areaPattern[] =
{
0x5555, 0xAAAA
};
SetAfPt(&rastPort, areaPattern, 1);
Colored patterns are possible with a negative value for the height. There must be the same number of bitplanes in the pattern as in the target bitmap. Reset of area pattern: SetAfPt(&rastPort, NULL, 0);
Drawing functionsA line is drawn by setting the pen position with Move() to the start and with Draw() to the end position. For the Flood() function you have to attach a TmpRas to the rastport as explained unter Area operations.
Data moving
Area operationsThe area functions allow a fast drawing of filled polygons and ellipses. In order to use this functions you need a struct AreaInfo which must be connected to the rastport. The area buffer must be WORD-aligned (it must have an even address). You need five bytes per vertex:
#define AREA_SIZE 200
WORD areaBuffer[AREA_SIZE];
struct AreaInfo areaInfo = {0};
memset(areabuffer, 0, sizeof(areabuffer));
InitArea(&areaInfo, areaBuffer, sizeof(areaBuffer)/5);
rastPort->AreaInfo = &areaInfo;
Additionally, you need a TmpRas structure. It should have the same width and height as the bitmap you want to draw into:
#define WIDTH 400
#define HEIGHT 300
PLANEPTR rasplane = AllocRaster(WIDTH, HEIGHT);
struct TmpRas tmpRas = {0};
InitTmpRas(&tmpRas, rasPlane, WIDTH * HEIGHT);
rastPort->TmpRas = &tmpRas;
Text
ClippingBitmaps which you have created with AllocBitMap() don't have a clipping rectangle. This means that you trash memory when you draw outside the bitmap. You can either take care about your drawing operations or you can install a clipping rectangle. There are two possibilities:
The latter is compatible with AmigaOS. ColorSo far we have only used the SetXPen() functions to select the drawing pens. Now we look how we can change the red, green blue values of the pens.
Animation
Layers
Display database
Blitter
Copper
Misc
|
Copyright © 1995-2008, The AROS Development Team. All rights reserved. Amiga® is a trademark of Amiga Inc. All other trademarks belong to their respective owners. |