All Topics  
Bit blit

 
Bit Blit

   Email Print
   Bookmark   Link






 

Bit blit



 
 
BitBlt (which stands for Bit-Block Transfer, but is pronounced Bit Blit) or the synonymous term Blit (which stands for Block Image Transfer) is a computer graphics
Computer graphics

Computer graphics are graphics created by computers and, more generally, the representation and manipulation of pictorial data by a computer....
 operation in which several bitmap
Bitmap

In computer graphics, a bitmap or pixmap is a type of computer storage organization or used to store digital images. The term bitmap comes from the computer programming terminology, meaning just a map of bits, a spatially mapped bit array....
s are combined into one using a "raster operator".

The operation usually involves just two bitmaps, a source and destination. The source and destination bitmaps are bitwise combined according to the specified Raster OPeration (ROP) and the result is then written on to the destination bitmap.






Discussion
Ask a question about 'Bit blit'
Start a new discussion about 'Bit blit'
Answer questions from other users
Full Discussion Forum



Encyclopedia


BitBlt (which stands for Bit-Block Transfer, but is pronounced Bit Blit) or the synonymous term Blit (which stands for Block Image Transfer) is a computer graphics
Computer graphics

Computer graphics are graphics created by computers and, more generally, the representation and manipulation of pictorial data by a computer....
 operation in which several bitmap
Bitmap

In computer graphics, a bitmap or pixmap is a type of computer storage organization or used to store digital images. The term bitmap comes from the computer programming terminology, meaning just a map of bits, a spatially mapped bit array....
s are combined into one using a "raster operator".

The operation usually involves just two bitmaps, a source and destination. The source and destination bitmaps are bitwise combined according to the specified Raster OPeration (ROP) and the result is then written on to the destination bitmap. The ROP is essentially a boolean
Boolean

Boolean , as a noun or an adjective, may refer to:* Boolean algebra , a logical calculus of truth values or set membership* Boolean algebra , a set with operations resembling logical ones...
 formula. The most obvious ROP just overwrites the destination rectangle with the source rectangle. Other ROPs may involve AND
Logical conjunction

In logic and/or mathematics, logical conjunction or and is a two-place logical operation that results in a value of true if both of its operands are true, otherwise a value of false....
, OR
Logical disjunction

File:ORGate2.pngIn logic and mathematics, or, also known as logical disjunction or inclusive disjunction is a logical operator that results in true whenever one or more of its operands are true....
, XOR and NOT operations.

In some implementations, such as Microsoft Windows GDI
Graphics Device Interface

The Graphics Device Interface is a Microsoft Windows application programming interface and core operating system component that is responsible for representing graphical objects and transmitting them to output devices such as computer display and computer printer....
, a third monochrome pattern (with only 1 bit per pixel) can be referenced in the ROP.

Origins

The name derives from the BitBLT machine instruction for the Xerox Alto
Xerox Alto

The Xerox Alto was an early personal computer developed at Xerox PARC in 1973. It was the first computer to use the desktop metaphor and graphical user interface ....
 computer
Computer

A computer is a machine that manipulates Data according to a list of Code .The first devices that resemble modern computers date to the mid-20th century , although the computer concept and various machines similar to computers existed earlier....
, standing for "Bit Block Transfer". This operation was created by Dan Ingalls at Xerox PARC
Xerox PARC

PARC , formerly Xerox PARC, is a research and development company in Palo Alto, California with a distinguished reputation for its contributions to information technology....
 in late 1974 for the Smalltalk-72 system. For the Smalltalk-74 system, Dan Ingalls implemented a redesigned version in microcode
Microcode

Microcode is a layer of lowest-level instructions involved in the implementation of machine code instructions in many computers and other processors; it resides in a special high-speed memory and translates machine instructions into sequences of detailed circuit-level operations....
.

The development of fast methods for various bit blit operations was key in the evolution of computer displays from using character graphics
Text mode

