Bit blit

Last updated

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 in which several bitmaps are combined into one using a boolean function . [1]

Contents

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". The result may be written to a fourth bitmap, though often it replaces the destination. The pixels of each are combined using a program-selectable raster operation, a bit-wise boolean formula. The most obvious raster operation overwrites the destination with the source. Others may involve AND, OR, XOR, and NOT operations. [1] The Commodore Amiga's graphics chipset (and others) could combine three source bitmaps using any of the 256 possible 3-input boolean functions.

Modern graphics software has almost completely replaced bitwise operations with more general mathematical operations used for effects such as alpha compositing. 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 computer, standing for bit-boundary block transfer. Dan Ingalls, Larry Tesler, Bob Sproull, and Diana Merry programmed this operation at Xerox PARC in November 1975 for the Smalltalk-72 system. Dan Ingalls later implemented a redesigned version in microcode.

The development of fast methods for various bit blit operations gave impetus to the evolution of computer displays from using character graphics (text mode) to using raster graphics (bitmap) for everything. Machines that rely heavily on the performance of 2D graphics (such as video game consoles) often have special-purpose circuitry called a blitter .

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.

A loop that examines each bit in the mask and copies the pixel 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.

Background imageSprite (left) and mask (right)
Blit back.png XBlit dot.png

The sprite is drawn in various positions over the image to produce this:

Intended Result
XBlit final.png

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 . 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.

Result of the first blit
XBlit and.png

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.

Final result
XBlit final.png

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. [2] 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 that every time a foreground pattern is placed on the screen, any background pixels underneath it are 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

Related Research Articles

<span class="mw-page-title-main">Amiga Original Chip Set</span> Chipset used in Amiga personal computer

The Original Chip Set (OCS) is a chipset used in the earliest Commodore Amiga computers and defined the Amiga's graphics and sound capabilities. It was succeeded by the slightly improved Enhanced Chip Set (ECS) and the greatly improved Advanced Graphics Architecture (AGA).

<span class="mw-page-title-main">Raster graphics</span> Matrix-based data structure

In computer graphics and digital photography, a raster graphics represents a two-dimensional picture as a rectangular matrix or grid of square pixels, viewable via a computer display, paper, or other display medium. A raster is technically characterized by the width and height of the image in pixels and by the number of bits per pixel. Raster images are stored in image files with varying dissemination, production, generation, and acquisition formats.

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 another relatively quickly, and in parallel with the CPU, while freeing up the CPU's more complex capabilities for other operations. A typical use for a blitter is the movement of a bitmap, such as windows and icons in a graphical user interface or images and backgrounds in a 2D video game. The name comes from the bit blit operation of the 1973 Xerox Alto, which stands for bit-block transfer. A blit operation is more than a memory copy, because it can involve data that's not byte aligned, handling transparent pixels, and various ways of combining the source and destination data.

<span class="mw-page-title-main">Framebuffer</span> Portion of random-access memory containing a bitmap that drives a video display

A framebuffer is a portion of random-access memory (RAM) containing a bitmap that drives a video display. It is a memory buffer containing data representing all the pixels in a complete video frame. Modern video cards contain framebuffer circuitry in their cores. This circuitry converts an in-memory bitmap into a video signal that can be displayed on a computer monitor.

QuickDraw was the 2D graphics library and associated application programming interface (API) which is a core part of classic Mac OS. It was initially written by Bill Atkinson and Andy Hertzfeld. QuickDraw still existed as part of the libraries of macOS, but had been largely superseded by the more modern Quartz graphics system. In Mac OS X Tiger, QuickDraw has been officially deprecated. In Mac OS X Leopard applications using QuickDraw cannot make use of the added 64-bit support. In OS X Mountain Lion, QuickDraw header support was removed from the operating system. Applications using QuickDraw still ran under OS X Mountain Lion to macOS High Sierra; however, the current versions of Xcode and the macOS SDK do not contain the header files to compile such programmes.

<span class="mw-page-title-main">MOS Technology VIC-II</span> Video microchip in the Commodore 64 and C128 home computers

The VIC-II, specifically known as the MOS Technology 6567/6566/8562/8564, 6569/8565/8566 (PAL), is the microchip tasked with generating Y/C video signals and DRAM refresh signals in the Commodore 64 and Commodore 128 home computers.

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 in a single bitwise operation. An additional use of masking involves predication in vector processing, where the bitmask is used to select which element operations in the vector are to be executed and which are not.

<span class="mw-page-title-main">Transparency (graphic)</span> Capability of a computer graphic to allow whatever is "behind" it to be visible

