FreeWRL / FreeX3D 4.3.0
SFImage.java
1//AUTOMATICALLY GENERATED BY genfields.pl.
2//DO NOT EDIT!!!!
3
4package vrml.field;
5import vrml.*;
6import java.io.BufferedReader;
7import java.io.PrintWriter;
8import java.io.IOException;
9
10public class SFImage extends Field {
11 int width;
12 int height;
13 int components;
14 byte[] pixels;
15
16 public SFImage() { }
17
18 public SFImage(int width, int height, int components, byte[] pixels) {
19 this.width = width;
20 this.height = height;
21 this.components = components;
22 this.pixels = pixels;
23 }
24
25 public int getWidth() {
26 __updateRead();
27 return width;
28 }
29
30 public int getHeight() {
31 __updateRead();
32 return height;
33 }
34
35 public int getComponents() {
36 __updateRead();
37 return components;
38 }
39
40 public byte[] getPixels() {
41 __updateRead();
42 return pixels;
43 }
44
45 public void setValue(int width, int height, int components, byte[] pixels) {
46 this.width = width;
47 this.height = height;
48 this.components = components;
49 this.pixels = pixels;
50 __updateWrite();
51 }
52
53
54 public void setValue(ConstSFImage sfImage) {
55 sfImage.__updateRead();
56 width = sfImage.width;
57 height = sfImage.height;
58 components = sfImage.components;
59 pixels = sfImage.pixels;
60 __updateWrite();
61 }
62
63 public void setValue(SFImage sfImage) {
64 sfImage.__updateRead();
65 width = sfImage.width;
66 height = sfImage.height;
67 components = sfImage.components;
68 pixels = sfImage.pixels;
69 __updateWrite();
70 }
71
72
73 public String toString() {
74 __updateRead();
75 StringBuffer sb = new StringBuffer();
76 sb.append(width).append(' ').append(height).append(' ').append(components);
77 for (int i = 0; i < pixels.length; i+=components) {
78 sb.append(" 0x");
79 for (int j = i; j < i+components; j++)
80 sb.append("0123456789ABCDEF".charAt((pixels[i+j] & 0xf0) >> 4))
81 .append("0123456789ABCDEF".charAt(pixels[i+j] & 0x0f));
82 }
83 return sb.toString();
84 }
85
86 public void __fromPerl(BufferedReader in) throws IOException {
87
88 //System.out.println ("fromPerl, Image");
89 width = Integer.parseInt(in.readLine());
90 height = Integer.parseInt(in.readLine());
91 components = Integer.parseInt(in.readLine());
92 pixels = new byte[height*width*components];
93 //System.out.println ("JavaClass -- fix method to read in pixels");
94 // pixels = String.getBytes(pst);
95
96 }
97
98 public void __toPerl(PrintWriter out) throws IOException {
99 out.print(width+" "+height+" "+components+" "+pixels);
100 //out.println();
101 }
102 //public void setOffset(String offs) { this.offset = offs; } //JAS2
103 //public String getOffset() { return this.offset; } //JAS2
104}