fied in the
TGA2chip. The Dagger chip, which was
EXPANSION OF 16-BIT 5/6/5 RGB PIXELS TO 8/8/8 RGB
EXPANSION OF 16-BIT 5/5/5 RGB PIXELS TO 8/8/8 RGB
EXPANSION OF 8-BIT 3/3/2 RGB PIXELS TO 8/8/8 RGB
Figure 3Expanding RGB
Pixels
to8/8/8
RG B Fonmt80
intended tc>r lower-cost systems, incl udes neither chrominancc nor luminance adjust LUTs .
T h e other usc for the adjust
LUT
in the TGA2 chipis for color index conversio n . This operation can be performed when the input pixel tc·m11at is 8 bits wide. In this case, the 8 - bit i np u t pixel is used as an index i nto the t:�blc. The resu lting \'a luc is used as the
Ychanncl value in the rest of the pipeline, and the U
and V channels are ignored . Later in the pipel ine, the
color conversion stage is skipped , and the r�channcl value is used directly as the resulting 8-bi r pixel va lue. Color index conversion is an operation that is particularl y desirable when using the Wind ows
NT
operating system . Typically, 8- bir screen pixels are converted to d isplaved col ors by lllt<lllS of a color LUT in the back-end video logic. Under the X ·wi ndow System graphical windowing environment , the map ping between an index and its color can be changed only by the application. Under the Windows NT oper ating system, however, the mappi ngs may cha nge dynamically. Therefore, an application that has stored an i mage as 8-bit index ,·alues will ntcdto
remap those index valuesbd(xe
copving it to the screen . This con version can be done in software, hut it is flster and simpler ro usc the adjust LUT in the TGA2 chip to per form the rcnupping.Scaling and Filtering
I n the next stage in the rendering pipeline, the chip pertorms scaling and tlltering. The Dagger and TGA2 chips support one-d imensional ( 1 - D) scaling and filter ing in hardware . Limiting the chips to 1 -D filteri ng sig nificantly simplifies the chip logic, since no line bufkrs are needtd. Somewhat higher-quality images can be achieved using two-dimensional
( 2 - D )
fi ltering, but the difference is not significant. This d i fterence is fu r ther reduced by the AccuVid eo dithering algorithm that is implemented by the Dagger and TGA2 chips. Two-dimensiona l smoothing tilters can be su pporttd with added software processing, if required.Bresenham-style Scaling Image scaling
in
the Dagger andTGA2
chips uses pixel replication but is not lim ited to integer mu ltiples. Instead, images can be scaled hom anv i ntegral source width toany
integral desti nation width. Scal ing is implemented through an adaptation of the Bresenham line-drawing algorithm . A compl ete description o f this Bresen ham-sryle sca ling algorithm appears in "Bresenham -sryle Scaling"; the tol lowing paragraphs provide an outline of the algo rithm, which is the same scaling algorithm used in the J 300 fam i ly of adapters 3'The B rescnham scaling algorithm works l i ke the B resenham line-drawing algorithm. Suppose we are drawing a line ti-om ( 0, 0) to (
10,
6)
, so that dx = 1 0and
c�v
= 6 . This is a n X- major line; that is, the line islonger i n the X di mension than in the V dimension.
Digit.1l Tcchniol )ou rn<li Vol. 7 No. 4 1 995
The Bresenbam algorithm draws this \'ector b\' in itial
izing an error term and then i ncrementing it c/.\ rimes,
in this example, 10 rimes. Each rime the algorithm i ncrements the term, a pixel is d rawn . The sign of t he error term determines whether to tind the next
pixel position bv stepping to the right ( incrementing
the X positio n ) or b\' steppi ng d iagonall\' ( increment
ing both
X
and }"). The error term is incremented insuch a way
t
hatas
the X position is incremented 10rimes, the Y position is incremented 6 rimes, rhus
d rawing the desired vector.
For Bresenham scali ng, dx rcpresems the width of the source image, and
c/1•
represents the \\'idth of the destination image on the screen . vVhen reducing the size of the sou rce image, dx is greater th:m d)' and the error terms and increments are set u p in rhe same way as the X-major Brescnham line drawing, :ts described in the previous paragraph. One source pixelis
processed each rime the error term is incrcmcmed . When Bresenham 's line algorithm i ndicates a step in the X dimension on I)·, the source pixel is skipped . vVhen the algorithm i ndicates :1 step in both the .\· and the V dimensions, the source pixel is written to the destina tion . As a result,cx:tcrly dx so urce
pixels arc processed , and exactly d1• ofrhem JIT drawn to the screen .Enlarging an im:�gc works in a similar bshion . For cx:1mplc, consider �1 source i mage rbar is nJITO\\'er than
the destination image, that is, dx is less th;m d ) ' This is
cqui,·alent to d rawing a )
:major Brcscnh:tm line in which the error term is incremented d ) ' tin1es :�nd rhe X dimension is incrcmcmcddx
ti mes. The scaling algo rith m draws a sou rce pixel to the desti n;Hion at each step. If the l ine-drawing algorithm i ncrements only in rhc Ydimension, it repeats the cu rrent pixel. If the linedra\\'ing algorithm increments
in
both t he X : llld the Y dimensions, it steps to and d isplavs rhc next source pixe l. Consequent!\', the dx source pixe ls arcrcplicJted
to yield c/J! destination pixels, thus enlarging the image.The Bresenham line-drawing algorithm has t\\'O
nice properties that arc shared by the Brescnham scal ing algorithm. First, it requ i res no divisions to com
pur e the error increments. Second,
it
produces linesthat are as smooth as possible, gi,·en the pixel grid .
ThJt is, tor an X-major line, each of the ch pixels has
a l' posi tion that is the
closest
pixel to the i ntersectionof i rs
X position wirh the real\'ector.
Simi larlv, the B rescnham scaling Jlgorithm selects pixels ti1Jt h:l\'e the most even spacing possible, given the pixel gri d . Just a s l ines c a n h e d rawn ti-om lett to right o r fi·omright to left, images can
be
dra\\'11 in either direction .An image dram1 in one d irection is tht mi rror image of the image drJ\\'n in rhc other direction . J'vlirror i magi ng is sometimes used in telecon krcncing, so that
users can look at themselves rhe way
they
norm:dl\' seethemselves. Similarly, images can be ru rncd upside
down by simply drawing to the d isplay fi·om
bottom
Scaling in the
V dimension is pertcmned simi larly toX-d imension sc:1.li ng. On the TGA2 chip, scaling
is performed i n software instead of in hardware: the
software increments an error term to decide whether
to skip lines ( tor reducing) or repeat lines ( for enlarg
ing). This is accepc1.blc because the CPU has plenty of
spare cycles to pertc>rm the scaling compu tations while
the al gorithm draws the preceding line. The Dagger
chip su pports Y-d imension scaling in hardware to
red uce the number of commands that are needed
to scale an im;1ge .
Smooth ing and Sharpening Fi lters