Raster operation

from Wikipedia, the free encyclopedia

A raster operation ( ROP for short ) uses Boolean operators to link the image data to be written with the values already in the frame buffer . A distinction between binary ROPs that link only source and target each other and, in addition rarely used ternary operators a brush ( Brush use). In contrast to blending , integer color values ​​are linked with one another in raster operations, since logical links generally cannot be applied to floating point numbers .

In the simplest case, the pixels of the image to be written are written without regard to the content of the frame buffer. The source is linked with a logical one, the destination with a logical zero. Since the source is taken over unchanged, the operation performed is called a copy .

Masking functions are a common area of ​​application for ROPs: the output image and a black-and-white image (the mask) are linked with an AND operator. This link with a black pixel in the mask always leads to a black pixel; a white pixel leaves the output data unchanged. With this method it is possible to create transparency effects, i. H. only render parts of the image.

Another use of raster operations is to invert a graphic. For this purpose, the image data are linked with an XOR link applied to a white mask. Since every bit in the mask is set, every bit in the image is inverted, so the result is the negative of the original.

The Boolean raster operation is always carried out the same on all bits of all pixels. Therefore, with the above-mentioned XOR link, the complementary color results, provided that it is not pallet indices. In the case of pallet images, however, only the complement of the pallet index results. The expected visual result is then only obtained through the complementary distribution of color values ​​in the palette. In practice, the two “ends” of the palette are assigned fixed, frequently used color values, such as index 0 with black and index 255 with white. Under MS Windows, 20 complementary palette entries are reserved for a screen display with 256 colors, 10 “below” and 10 “above”.

functionality

With binary ROPs there are a total of 2 4 = 16 combinations to link source and target data. Source data bits are usually symbolized with P (for pattern) and target data bits with D (for destination). Since both P and D can be logic zero or one, this results in 2 2 = 4 combinations of the coincidence of bits. A 4 line long (= 2 address bits) and 1 bit wide lookup table then translates into the result bit . There are 16 possible.

6 (of 16 possible) lookup tables
P D. black notmergepen xorpen copyping merge white
0 0 0 1 0 0 0 1
0 1 0 0 1 0 1 1
1 0 0 0 1 1 1 1
1 1 0 0 0 1 1 1
logical: 0 DPon DPx P DPo 1

Implementation via a lookup table is favorable for graphics processors . When using a universal processor, the lookup table is replaced by a (here faster) logical link that processes several bits at the same time. The specification of the logic operation can be found abbreviated in Reverse Polish Notation approximately as follows: DPx- means D exclusively or -linked with P .

With ternary ROPs there are a total of 2 8 = 256 combinations, the B bit (for brush) is added. The lookup table is accordingly 8 lines (= 3 address bits) long.

Advantages and disadvantages

Binary raster operations are ideal for screens with little color depth , such as black and white, and are easy to implement and fast. They do not suffer from saturation effects such as arithmetic ( alpha blending ) and are very favorable for CAD processing in several layers (typically circuit board design ). On the other hand, they are hardly suitable for image processing in high color depth (such as photos). The use of color-rich systems has made binary raster operations out of fashion. In vector graphics, binary ROPs are only supported in the Windows WMF and EMF vector files and cause problems when converting to those that do not support them.

Alpha blending as an important modern operation is increasingly replacing binary raster operations and is available in almost all modern vector graphic formats, such as PDF and SVG . Alpha blending cannot be modeled by binary raster operations, apart from “hard” punching, which corresponds to a 1-bit alpha channel.

swell

  1. Raster Operation Codes in MSDN