FreeWRL / FreeX3D 4.3.0
ConstSFImage.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 ConstSFImage extends ConstField {
11 int width;
12 int height;
13 int components;
14 byte[] pixels;
15
16 public ConstSFImage() { }
17
18 public ConstSFImage(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 String toString() {
46 __updateRead();
47 StringBuffer sb = new StringBuffer();
48 sb.append(width).append(' ').append(height).append(' ').append(components);
49 for (int i = 0; i < pixels.length; i+=components) {
50 sb.append(" 0x");
51 for (int j = i; j < i+components; j++)
52 sb.append("0123456789ABCDEF".charAt((pixels[i+j] & 0xf0) >> 4))
53 .append("0123456789ABCDEF".charAt(pixels[i+j] & 0x0f));
54 }
55 return sb.toString();
56 }
57
58 public void __fromPerl(BufferedReader in) throws IOException {
59
60 //System.out.println ("fromPerl, Image");
61 width = Integer.parseInt(in.readLine());
62 height = Integer.parseInt(in.readLine());
63 components = Integer.parseInt(in.readLine());
64 pixels = new byte[height*width*components];
65 //System.out.println ("JavaClass -- fix method to read in pixels");
66 // pixels = String.getBytes(pst);
67
68 }
69
70 public void __toPerl(PrintWriter out) throws IOException {
71 out.print(width+" "+height+" "+components+" "+pixels);
72 //out.println();
73 }
74 //public void setOffset(String offs) { this.offset = offs; } //JAS2
75 //public String getOffset() { return this.offset; } //JAS2
76}