本文整理汇总了Java中javax.media.j3d.ImageComponent2D类的典型用法代码示例。如果您正苦于以下问题:Java ImageComponent2D类的具体用法?Java ImageComponent2D怎么用?Java ImageComponent2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageComponent2D类属于javax.media.j3d包,在下文中一共展示了ImageComponent2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doRender
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
/**
* render a Image from canvas
*
* @param width
* Image width
* @param height
* Image height
* @return the image
*/
public BufferedImage doRender(BufferedImage image)
{
ImageComponent2D buffer = new ImageComponent2D(
ImageComponent.FORMAT_RGB, image);
// buffer.setYUp(true);
if (getOffScreenBuffer() == null)
{
setOffScreenBuffer(buffer);
renderOffScreenBuffer();
waitForOffScreenRendering();
}
return getOffScreenBuffer().getImage();
}
示例2: getScreenshot
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
/**
* Baut einen Screenshot
* @return null wenn nix geladen, sonst Screenshot
* Bsp: ImageIO.write(worldViewer.getScreenshot(), "png", File.createTempFile("screenshot", ".png"));
*/
public BufferedImage getScreenshot() {
/*
* Das hier ist sehr buerokratisch, aber leider hab ich keinen
* einfacheren Weg gefunden. Was man mit Google findet sind i.d.R.
* Beispiele, die java.awt.Robot.createScreenCapture() verwenden -- was
* aber einen "echten Screenshot" macht, d.h. wenn einer ein anderes
* Fenster ueber den ctSim geschoben hat, wird eben das abgelichtet. Die
* Alternative, auf dem Canvas3D oder auf diesem Objekt paint(...)
* aufzurufen, funktioniert nicht (ergibt immer einfarbig schwarze
* Screenshots -- vermutlich ist Canvas3D eben doch keine ganz so
* normale Swing-Komponente).
*/
Screen3D onScr = onScreenCanvas.getScreen3D();
Screen3D offScr = offScreenCanvas.getScreen3D();
offScreenCanvas.setOffScreenBuffer(new ImageComponent2D(ImageComponent2D.FORMAT_RGB, onScr.getSize().width, onScr.getSize().height));
offScr.setSize(onScr.getSize());
offScr.setPhysicalScreenHeight(onScr.getPhysicalScreenHeight());
offScr.setPhysicalScreenWidth(onScr.getPhysicalScreenWidth());
offScreenCanvas.renderOffScreenBuffer();
offScreenCanvas.waitForOffScreenRendering();
return offScreenCanvas.getOffScreenBuffer().getImage();
}
示例3: doRender
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
private BufferedImage doRender(int width, int height) {
BufferedImage bImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
ImageComponent2D buffer = new ImageComponent2D(
ImageComponent.FORMAT_RGB, bImage);
//buffer.setYUp(true);
setOffScreenBuffer(buffer);
renderOffScreenBuffer();
waitForOffScreenRendering();
bImage = getOffScreenBuffer().getImage();
return bImage;
}
示例4: getColoredImageTexture
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
/**
* Returns a texture image of one pixel of the given <code>color</code>.
*/
private Texture getColoredImageTexture(Color color)
{
BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(color);
g.drawLine(0, 0, 0, 0);
g.dispose();
Texture texture = new TextureLoader(image).getTexture();
texture.setCapability(Texture.ALLOW_IMAGE_READ);
texture.setCapability(Texture.ALLOW_FORMAT_READ);
texture.getImage(0).setCapability(ImageComponent2D.ALLOW_IMAGE_READ);
texture.getImage(0).setCapability(ImageComponent2D.ALLOW_FORMAT_READ);
return texture;
}
示例5: getImageBits
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
/**
* Returns the pixels of the given <code>image</code>.
*/
private int[] getImageBits()
{
int[] imageBits = null;
if (this.imageBits != null)
{
imageBits = this.imageBits.get();
}
if (imageBits == null)
{
BufferedImage image = ((ImageComponent2D) this.texture.getImage(0)).getImage();
if (image.getType() != BufferedImage.TYPE_INT_RGB && image.getType() != BufferedImage.TYPE_INT_ARGB)
{
// Transform as TYPE_INT_ARGB or TYPE_INT_RGB (much faster than calling image.getRGB())
BufferedImage tmp = new BufferedImage(image.getWidth(), image.getHeight(),
this.texture.getFormat() == Texture.RGBA ? BufferedImage.TYPE_INT_ARGB
: BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) tmp.getGraphics();
g.drawImage(image, null, 0, 0);
g.dispose();
image = tmp;
}
imageBits = (int[]) image.getRaster().getDataElements(0, 0, image.getWidth(), image.getHeight(), null);
this.transparent = image.getTransparency() != BufferedImage.OPAQUE;
if (this.transparent)
{
this.transparent = containsTransparentPixels(imageBits);
}
this.imageBits = new WeakReference<int[]>(imageBits);
}
return imageBits;
}
示例6: getOffScreenCanvas3D
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
/**
* Returns a new off screen <code>canva3D</code> at the given size.
* @throws IllegalRenderingStateException if the canvas 3D couldn't be created.
* To avoid this exception, call {@link #isOffScreenImageSupported() isOffScreenImageSupported()} first.
*/
public Canvas3D getOffScreenCanvas3D(int width, int height)
{
Canvas3D offScreenCanvas = getCanvas3D(null, true, null);
// Configure canvas 3D for offscreen
Screen3D screen3D = offScreenCanvas.getScreen3D();
screen3D.setSize(width, height);
screen3D.setPhysicalScreenWidth(2f);
screen3D.setPhysicalScreenHeight(2f / width * height);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
ImageComponent2D imageComponent2D = new ImageComponent2D(ImageComponent2D.FORMAT_RGB, image);
imageComponent2D.setCapability(ImageComponent2D.ALLOW_IMAGE_READ);
offScreenCanvas.setOffScreenBuffer(imageComponent2D);
return offScreenCanvas;
}
示例7: textureUpdated
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
public void textureUpdated(Texture texture)
{
floorTextureImagesCache.put(floorRotatedTextureKey,
((ImageComponent2D) texture.getImage(0)).getImage());
if (!waitForTexture)
{
repaint();
}
}
示例8: OffScreenCanvas3D
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
public OffScreenCanvas3D(GraphicsConfiguration gconfig) {
super(gconfig, true);
ImageComponent2D buffer = new ImageComponent2D(ImageComponent.FORMAT_RGB, visionImage);
buffer.setCapability(ImageComponent.ALLOW_IMAGE_READ);
setOffScreenBuffer(buffer);
rendering = false;
}
示例9: writeJPEGFile
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
/** Writes the current view in a <code>Canvas3D</code> object to an JPG file */
public static void writeJPEGFile(String fName, Canvas3D canvas){
GraphicsContext3D ctx = canvas.getGraphicsContext3D();
// The raster components need all be set!
Raster ras = new Raster(
new Point3f(-1.0f,-1.0f,-1.0f),
Raster.RASTER_COLOR,
0,0,
canvas.getWidth(),canvas.getHeight(),
new ImageComponent2D( ImageComponent.FORMAT_RGB, new BufferedImage(canvas.getWidth(), canvas.getHeight(), BufferedImage.TYPE_INT_RGB)),
null);
ctx.readRaster(ras);
// Now strip out the image info
BufferedImage img = ras.getImage().getImage();
// write that to disk....
try {
FileOutputStream out = new FileOutputStream(fName);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(img);
param.setQuality(0.95f,false); // 75% quality for the JPEG
encoder.setJPEGEncodeParam(param);
encoder.encode(img);
out.close();
} catch ( IOException e ) {
e.printStackTrace();
}
}
示例10: J3dNyARRaster_RGB
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
public J3dNyARRaster_RGB(NyARParam i_cparam,VideoFormat i_format) throws NyARRuntimeException
{
super(i_format);
//bufferdimageの種類を決める
if(this.getBufferType()!=NyARBufferType.BYTE1D_B8G8R8_24){
throw new NyARRuntimeException();
}
//RGBのラスタを作る。
this.bufferd_image = new BufferedImage(this._size.w, this._size.h, BufferedImage.TYPE_3BYTE_BGR);
i2d_buf = ((DataBufferByte) bufferd_image.getRaster().getDataBuffer()).getData();
this.imc2d = new ImageComponent2D(ImageComponent2D.FORMAT_RGB, this.bufferd_image, true, true);
imc2d.setCapability(ImageComponent.ALLOW_IMAGE_WRITE);
}
示例11: captureImage
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
@Override
public void captureImage( int maxSize, RenderingViewer.ImageCapture capture )
{
if ( mCanvas .isOffScreen() )
{
BufferedImage bImage = new BufferedImage( maxSize, maxSize * 4 / 5, BufferedImage.TYPE_INT_ARGB );
ImageComponent2D buffer = new ImageComponent2D( ImageComponent.FORMAT_RGB, bImage );
Screen3D sOff = mCanvas .getScreen3D();
Dimension dim = new Dimension( 1024, 768 );
sOff .setSize( dim );
sOff .setPhysicalScreenWidth( 1024 );
sOff .setPhysicalScreenHeight( 768 );
mCanvas .setOffScreenLocation( 0, 0 );
mCanvas .setOffScreenBuffer( buffer );
mCanvas .renderOffScreenBuffer();
mCanvas .waitForOffScreenRendering();
capture .captureImage( mCanvas .getOffScreenBuffer() .getImage() );
}
else
{
mCanvas .maxImageSize = maxSize;
mCanvas .m_imageHandler = capture;
mCanvas .repaint();
}
//mCanvas .m_imageHandler = null; mCanvas .maxImageSize = -1; // will be done by canvas, on another thread
}
示例12: render
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
public BufferedImage render(int width, int height) {
BufferedImage image =
new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
ImageComponent2D buffer =
new ImageComponent2D(ImageComponent.FORMAT_RGBA, image);
this.setOffScreenBuffer(buffer);
this.renderOffScreenBuffer();
this.waitForOffScreenRendering();
return this.getOffScreenBuffer().getImage();
}
示例13: OffScreenCanvas3D
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
public OffScreenCanvas3D(GraphicsConfiguration gconfig) {
super(gconfig, true);
ImageComponent2D buffer = new ImageComponent2D(ImageComponent.FORMAT_RGB, visionImage);
buffer.setCapability(ImageComponent.ALLOW_IMAGE_READ);
setOffScreenBuffer(buffer);
// rendering = false;
}
示例14: updateData
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
public void updateData(ImageComponent2D imageComponent,
int x,
int y,
int width,
int height) {
// Do nothing for now.
}
示例15: initTexture
import javax.media.j3d.ImageComponent2D; //导入依赖的package包/类
private void initTexture()
{
//Debug.trace();
textureImage =
new BufferedImage(textureWidth,
textureHeight,
BufferedImage.TYPE_INT_RGB);
textureImageComponent =
new ImageComponent2D(ImageComponent2D.FORMAT_RGB,
textureImage);
textureImageComponent.setCapability(ImageComponent2D.ALLOW_IMAGE_WRITE);
textureImpl = new Texture2D(Texture2D.BASE_LEVEL,
Texture2D.RGB,
textureWidth,
textureHeight);
textureImpl.setImage(0, textureImageComponent);
// Handle repeatS and repeatT fields
textureImpl.setBoundaryModeS(vfRepeatS ? Texture2D.WRAP : Texture2D.CLAMP);
textureImpl.setBoundaryModeT(vfRepeatT ? Texture2D.WRAP : Texture2D.CLAMP);
textureArray = new Texture[] { textureImpl };
textureAlphaArray = new boolean[] { false };
TextureAttributes attr = new TextureAttributes();
textureAttributeArray = new TextureAttributes[] { attr };
firstFrame = true;
}