Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site turtlevax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!oliveb!hplabs!turtlevax!ken From: ken@turtlevax.UUCP (Ken Turkowski) Newsgroups: net.graphics Subject: Re: rasterops Message-ID: <914@turtlevax.UUCP> Date: Mon, 30-Sep-85 14:00:16 EDT Article-I.D.: turtleva.914 Posted: Mon Sep 30 14:00:16 1985 Date-Received: Wed, 2-Oct-85 05:30:07 EDT References: <588@stc-b.stc.UUCP> <5988@utzoo.UUCP> Reply-To: ken@turtlevax.UUCP (Ken Turkowski) Organization: CADLINC, Inc. @ Menlo Park, CA Lines: 61 Keywords: Rasterops for multi-bit systems Summary: In article <5988@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes: >> Henry, how about a succinct explanation/definition of rasterops?. > >RasterOp (also known as BitBlt) is the basic primitive operation for >modern bit-map raster graphics. It combines a source rectangle of bits >with a destination rectangle of bits, with a number of variations on the >combining function. Using C notation, D=S gives straight copying, D|=S >gives "overprinting", D^=S gives reversible overprinting that is very >useful for things like highlighting and cursors, D&=~S gives erasing, a >few other combinations give useful results. Most RasterOp implementations >also support replication of a "texture" over a rectangle, again potentially >using any of the combining functions. There are various other complexities >that some implementations add: clipping, combining two source rectangles >before working on the destination, etc. Extensions to handle more than >one bit per pixel are straightforward although the combining functions >become much more complicated. I would like to clarify the application of RasterOp to multi-bit systems. Four functions are readily extended to multi-bit and color systems: OVERWRITE, FLIP, MIX, and ERASE. For overwriting, one simply replaces the destination by the source (D=S). FLIPping is used mostly for cursors and rubber-band lines; its only useful definition is that there is no net change after doing a FLIP with both source and destinations the same. This is usually implemented by performing a generalized exclusive-OR of the source with the destination. MIX is a function that merges the features of the source with the destination. Determination of what constitutes "feature" is simplified if the source is of type "alpha", where alpha is a measure of opacity (somewhere between 0 and 1, inclusive). Otherwise, an alpha mask has to be somehow extracted from the source. The defining equation for each pixel is: D' = (1-alpha) * D + alpha * S = D + alpha * (S - D) where D' is the new value to be plugged into the frame store, D is the old value in the framestore, and S is the value in the source. The multiplication and addition should be appropriately interpreted in the algebra of the color space. Logical-OR, saturating-add, and average are some operations which have been used to implement the MIX function when the source is not alpha. ERASE is defined to be the pseudo-inverse of MIX. Theoretically, the original values in the frame store can be recovered as long as alpha!=1: D = (D' - alpha * S) / (1 - alpha) Quantization may prevent perfect erasure. Some useful convention is used when alpha==0, because the above equation yields 0/0. As Henry indicates above, it is also useful to modulate the above functions with a periodic texture. Any other functions applied to either single- or multi-bit RasterOps are difficult to understand and have limited utility. -- Ken Turkowski @ CADLINC, Menlo Park, CA UUCP: {amd,decwrl,hplabs,seismo,spar}!turtlevax!ken ARPA: turtlevax!ken@DECWRL.ARPA Brought to you by Super Global Mega Corp .com