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 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, XOR, and NOT operations. [1] The Commodore Amiga's graphics chipset (and others) could combine three source bitmaps using any of the 256 possible boolean functions with three inputs.

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

Related Research Articles

Original Chip Set

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 greatly improved Advanced Graphics Architecture (AGA).

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

Framebuffer 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 is the 2D graphics library and associated Application Programming Interface (API) which is a core part of the classic Mac OS operating system. It was initially written by Bill Atkinson and Andy Hertzfeld. QuickDraw still existed as part of the libraries of Mac OS X, but had been largely superseded by the more modern Quartz graphics system. In Mac OS X v10.4, QuickDraw has been officially deprecated. In Mac OS X v10.5 applications using QuickDraw cannot make use of the added 64-bit support. In Mac OS X v10.8, QuickDraw header support was removed from the operating system. Applications using QuickDraw will still run under OS X 10.8 through macOS 10.13; however, the current versions of Xcode and the macOS SDK do not contain the header files to compile such programs.

Commodore 64 demos

The Commodore 64 (C64) demos are demonstrations of what can be done to push the limits of the Commodore 64 computer, made by programmers, musicians and artists.

MOS Technology VIC-II Video microchip in the Commodore 64 and C128 home computers

The VIC-II, specifically known as the MOS Technology 6567/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 C128 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.

Pixel art Form of digital art

Pixel art, also called Pixel-art or simply Pixelart, is a form of digital art, drawn with software, whereby images are built with the exclusive and intentional placement of pixels.

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 all points addressable (APA) mode or other kinds of computer graphics modes.

X68000 Home computer

The X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan. Gaming was a major use of the X68000, with custom sprite hardware and an 8-channel sound chip enabling ports of contemporaneous arcade video games.

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

Television Interface Adaptor 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. It is part of 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.

Texas Instruments TMS9918 Video display controller by Texas Instruments

The TMS9918 is a video display controller (VDC) manufactured by Texas Instruments and introduced in 1979. The TMS9918 and its variants were used in the ColecoVision, CreatiVision, Memotech MTX, MSX, SG-1000/SC-3000, Spectravideo, Sord M5, Tatung Einstein, Texas Instruments TI-99/4, Casio PV-2000, and Tomy Tutor.

Sprite (computer graphics) A 2D bitmap displayed on top of a larger scene

In computer graphics, a sprite is a two-dimensional bitmap that is integrated into a larger scene, most often in a 2D video game. Originally, the term sprite referred to fixed-sized objects composited together, by hardware, with a background. Use of the term has since become more general.

CTIA and GTIA

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. The image is created (rendered) by executing the commands to combine various primitives. This activity is most often performed by specialized display or processing hardware partly or completely independent of the system's CPU for the purpose of freeing the CPU from the overhead of maintaining the display, and may provide output features or speed beyond the CPU's capability.

The render output unit, often abbreviated as "ROP", and sometimes called raster operations pipeline, is a hardware component in modern graphics processing units (GPUs) and one of the final steps in the rendering process of modern graphics cards. The pixel pipelines take pixel, and texel information and process it, via specific matrix and vector operations, into a final pixel or depth value. This process is called rasterization. So ROPs control antialiasing, when more than one sample is merged into one pixel. The ROPs perform the transactions between the relevant buffers in the local memory – this includes writing or reading values, as well as blending them together. Dedicated antialiasing hardware used to perform hardware-based antialiasing methods like MSAA is contained in ROPs.

In computing, a bitmap is a mapping from some domain to bits. It is also called a bit array or bitmap index.

PlayStation technical specifications 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.