BITBLT(3G) BITBLT(3G) NAME bitblt, bitbltclip, copymasked, clipline, point, segment, polysegment, arc, circle, disc, ellipse, texture, border, string, strsize, strwidth, Fcode - graphics functions SYNOPSIS#include <libc.h>#include <libg.h>void bitblt(Bitmap *db, Point dp, Bitmap *sb,Rectangle sr, Fcode f)int bitbltclip(void *)void copymasked(Bitmap *db, Point dp, Bitmap *sb, Bitmap *mb, Rectangle sr)int clipline(Rectangle r, Point *p0, Point *p1);void point(Bitmap *b, Point p, int v, Fcode f);void segment(Bitmap *b, Point p, Point q, int v, Fcode f)void polysegment(Bitmap *b, int n, Point *pp, int v, Fcode f)void circle(Bitmap *b, Point p, int r, int v, Fcode f);void arc(Bitmap *b, Point p0, Point p1, Point p2, int v, Fcode f);void disc(Bitmap *b, Point p, int r, int v, Fcode f);void ellipse(Bitmap *b, Point p, int a, int b, int v, Fcode f);void texture(Bitmap *b, Rectangle r, Bitmap *t, Fcode f)void border(Bitmap *b, Rectangle r, int w, Fcode f)Point string(Bitmap *b, Point p, Font *ft, char *s, Fcode f)Point strsize(Font *ft, char *s)long strwidth(Font *ft, char *s)enum Fcode { Zero, DnorS, DandnotS, notS, notDandS, notD, DxorS, DnandS, DandS, DxnorS, D, DornotS, S, notDorS, DorS, F } Fcode; DESCRIPTIONBitblt(bit-block transfer) takes bits from rectanglesrin thesourceBitmap,sb,and overlays them on a congruent rectangle with themincorner at pointdpin thedestinationbitmap,db. Thefparameter says how to compute each destination pixel as a function of the source and destination pixels. The first sixteen codes inFcodegive all possible boolean operations on the source,Sand destinationD. The code values have been arranged so that they may be expressed as boolean operations on the valuesSandD.So, for example,D|Scomputes the result as the logicalorof the destination pixel's old value and the overlaying source pixel's value. If pixels are more than one bit deep, the operations are bitwise. TheZeroandFcodes result in new pixel values that are all zeros or all ones, respectively. If the source and destination bitmaps have different depths, the source rectangle is first converted to have the same depth as the destination, as follows: conversion to a smaller number of bits per pixel is accomplished by taking the desired number of high order bits; conversion to a larger number of bits per pixel is accomplished by putting the small value into the high order bits, and replicating it as many times as necessary to fill the lower order bits.Copymaskedcopies rectanglesrin the source bitmapsbto the congruent rectangle with themincorner at pointdpin the destination bitmapdb, masked by bitmapmb .This means thatmbis overlayed on the destination rectangle, and only pixels corresponding to 1 bits in the mask are changed.Mbmust be a 1-bit-deep bitmap with origin (0,0) and congruent tosr. Bitmapssbanddbmust have the same depth. All of the drawing graphics functions clip the rectangle against the source and destination bitmaps, so that only pixels within the destination bitmap are changed, and none are changed that would have come from areas outside the source bitmap.Bitbltcliptakes a pointer to the first argument of abitbltargument list, and modifiesdpandsrso that no more clipping is needed.Pointchanges the value of the destination pointpin bitmapbaccording to function codef. The source is a pixel with valuev. It is useful to use~0when the maximum pixel value is desired for the source.Segment,circle,disc, andellipseall draw in bitmapbwith function codefand a source pixel with valuev.Arcdraws a circular arc centered onp0, traveling clockwise fromp1top2or a point on the circle nearp2.Segmentdraws a line segment in bitmapbfrom pointptoq. The segment is half-open:pis the first point of the segment andqis the first point beyond the segment, so adjacent segments sharing endpoints abut.Polysegmentdraws then-1 segments joining thenpoints in the array pointed to bypp. Cliplineclips the line segment from *p0to *p1(p0is closed,p1is open) to rectangler, adjustingp0andp1so that the segment is within the rectangle and *p1is closed. It returns 0 if none of the segment is in the rectangle, 1 otherwise.Circledraws a circle with radiusrand center at pointp.Discis the same except that it fills the circle.Ellipsedraws an ellipse with horizontal semi-axisaand vertical semi-axisb.Borderdraws, with functionfin bitmapb, the rectangular outline with lines of widthw, fitting just inside rectangler.Texturedraws, with functionfin bitmapb, a texture using the bitmap specified byt. The texture bitmap is aligned onb's coordinate system so that (0,0) in both coordinate systems coincide, and thentis replicated to form a tiling ofb. The tiling is clipped to rectanglerinb, and then transferred tobusing the specified function.Stringdraws the text characters given by the null-terminated (UTF encoded) stringsinto bitmapb, using fontft.The upper left corner of the first character (i.e., a point that isft->ascentabove the baseline) is placed at pointp, and subsequent characters are placed on the same baseline, displaced to the right by the previous character'swidth. The individual characters arebitblt'ed into the destination, using drawing functionf.Stringreturns the point in the destination bitmap after the final character ofs(or where the final character would be drawn, assuming no clipping; the returned value might be outside the destination bitmap). The bounding box for text to be drawn withstringin fontftcan be found withstrsize; it returns themaxpoint of the bounding box, assuming aminpoint of (0,0).Strwidthreturns thex-component of themaxpoint. SEE ALSOgraphics(3g), BITBLT(3G)