1 package vrml.external.field;
5 import java.math.BigInteger;
11 public void setValue(
int width,
int height,
int components, byte[] pixels)
throws IllegalArgumentException {
19 if (pixels.length != (width*height*components)) {
20 throw new IllegalArgumentException();
23 if ((components < 1) || (components > 4)) {
24 throw new IllegalArgumentException();
28 xx =
new byte[components+1];
31 val =
new String(
"" + width +
" " + height +
" " + components);
33 if (pixels== null) { pixcount = 0;}
else {pixcount=pixels.length;}
35 if (components == 1) {
36 for (count = 0; count < pixcount; count++) {
37 xx[1] = pixels[count];
38 newval =
new BigInteger(xx);
40 val = val.concat(
" 0x" + newval.toString(16));
43 if (components == 2) {
44 for (count = 0; count < pixcount; count+=2) {
45 xx[1] = pixels[count]; xx[2] = pixels[count+1];
46 newval =
new BigInteger(xx);
48 val = val.concat(
" 0x" + newval.toString(16));
52 if (components == 3) {
53 for (count = 0; count < pixcount; count+=3) {
54 xx[1] = pixels[count]; xx[2] = pixels[count+1]; xx[3]=pixels[count+2];
55 newval =
new BigInteger(xx);
57 val = val.concat(
" 0x" + newval.toString(16));
60 if (components == 4) {
61 for (count = 0; count < pixcount; count+=4) {
62 xx[1] = pixels[count]; xx[2] = pixels[count+1]; xx[3]=pixels[count+2]; xx[4]=pixels[count+3];
63 newval =
new BigInteger(xx);
65 val = val.concat(
" 0x" + newval.toString(16));
71 Browser.newSendEvent (
this, val.length() +
":" + val +
" ");