bitblt

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;

DESCRIPTION
       Bitblt (bit-block transfer) takes bits from rectangle sr in the source
       Bitmap, sb, and overlays them on a congruent rectangle with the min
       corner at point dp in the destination bitmap, db.  The f parameter says
       how to compute each destination pixel as a function of the source and
       destination pixels.  The first sixteen codes in Fcode give all possible
       boolean operations on the source, S and destination D.  The code values
       have been arranged so that they may be expressed as boolean operations
       on the values S and D.  So, for example, D|S computes the result as the
       logical or of 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.  The Zero and F codes 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.

       Copymasked copies rectangle sr in the source bitmap sb to the congruent
       rectangle with the min corner at point dp in the destination bitmap db,
       masked by bitmap mb .  This means that mb is overlayed on the
       destination rectangle, and only pixels corresponding to 1 bits in the
       mask are changed.  Mb must be a 1-bit-deep bitmap with origin (0,0) and
       congruent to sr.  Bitmaps sb and db must 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.  Bitbltclip takes a pointer
       to the first argument of a bitblt argument list, and modifies dp and sr
       so that no more clipping is needed.

       Point changes the value of the destination point p in bitmap b
       according to function code f.  The source is a pixel with value v.  It
       is useful to use ~0 when the maximum pixel value is desired for the
       source.

       Segment, circle, disc, and ellipse all draw in bitmap b with function
       code f and a source pixel with value v.  Arc draws a circular arc
       centered on p0, traveling clockwise from p1 to p2 or a point on the
       circle near p2.  Segment draws a line segment in bitmap b from point p
       to q.  The segment is half-open: p is the first point of the segment
       and q is the first point beyond the segment, so adjacent segments
       sharing endpoints abut.

       Polysegment draws the n-1 segments joining the n points in the array
       pointed to by pp.  Clipline clips the line segment from *p0 to *p1 (p0
       is closed, p1 is open) to rectangle r, adjusting p0 and p1 so that the
       segment is within the rectangle and *p1 is closed.  It returns 0 if
       none of the segment is in the rectangle, 1 otherwise.

       Circle draws a circle with radius r and center at point p.  Disc is the
       same except that it fills the circle.  Ellipse draws an ellipse with
       horizontal semi-axis a and vertical semi-axis b.

       Border draws, with function f in bitmap b, the rectangular outline with
       lines of width w, fitting just inside rectangle r.

       Texture draws, with function f in bitmap b, a texture using the bitmap
       specified by t.  The texture bitmap is aligned on b's coordinate system
       so that (0,0) in both coordinate systems coincide, and then t is
       replicated to form a tiling of b.  The tiling is clipped to rectangle r
       in b, and then transferred to b using the specified function.

       String draws the text characters given by the null-terminated (UTF
       encoded) string s into bitmap b, using font ft.  The upper left corner
       of the first character (i.e., a point that is ft->ascent above the
       baseline) is placed at point p, and subsequent characters are placed on
       the same baseline, displaced to the right by the previous character's
       width.  The individual characters are bitblt'ed into the destination,
       using drawing function f.  String returns the point in the destination
       bitmap after the final character of s (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 with string in font ft can be
       found with strsize; it returns the max point of the bounding box,
       assuming a min point of (0,0).  Strwidth returns the x-component of the
       max point.

SEE ALSO
       graphics(3),



                                                                    BITBLT(3G)