Jump to content

Planar (computer graphics): Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Kanenas (talk | contribs)
made chunky & planar display examples more similar (to better compare their mechanisms)
Kanenas (talk | contribs)
better described color availability & memory usage, and advantages & disadvantages
Line 57: Line 57:
|}
|}


In the planar example, 2 bytes represent 8 pixels with 4 available colors, where the chunky example uses 2 bytes to represent fewer pixels but with more colors. Adding planes will increase the number of colors available at the cost of requiring more memory. For example, using 4 planes makes 2<sup>4</sup>=16 colors available, but it would then take 4 bytes to represent 8 pixels.
Adding a third plane makes 2<sup>3</sup>=8 colors available. Where fewer than 256 colors are needed, planar graphics are more economical in RAM compared with 8-bit chunky graphics, as there are no unused bits in a given byte.


Planar graphics have the advantages over chunky graphics of more easily handling a variety of color depths, and not wasting bits at certain bit depths. As a hypothetical example, consider 3 {{abbr|bpp|bits-per-pixel}}</abbr>, allowing 32 colors. With planar graphics, this simply requires 3 planes. With chunky graphics, supporting exactly 3 bpp would require either allowing pixels to cross byte boundaries (with corresponding complications addressing pixels) or padding (each byte would store 2 pixels and have 2 unused bits); historically, this is one reason (though not necessarily the main one) chunky graphics used bit depths that fit evenly into bytes. In planar graphics, support for higher bit depths can be added simply by adding bit planes with little to no impact on older software. Planar graphics also allow elements with different bit depths to be easily used together. A disadvantage of planar graphics is that more RAM address cycles are needed for [[scrolling]] and [[animation]]s.
A disadvantage of planar graphics is that more RAM address cycles are needed for [[scrolling]] and [[animation]]s.
==See also==
==See also==
*[[Packed pixel]]
*[[Packed pixel]]

Revision as of 05:41, 21 December 2020

In computer graphics, planar is the method of representing pixel colors with several bitplanes of RAM. Each bit in a bitplane is related to one pixel on the screen. Unlike chunky, high color, or true color graphics, the whole dataset for an individual pixel isn't in one specific location in RAM, but spread across the bitplanes that make up the display.

This scheme originated in the early days of computer graphics. The memory chips of this era can not supply data fast enough on their own to generate a picture on a TV screen or monitor from a large framebuffer.[1] By splitting the data up into multiple planes, each plane can be stored on a separate memory chip. These chips can then be read in parallel at a slower rate, allowing graphical display on modest hardware. The EGA video adapter on early IBM PC computers uses planar arrangement in color graphical modes for this reason. The later VGA includes one non-planar mode which sacrifices memory efficiency for more convenient access.[2]

Combining four one-bit planes into a final "four bits per pixel" (16-color) image

For example, on a chunky display with 4-bits-per-pixel and a "true-color" palette (indexed color is generally used with less than 2 bytes per pixel), each byte represents two pixels, with 16 different colors available for each pixel. Four pixels in a row are stored as follows:

Byte index 0 1
Byte value (decimal) 1 35
Byte value (hexadecimal) 0x01 0x23
Nybble value (binary) 1000 1001 1010 1011
Nybble value (decimal) 0 1 2 3
Resulting pixel Black Blue Green Cyan

Whereas a planar scheme could use 2 bitplanes, providing for a 4 color display. Eight pixels would be stored as 2 bytes non-contiguously in memory:

Byte index 0 Byte value
Bit index 0 1 2 3 4 5 6 7 hexadecimal decimal
Plane 0 0 1 0 1 0 0 0 0 0x50 80
Plane 1 0 0 1 1 0 0 0 0 0x30 48
Resulting pixel 0 1 2 3 0 0 0 0

In the planar example, 2 bytes represent 8 pixels with 4 available colors, where the chunky example uses 2 bytes to represent fewer pixels but with more colors. Adding planes will increase the number of colors available at the cost of requiring more memory. For example, using 4 planes makes 24=16 colors available, but it would then take 4 bytes to represent 8 pixels.

Planar graphics have the advantages over chunky graphics of more easily handling a variety of color depths, and not wasting bits at certain bit depths. As a hypothetical example, consider 3 bpp, allowing 32 colors. With planar graphics, this simply requires 3 planes. With chunky graphics, supporting exactly 3 bpp would require either allowing pixels to cross byte boundaries (with corresponding complications addressing pixels) or padding (each byte would store 2 pixels and have 2 unused bits); historically, this is one reason (though not necessarily the main one) chunky graphics used bit depths that fit evenly into bytes. In planar graphics, support for higher bit depths can be added simply by adding bit planes with little to no impact on older software. Planar graphics also allow elements with different bit depths to be easily used together. A disadvantage of planar graphics is that more RAM address cycles are needed for scrolling and animations.

See also

References

  1. ^ Rogers, David F. (1985). Procedural Elements for Computer Graphics. McGraw-Hill. p. 13. ISBN 0-07-053534-5.
  2. ^ "VGA Hardware - OSDev Wiki". wiki.osdev.org. Retrieved September 4, 2017.