Transparency in computer graphics is possible in a number of file formats. The term "transparency" is used in various ways by different people, but at its simplest there is "full transparency" i.e. something that is completely invisible. Only part of a graphic should be fully transparent, or there would be nothing to see. More complex is "partial transparency" or "translucency" where the effect is achieved that a graphic is partially transparent in the same way as colored glass. Since ultimately a printed page or computer or television screen can only be one color at a point, partial transparency is always simulated at some level by mixing colors. There are many different ways to mix colors, so in some cases transparency is ambiguous.

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 of which contains one of the characters of a character set; at the same time, contrasted to graphics mode or other kinds of computer graphics modes.

<span class="mw-page-title-main">X68000</span> 1987 home computer

The X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.

The Visualize EG is a Hewlett-Packard 2D graphics card used in their Series 700 UNIX workstations.

<span class="mw-page-title-main">MOS Technology 8563</span>

The 8563 Video Display Controller (VDC) was an integrated circuit produced by MOS Technology. It was used in the Commodore 128 (C128) computer to generate an 80-column RGB video display, running alongside a VIC-II which supported Commodore 64-compatible graphics. The DCR models of the C128 used the later and more technically advanced 8568 [D]VDC controller.

<span class="mw-page-title-main">FM Towns</span> Japanese personal computer

The FM Towns is a Japanese personal computer built by Fujitsu from February 1989 to the summer of 1997. It started as a proprietary PC variant intended for multimedia applications and PC games, but later became more compatible with IBM PC compatibles. In 1993, the FM Towns Marty was released, a game console compatible with existing FM Towns games.

<span class="mw-page-title-main">Television Interface Adaptor</span> Video/audio/input chip of the Atari 2600

The Television Interface Adaptor (TIA) is the custom computer chip, along with a variant of the MOS Technology 6502 constituting the heart of the 1977 Atari Video Computer System game console. The TIA generates the screen display, sound effects, and reads the controllers. At the time the Atari VCS was designed, even small amounts of RAM were expensive. The chip was designed around not having a frame buffer, instead requiring detailed programming to create even a simple display.

<span class="mw-page-title-main">TMS9918</span> Video display controller

The TMS9918 is a video display controller (VDC) manufactured by Texas Instruments, in manuals referenced as "Video Display Processor" (VDP) and introduced in 1979. The TMS9918 and its variants were used in the ColecoVision, CreatiVision, Memotech MTX, MSX, NABU Personal Computer, SG-1000/SC-3000, Spectravideo SV-318, SV-328, Sord M5, Tatung Einstein, TI-99/4, Casio PV-2000, Coleco Adam, Hanimex Pencil II, and Tomy Tutor.

<span class="mw-page-title-main">CTIA and GTIA</span> Custom chips used in Atari 8-bit computers

Color Television Interface Adaptor (CTIA) and its successor Graphic Television Interface Adaptor (GTIA) are custom chips used in the Atari 8-bit family of computers and in the Atari 5200 home video game console. In these systems, a CTIA or GTIA chip works together with ANTIC to produce the video display. ANTIC generates the playfield graphics while CTIA/GTIA provides the color for the playfield and adds overlay objects known as player/missile graphics (sprites). Under the direction of Jay Miner, the CTIA/GTIA chips were designed by George McLeod with technical assistance of Steve Smith.

A display list is a series of graphics commands that define an output image so that they may be later run when the list is executed. This activity is most often performed by specialized display or processing hardware partly or completely independent of the system's CPU to free the CPU from the overhead of maintaining the display and may provide output features or speed beyond the CPU's capability.

<span class="mw-page-title-main">VGA text mode</span> Computer graphics standard from 1987

VGA text mode was introduced in 1987 by IBM as part of the VGA standard for its IBM PS/2 computers. Its use on IBM PC compatibles was widespread through the 1990s and persists today for some applications on modern computers. The main features of VGA text mode are colored characters and their background, blinking, various shapes of the cursor, and loadable fonts. The Linux console traditionally uses hardware VGA text modes, and the Win32 console environment has an ability to switch the screen to text mode for some text window sizes.

<span class="mw-page-title-main">PlayStation technical specifications</span> Overview of the technical specifications of the PlayStation

The PlayStation technical specifications describe the various components of the original PlayStation video game console.

References

  1. 1 2 Sanchez, Julio; Maria P. Canton (2007). "Displaying Bit-Mapped images". Software solutions for engineers and scientists. CRC Press. p. 690.
  2. "Framebuffer - OpenGL Wiki". www.khronos.org. Retrieved 23 June 2020. A blit operation is a special form of copy operation; it copies a rectangular area of pixels from one framebuffer to another. This function also has some very specific properties with regard to multisampling.