1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
|
.TH BITBLT 3G
.SH NAME
bitblt, bitbltclip, copymasked, clipline, point, segment, polysegment, arc, circle, disc, ellipse, texture, border, string, strsize, strwidth, Fcode \- graphics functions
.SH SYNOPSIS
.nf
.B
#include <libc.h>
.B
#include <libg.h>
.PP
.ta \w'\fLPoint 'u
.B
void bitblt(Bitmap *db, Point dp, Bitmap *sb,
.B
Rectangle sr, Fcode f)
.PP
.B
int bitbltclip(void *)
.PP
.B
void copymasked(Bitmap *db, Point dp, Bitmap *sb, Bitmap *mb, Rectangle sr)
.PP
.B
int clipline(Rectangle r, Point *p0, Point *p1);
.PP
.B
void point(Bitmap *b, Point p, int v, Fcode f);
.PP
.B
void segment(Bitmap *b, Point p, Point q, int v, Fcode f)
.PP
.B
void polysegment(Bitmap *b, int n, Point *pp, int v, Fcode f)
.PP
.B
void circle(Bitmap *b, Point p, int r, int v, Fcode f);
.PP
.B
void arc(Bitmap *b, Point p0, Point p1, Point p2, int v, Fcode f);
.PP
.B
void disc(Bitmap *b, Point p, int r, int v, Fcode f);
.PP
.B
void ellipse(Bitmap *b, Point p, int a, int b, int v, Fcode f);
.PP
.B
void texture(Bitmap *b, Rectangle r, Bitmap *t, Fcode f)
.PP
.B
void border(Bitmap *b, Rectangle r, int w, Fcode f)
.PP
.B
Point string(Bitmap *b, Point p, Font *ft, char *s, Fcode f)
.PP
.B
Point strsize(Font *ft, char *s)
.PP
.B
long strwidth(Font *ft, char *s)
.PP
.ft L
.ta 8n +\w'xxxxxxxxxx'u +\w'xxxxxxxxxx'u +\w'xxxxxxxxxx'u +\w'xxxxxxxxxx'u
enum Fcode {
Zero, DnorS, DandnotS, notS,
notDandS, notD, DxorS, DnandS,
DandS, DxnorS, D, DornotS,
S, notDorS, DorS, F
} Fcode;
.ft P
.fi
.SH DESCRIPTION
.I Bitblt
(bit-block transfer)
takes bits from rectangle
.I sr
in the
.I source
Bitmap,
.IR sb,
and overlays them on a congruent rectangle with the
.B min
corner at point
.B dp
in the
.I destination
bitmap,
.IR db .
The
.I f
parameter says how to compute each destination pixel
as a function of the source and destination pixels.
The first sixteen codes in
.B Fcode
give all possible boolean operations
on the source,
.B S
and destination
.BR D .
The code values have been arranged so that they may be expressed as
boolean operations on the values
.B S
and
.BR D.
So, for example,
.B D|S
computes the result as the logical
.I 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
.B Zero
and
.B F
codes result in new pixel values that are all zeros or all ones, respectively.
.PP
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.
.PP
.I Copymasked
copies rectangle
.I sr
in the source bitmap
.I sb
to the congruent rectangle with the
.B min
corner at point
.B dp
in the destination bitmap
.IR db ,
masked by
bitmap
.I mb .
This means that
.I mb
is overlayed on the destination rectangle, and only pixels corresponding to 1 bits
in the mask are changed.
.I Mb
must be a 1-bit-deep bitmap with origin (0,0) and congruent to
.IR sr .
Bitmaps
.I sb
and
.I db
must have the same depth.
.PP
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.
.I Bitbltclip
takes a pointer to the first argument of a
.I bitblt
argument list, and modifies
.I dp
and
.I sr
so that no more clipping is needed.
.PP
.I Point
changes the value of the destination point
.I p
in bitmap
.I b
according to function code
.IR f .
The source is a pixel with
value
.IR v .
It is useful to use
.B "~0"
when the maximum pixel value is desired for the source.
.PP
.IR Segment ,
.IR circle ,
.IR disc ,
and
.I ellipse
all draw in bitmap
.I b
with function code
.I f
and a source pixel with value
.IR v .
.I Arc
draws a circular arc centered on
.IR p0 ,
traveling clockwise from
.I p1
to
.I p2
or a point on the circle near
.IR p2 .
.I Segment
draws a line segment in bitmap
.I b
from point
.I p
to
.IR q .
The segment is half-open:
.I p
is the first point of the segment and
.I q
is the first point beyond the segment,
so adjacent segments sharing endpoints abut.
.PP
.I Polysegment
draws the
.IR n \-1
segments joining the
.I n
points in the array pointed to by
.I pp.
.I Clipline
clips the line segment from
.RI * p0
to
.RI * p1
.RI ( p0
is closed,
.I p1
is open)
to rectangle
.IR r ,
adjusting
.I p0
and
.I p1
so that the segment is within the rectangle and
.RI * p1
is closed.
It returns 0 if none of the segment is in the rectangle, 1 otherwise.
.PP
.I Circle
draws a circle with radius
.I r
and center at point
.IR p .
.I Disc
is the same except that it fills the circle.
.I Ellipse
draws an ellipse with horizontal semi-axis
.I a
and vertical semi-axis
.IR b.
.PP
.I Border
draws, with function
.I f
in bitmap
.IR b ,
the rectangular outline with lines of width
.IR w ,
fitting just inside rectangle
.IR r .
.PP
.I Texture
draws, with function
.I f
in bitmap
.IR b ,
a texture using the
bitmap specified by
.IR t .
The texture bitmap is aligned on
.IR b 's
coordinate system so that (0,0) in both coordinate systems coincide,
and then
.I t
is replicated to form a tiling of
.IR b .
The tiling is clipped to rectangle
.I r
in
.IR b ,
and then transferred to
.I b
using the specified function.
.PP
.I String
draws the text characters given by the null-terminated (UTF
encoded) string
.I s
into bitmap
.IR b ,
using font
.IR ft.
The upper left corner of the first character (i.e., a point
that is
.IB ft ->ascent
above the baseline) is placed at point
.IR p ,
and subsequent characters are placed on the same baseline, displaced to
the right by the previous character's
.BR width .
The individual characters are
.IR bitblt 'ed
into the destination, using drawing function
.IR f .
.I String
returns the point in the destination bitmap after the final character of
.I s
(or where the final character would be drawn, assuming no clipping;
the returned value might be outside the destination bitmap).
.PP
The bounding box for text to be drawn with
.I string
in font
.I ft
can be found with
.IR strsize ;
it returns the
.B max
point of the bounding box, assuming a
.B min
point of (0,0).
.I Strwidth
returns the
.IR x -component
of the
.B max
point.
.SH SEE ALSO
.IR graphics (3g),
.IT utf (5g).
|