Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Bit blit
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Data operation used in computer graphics}} {{one source|date=December 2017}} '''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 [[bitmap]]s are combined into one using a ''[[Truth_table#Binary_operations|boolean function]]''.<ref name="Sanchez"/> 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 "[[stencil|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 logic|boolean]] formula. The most obvious raster operation overwrites the destination with the source. Others may involve [[Logical conjunction|AND]], [[Logical disjunction|OR]], [[XOR]], and [[negation|NOT]] operations.<ref name="Sanchez">{{cite book|last=Sanchez|first=Julio |author2=Maria P. Canton|title=Software solutions for engineers and scientists |publisher=CRC Press|date=2007|pages=690|chapter=Displaying Bit-Mapped images|isbn=978-1-4200-4303-7 |chapter-url=https://books.google.com/books?id=jtKc0k5BWA8C&pg=PA690}}</ref> The Commodore [[Amiga]]'s graphics chipset (and others) could combine three source bitmaps using any of the 256 possible 3-input [[boolean function]]s. 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 computer graphics|2D graphics]] (such as [[video game console]]s) often have special-purpose circuitry called a ''[[blitter]]''. == Example of a masked blit implementation == A classic use for blitting is to [[rendering (computer graphics)|render]] transparent [[sprite (computer graphics)|sprite]]s 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 compositing#Alpha blending|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. {| class="wikitable" |- ! Background image ! Sprite (left) and mask (right) |- |align="center"| [[File:Blit back.png]] |align="center"| [[Image:XBlit_dot.png]] |} The sprite is drawn in various positions over the image to produce this: {| class="wikitable" |- ! Intended Result |- |align="center"| [[Image:XBlit_final.png|none]] |} === 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 ''[[bitwise operation#AND|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. {| class="wikitable" |- ! Result of the first blit |- |align="center"| [[Image:XBlit_and.png|none]] |} In the second blit, the ''sprite'' is blitted onto the newly altered background using the raster operator of ''[[bitwise operation#OR|OR]]''. Because any value ORed with 0 is unchanged, the background is unaffected and the black areas are filled with the actual sprite image. {| class="wikitable" |- ! Final result |- |align="center"| [[Image:XBlit_final.png|none]] |} 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== {{See also|Sprite (computer graphics)}} Blitting is similar to hardware-[[Sprite (computer graphics)|sprite]] drawing, in that both systems reproduce a pattern, typically a square area, at different locations on the screen.<ref>{{cite web |title=Framebuffer - OpenGL Wiki |url=https://www.khronos.org/opengl/wiki/Framebuffer#Blitting |website=www.khronos.org |accessdate=23 June 2020 |quote=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.}}</ref> 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 == * [[Alpha compositing]] * [[Mask (computing)]], used here as a [[stencil]] * [[Blitter]] == References == {{reflist}} ==External links== * [http://bitsavers.org/pdf/xerox/alto/BitBLT_Nov1975.pdf Xerox Inter-Office Memorandum 19 November 1975] [[Category:Computer graphics algorithms]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:One source
(
edit
)
Template:Reflist
(
edit
)
Template:See also
(
edit
)
Template:Short description
(
edit
)