I want to load an image onto a texture making use of a bufferedImage on a Graphics2d. Is this possible?

So far I've worked with a GraphicsImage, but I can't seem to put an BufferedImage on it.

I need this for my game. It's a drawing game. I got the drawing part working, but bow I want to load a image in the game fot the player to colour it.

any idea's?

Take a look at the ImageGraphics class…

@llama: obviously he already did :slight_smile:

You can also draw a BufferedImage (any image, in fact) on it (Graphics.drawImage).

Well I tried that but it doesn't show my image.  :?

This is my code: Is this the right way to handle it?

String imgfile;
        imgfile = fileroot + "data/Kleurplaten/kleurplaat1.png";
        BufferedImage img = null;
        try {
           img = File(imgfile));
        } catch (IOException e){
        scales[3] = 50;
        rop = new RescaleOp(scales, offsets, null);
        str = new BasicStroke(5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
        graphics = ImageGraphics.createInstance( this.width, this.height, 1 );
        graphics.translate( ( this.width - width ) * 0.5f, ( this.height - height ) * 0.5f );
        graphics.drawImage(img, rop, 0, 0);
        ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
       texture = new Texture();
        texture.setFilter( Texture.FM_LINEAR );
        texture.setWrap( Texture.WM_WRAP_S_WRAP_T );
        texture.setImage( graphics.getImage() );

        ts.setTexture( texture );

Looks ok, but it's fairly complicated. Maybe the scale/translation draws it off screen… try with a simply example first.

I'm so stupid sometimes,

The image I loaded was to big for my graphics object so all that was shown was te top rights corner (It's displayed upside down) which happened to be white. after rescaling the image it worked fine!