Text mode is a kind of computer display mode in which the content of the screen is internally represented in terms of textual characters rather than individual pixels....
, to using bitmap graphics
Raster graphics

In computer graphics, a raster graphics image or bitmap, is a data structure representing a generally Rectangle grid of pixels, or points of color, viewable via a Computer display, paper, or other display medium....
 for everything. Machines that rely heavily on the performance of 2D graphics
2D computer graphics

2D computer graphics is the computer-based generation of digital images—mostly from two-dimensional models and by techniques specific to them....
 (such as video game console
Video game console

A video game console is an game development that produces a video signal which can be used with a display device to display a video game. The term "video game console" is used to distinguish a machine designed for consumers to buy and use solely for playing video games from a personal computer, which has many other functions, or arcade machi...
s) often have special-purpose circuitry called a blitter
Blitter

In a computer system, a blitter is a co-processor or a logic block on a microprocessor that is dedicated to rapid data transfer within that computer's RAM....
.

Masked Blit Implementation

A classic use for blitting is to render
Rendering (computer graphics)

Rendering is the process of generating an image from a 3D model, by means of computer programs. The model is a description of three-dimensional objects in a strictly defined language or data structure....
 transparent sprite
Sprite (computer graphics)

In computer graphics, a sprite is a two-dimensional/three-dimensional or animation that is integrated into a larger scene.Sprites were originally invented as a method of quickly compositing several images together in two-dimensional video games using special hardware....
s onto a background. This operation is called a masked blit, and can be implemented with two regular BitBlt operations using the AND and OR raster operations. The technique will be explained shortly.

It is usually not feasible to implement a masked blit by looping through every pixel
Pixel

In digital imaging, a pixel is the smallest item of information in an image. Pixels are normally arranged in a 2-dimensional grid, and are often represented using dots, squares, or rectangles....
 and conditionally drawing it only if it needs to be displayed, due to considerations of speed.

Example of a masked blit


Here is an example of a masked blit to show what we are trying to achieve. We have a background image, a sprite, and a 1-bit mask. As the mask is 1-bit there is no possibility for partial transparency via alpha blending.

Background Image Sprite (Left) and Mask (Right)


We wish to draw the sprite in various positions over the image to produce this:

Intended Result


Technique


When preparing the sprite and mask, the colours 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, we blit the mask onto the background using the raster operator of AND
Bitwise operation

In computer programming, a bitwise operation operates on one or two bit patterns or Binary numeral system at the level of their individual bits....
. Because any value ANDed with 0 equals 0, and any value ANDed with 1 is unchanged, we can create black areas where the actual sprites will appear, and leave the rest of the background alone.

Result of the first blit


In the second blit, we blit the sprite onto the newly altered background using the raster operator of OR
Bitwise operation

In computer programming, a bitwise operation operates on one or two bit patterns or Binary numeral system at the level of their individual bits....
. Because any value OR'd with 0 is unchanged, the background is unaffected and the black areas are filled with the actual sprite image.

Final result


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
Sprite (computer graphics)

In computer graphics, a sprite is a two-dimensional/three-dimensional or animation that is integrated into a larger scene.Sprites were originally invented as a method of quickly compositing several images together in two-dimensional video games using special hardware....
 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 the pattern is placed on the screen, the display "under" it is overwritten, or "damaged". It is up to the software to clean this damage up by blitting twice, once to remove the damage, and then again to place the bit in its new location. 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.

As one might imagine, this makes blitting significantly slower than sprite manipulation. However blitting has one very big advantage: there's no physical limit to the number of patterns you can blit, or to the size of the patterns. Thus you can use blitting to display anything on the screen, including simulating sprites (through the double-write pattern noted above), or even text.

See also

  • Block-transfer instruction
    Block-transfer instruction

    On the PDP-10, the BLT instruction copies Word from Memory address to memory. The left half of the selected AC specifies the first source address....
  • Blitter
    Blitter

    In a computer system, a blitter is a co-processor or a logic block on a microprocessor that is dedicated to rapid data transfer within that computer's RAM....


External links