Java Reference
In-Depth Information
alpha[i] = 255;
red[i] = (short) (255-i);
green[i] = (short) (255-i);
blue[i] = (short) (255-i);
}
short[][] invert = { red, green, blue, alpha };
BufferedImageOp invertOp = new LookupOp(new ShortLookupT-
able(0, invert), null);
Thisexamplefirstcreatesaseparatearrayforinvertingeachcomponentexceptforal-
pha—each
alpha
arrayentryisassigned
255
tospecifyopaque.Next,thesearraysare
passedtoatwo-dimensional
invert
array—the
alpha
arraymustbepassedlast.Fin-
ally,analternate
ShortLookupTable
constructoriscalledwiththetwo-dimensional
invert
arrayanda
0
offsetasitsarguments.Theresultingtablealongwith
null
(that
indicates no rendering hints) are passed to
LookupOp
's constructor.
Figure 7-32
shows this image operator's results.