0

I have a class that looks like:

class Game {
   private IntBuffer GameBuffer = null;

   public Game(int Width, int Height) {
       GameBuffer = ByteBuffer.allocateDirect(Width * Height * 4).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer();
   }


   public BufferedImage getGameBuffer() {
        return this.GameBuffer;  //Need to return my GameBuffer without making a copy.
    }
}

How can I return my GameBuffer such that it is a BufferedImage but not a copy of the GameBuffer.

In other words, when I call:

Canvas.draw(GameInstance.getGameBuffer()); //Uses Graphics g.drawImage(...);

It would draw on my GameBuffer, not a copy. How can I achieve this? I need to use the Int/Byte-Buffer because I need it for my JNI functions.

4

0 に答える 0