HOME

TheInfoList



OR:

Bit blit (also written BITBLT, BIT BLT, BitBLT, Bit BLT, Bit Blt etc., which stands for ''bit block transfer'') is a data operation commonly used in
computer graphics Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great de ...
in which several
bitmap In computing, a bitmap is a mapping from some domain (for example, a range of integers) to bits. It is also called a bit array A bit array (also known as bitmask, bit map, bit set, bit string, or bit vector) is an array data structure that c ...
s are combined into one using a ''
boolean function In mathematics, a Boolean function is a function whose arguments and result assume values from a two-element set (usually , or ). Alternative names are switching function, used especially in older computer science literature, and truth function ( ...
''. The operation involves at least two bitmaps: a "source" (or "foreground") and a "destination" (or "background"), and possibly a third that is often called the "
mask A mask is an object normally worn on the face, typically for protection, disguise, performance, or entertainment and often they have been employed for rituals and rights. Masks have been used since antiquity for both ceremonial and practic ...
". The result may be written to a fourth bitmap, though often it replaces the destination. The pixels of each are combined bitwise according to the specified raster operation (ROP) and the result is then written to the destination. The ROP is essentially a boolean formula. The most obvious ROP overwrites the destination with the source. Other ROPs may involve
AND or AND may refer to: Logic, grammar, and computing * Conjunction (grammar), connecting two words, phrases, or clauses * Logical conjunction in mathematical logic, notated as "∧", "⋅", "&", or simple juxtaposition * Bitwise AND, a boolea ...
, OR,
XOR Exclusive or or exclusive disjunction is a logical operation that is true if and only if its arguments differ (one is true, the other is false). It is symbolized by the prefix operator J and by the infix operators XOR ( or ), EOR, EXOR, , ...
, and NOT operations. The Commodore
Amiga Amiga is a family of personal computers introduced by Commodore in 1985. The original model is one of a number of mid-1980s computers with 16- or 32-bit processors, 256 KB or more of RAM, mouse-based GUIs, and significantly improved graphi ...
's graphics chipset (and others) could combine three source bitmaps using any of the 256 possible
boolean function In mathematics, a Boolean function is a function whose arguments and result assume values from a two-element set (usually , or ). Alternative names are switching function, used especially in older computer science literature, and truth function ( ...
s with three inputs. Modern graphics software has almost completely replaced bitwise operations with more general mathematical operations used for effects such as
alpha compositing In computer graphics, alpha compositing or alpha blending is the process of combining one image with a background to create the appearance of partial or full transparency. It is often useful to render picture elements (pixels) in separate pas ...
. This is because bitwise operations on color displays do not usually produce results that resemble the physical combination of lights or inks. Some software still uses XOR to draw interactive highlight rectangles or region borders; when this is done to color images, the unusual resulting colors are easily seen.


Origins

The name derives from the ''BitBLT'' routine for the
Xerox Alto The Xerox Alto is a computer designed from its inception to support an operating system based on a graphical user interface (GUI), later using the desktop metaphor. The first machines were introduced on 1 March 1973, a decade before mass-market ...
computer A computer is a machine that can be programmed to Execution (computing), carry out sequences of arithmetic or logical operations (computation) automatically. Modern digital electronic computers can perform generic sets of operations known as C ...
, standing for ''bit-boundary block transfer''.
Dan Ingalls Daniel Henry Holmes Ingalls Jr. (born 1944) is a pioneer of object-oriented computer programming and the principal architect, designer and implementer of five generations of Smalltalk environments. He designed the bytecoded virtual machine that ...
,
Larry Tesler Lawrence Gordon Tesler (April 24, 1945 – February 16, 2020) was an American computer scientist who worked in the field of human–computer interaction. Tesler worked at Xerox PARC, Apple, Amazon, and Yahoo! While at PARC, Tesler's work include ...
,
Bob Sproull Robert Fletcher "Bob" Sproull (born c. 1945) is an American computer scientist, who worked for Oracle Corporation where he was director of Oracle Labs in Burlington, Massachusetts. He is currently an adjunct professor at the College of Informat ...
, and
Diana Merry Diana Merry-Shapiro was a computer programmer for the Learning Research Group of Xerox PARC in the 1970s and 1980s, after having been hired originally as a secretary. As one of the original developers of the Smalltalk programming language, she hel ...
programmed this operation at
Xerox PARC PARC (Palo Alto Research Center; formerly Xerox PARC) is a research and development company in Palo Alto, California. Founded in 1969 by Jacob E. "Jack" Goldman, chief scientist of Xerox Corporation, the company was originally a division of Xero ...
in November 1975 for the
Smalltalk Smalltalk is an object-oriented, dynamically typed reflective programming language. It was designed and created in part for educational use, specifically for constructionist learning, at the Learning Research Group (LRG) of Xerox PARC by Alan Ka ...
-72 system.
Dan Ingalls Daniel Henry Holmes Ingalls Jr. (born 1944) is a pioneer of object-oriented computer programming and the principal architect, designer and implementer of five generations of Smalltalk environments. He designed the bytecoded virtual machine that ...
later implemented a redesigned version in
microcode In processor design, microcode (μcode) is a technique that interposes a layer of computer organization between the central processing unit (CPU) hardware and the programmer-visible instruction set architecture of a computer. Microcode is a laye ...
. The development of fast methods for various bit blit operations gave impetus to the evolution of computer displays from using character graphics (
text mode Text mode is a computer display mode in which content is internally represented on a computer screen in terms of characters rather than individual pixels. Typically, the screen consists of a uniform rectangular grid of ''character cells'', each ...
) to using
raster graphics upright=1, The Smiley, smiley face in the top left corner is a raster image. When enlarged, individual pixels appear as squares. Enlarging further, each pixel can be analyzed, with their colors constructed through combination of the values for ...
(bitmap) for everything. Machines that rely heavily on the performance of
2D graphics 2D computer graphics is the computer-based generation of digital images—mostly from two-dimensional models (such as 2D geometric models, text, and digital images) and by techniques specific to them. It may refer to the branch of computer s ...
(such as
video game console A video game console is an electronic device that Input/output, outputs a video signal or image to display a video game that can be played with a game controller. These may be home video game console, home consoles, which are generally placed i ...
s) often have special-purpose circuitry called a ''
blitter A blitter is a circuit, sometimes as a coprocessor or a logic block on a microprocessor, dedicated to the rapid movement and modification of data within a computer's memory. A blitter can copy large quantities of data from one memory area to anot ...
''.


Example of a masked blit implementation

A classic use for blitting is to render transparent sprites onto a background. In this example a background image, a sprite, and a 1-bit mask are used. As the mask is 1-bit, there is no possibility for partial transparency via
alpha blending In computer graphics, alpha compositing or alpha blending is the process of combining one image with a background to create the appearance of partial or full transparency. It is often useful to render picture elements (pixels) in separate pas ...
. A loop that examines each bit in the mask and copies the
pixel In digital imaging, a pixel (abbreviated px), pel, or picture element is the smallest addressable element in a raster image, or the smallest point in an all points addressable display device. In most digital display devices, pixels are the smal ...
from the sprite only if the mask is set will be much slower than hardware that can apply exactly the same operation to every pixel. Instead a ''masked blit'' can be implemented with two regular BitBlit operations using the AND and OR raster operations. The sprite is drawn in various positions over the image to produce this:


Technique

When preparing the sprite, the colors are very important. The mask pixels are 0 (black) wherever the corresponding sprite pixel is to be displayed, and 1 (white) wherever the background needs to be preserved. The sprite must be 0 (black) anywhere where it is supposed to be transparent, but note that black can be used in the non-transparent regions. In the first blit, the ''mask'' is blitted onto the ''background'' using the raster operator ''
AND or AND may refer to: Logic, grammar, and computing * Conjunction (grammar), connecting two words, phrases, or clauses * Logical conjunction in mathematical logic, notated as "∧", "⋅", "&", or simple juxtaposition * Bitwise AND, a boolea ...
''. Because any value ANDed with 0 equals 0, and any value ANDed with 1 is unchanged, black areas are created where the actual sprites will appear, while leaving the rest of the background alone. In the second blit, the ''sprite'' is blitted onto the newly altered background using the raster operator of '' OR''. Because any value ORed with 0 is unchanged, the background is unaffected and the black areas are filled with the actual sprite image. It is also possible to achieve the same effect using a sprite with a white background and a white-on-black mask. In this case, the mask would be ORed first, and the sprite ANDed next.


Blitting vs hardware sprites

Blitting is similar to hardware- sprite drawing, in that both systems reproduce a pattern, typically a square area, at different locations on the screen. Hardware sprites have the advantage of being stored in separate memory, and therefore don't disturb the main display memory. This allows them to be moved about the display, covering the "background", with no effect on it. Blitting moves the same types of patterns about the screen, but does so by writing into the same memory as the rest of the display. This means every time a foreground pattern is placed on the screen, any background pixels underneath overwritten, or "damaged". It is up to the software to repair this damage by blitting twice, once to restore the pixels that were changed, and then again to place the foreground pattern in its new location. One way to do it is to store the required patterns in VRAM offscreen and to reserve another area offscreen as a sort of stack to temporarily store the affected display section. Assuming the graphics chip has dedicated VRAM this is useful to lessen the strain on system RAM but also the bandwidth limited ISA expansion slot on older PC systems. However, there are several ways to optimize this. If large areas of the screen are taken over by the patterns, it may be more efficient to blit the background to the screen instead of erasing each pattern individually. A variation involves dividing the screen into segments and erasing only the segments where patterns have been drawn on. This technique is known as dirty rectangles.


See also

*
Alpha compositing In computer graphics, alpha compositing or alpha blending is the process of combining one image with a background to create the appearance of partial or full transparency. It is often useful to render picture elements (pixels) in separate pas ...
*
Mask (computing) In computer science, a mask or bitmask is data that is used for bitwise operations, particularly in a bit field. Using a mask, multiple bits in a byte, nibble, word, etc. can be set either on or off, or inverted from on to off (or vice versa) in ...
, used here as a
stencil Stencilling produces an image or pattern on a surface, by applying pigment to a surface through an intermediate object, with designed holes in the intermediate object, to create a pattern or image on a surface, by allowing the pigment to reach ...
*
Blitter A blitter is a circuit, sometimes as a coprocessor or a logic block on a microprocessor, dedicated to the rapid movement and modification of data within a computer's memory. A blitter can copy large quantities of data from one memory area to anot ...


References

{{reflist


External links


Performance demonstration coded in Flash/AS3

Xerox Inter-Office Memorandum 19 November 1975
Computer graphics algorithms