11 package com.generalrobotix.ui.view.vsensor;
13 import java.awt.GraphicsConfiguration;
14 import java.awt.image.BufferedImage;
16 import javax.media.j3d.DepthComponentFloat;
17 import javax.media.j3d.GraphicsContext3D;
18 import javax.media.j3d.Raster;
25 @SuppressWarnings(
"serial")
26 public class
Canvas3DI extends javax.media.j3d.Canvas3D {
32 protected GraphicsContext3D
gc_;
37 boolean finished_ =
false;
41 protected DepthComponentFloat
depth_;
56 public Canvas3DI(GraphicsConfiguration gc,
boolean offscr,
57 Raster raster,
int width,
int height,
int rasterType) {
59 gc_ = getGraphicsContext3D();
63 rasterType_ = rasterType;
65 if (rasterType_ == Raster.RASTER_DEPTH
66 || rasterType_ == Raster.RASTER_COLOR_DEPTH) {
67 depthBuffer_ =
new float[width_ * height_];
69 if (rasterType_ == Raster.RASTER_COLOR
70 || rasterType_ == Raster.RASTER_COLOR_DEPTH) {
71 colorBuffer_ =
new int[width_ * height_];
73 setSize(width, height);
85 byte[] monoBuffer =
new byte[width_*height_];
86 for (
int i=0;
i<width_;
i++) {
87 for (
int j=0;
j<height_;
j++) {
88 monoBuffer[
i+
j*width_] =
89 (byte)(0.587*(0xff&(colorBuffer_[
i+
j*width_]>>8))
90 +0.114*(0xff&(colorBuffer_[
i+
j*width_]))
91 +0.299*(0xff&(colorBuffer_[
i+
j*width_]>>16)));
119 gc_.readRaster(raster_);
122 if (rasterType_ == Raster.RASTER_COLOR ||
123 rasterType_ == Raster.RASTER_COLOR_DEPTH){
124 color_ = raster_.getImage().getImage();
125 color_.getRGB(0, 0, width_, height_, colorBuffer_, 0, width_);
126 if (colorBuffer_.length != width_*height_){
127 System.out.println(
"invalid length of color buffer = "+colorBuffer_.length);
132 if (rasterType_ == Raster.RASTER_DEPTH ||
133 rasterType_ == Raster.RASTER_COLOR_DEPTH){
134 depth_ = (DepthComponentFloat)raster_.getDepthComponent();
135 depth_.getDepthData(depthBuffer_);
136 if (depthBuffer_.length != width_*height_){
137 System.out.println(
"invalid length of depth buffer = "+depthBuffer_.length);
DepthComponentFloat depth_
png_infop png_uint_32 * width
Canvas3DI(GraphicsConfiguration gc)
png_infop png_uint_32 png_uint_32 * height
def j(str, encoding="cp932")
Canvas3DI(GraphicsConfiguration gc, boolean offscr, Raster raster, int width, int height, int rasterType)