# [java] Rendering a static 2D Image over a Java 3D Screen

## Recommended Posts

Hello. I want to render a 2d logo over a 3d object screen. I would like to avoid texture mapping a plain if I can. I saw the sprite3D class I have tried using it. My problem I guess is with loading an image. I have a gif,jpg, and png versino of my image. I have tried loading all of them however none will load. Here is my code
Image img;
CompositingMode cm = new CompositingMode();
cm.setBlending(CompositingMode.ALPHA);

Appearance appearance = new Appearance();
appearance.setCompositingMode(cm);

sprite3D = new Sprite3D(false,new Image2D(Image2D.RGB,img),appearance);

The error I get is, Exception in thread "main" java.lang.ClassCastException: [I at sun.awt.image.ByteInterleavedRaster.getDataElements(Unknown Source) at javax.microedition.m3g.Image2D.<init>(Image2D.java:216) at mot.psm.renderEnv.RenderEnvM3G.initWindow(RenderEnvM3G.java:319) at mot.psm.renderEnv.RenderEnvM3G.<init>(RenderEnvM3G.java:129) at mot.psm.framework.m3g.Avatar.main(Avatar.java:1703) Any ideas?

##### Share on other sites
By the way, my loadimage code looks like

	private Image loadImage(String s) {		InputStream is;		Image img = null;		try {			String fs = s;			is = new FileInputStream(new File(fs));			img = ImageIO.read(is);		}		catch (FileNotFoundException e) {			e.printStackTrace();		}		catch (IOException e) {			e.printStackTrace();		}		return img;	}

##### Share on other sites
Son of Cain    480
What are you casting?

If not you, then some method you're calling is expecting a specific implemention of a super class, and receiving the other - and when it performs the casting in its body, it throws the exception.

Son Of Cain