libtiled-java should use BufferedImage #369

Open
devnewton opened this Issue Feb 20, 2013 · 3 comments

Comments

Projects
None yet
2 participants
Contributor

devnewton commented Feb 20, 2013

libtiled-java use Image instead of BufferedImage because of some old java trick like:

                     // Deriving a scaled instance, even if it has the same
                        // size, somehow makes drawing of the tiles a lot
                        // faster on various systems (seen on Linux, Windows
                        // and MacOS X).
                        img = img.getScaledInstance(
                                img.getWidth(null), img.getHeight(null),
                                Image.SCALE_FAST);

It should not be a performance improvement today: http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html

Java image manipulation is easier and faster with BufferedImage, maybe it should be used as preferred image type?

Owner

bjorn commented Feb 20, 2013

I welcome your patch, as well as your performance tests. :-)

Contributor

devnewton commented Feb 24, 2013

I realized that my issue description is wrong.

My final goal is to get an opengl texture, not to get the best java2d drawing performance.

Using libtiled-java, a tile image will be pass through several conversions:

  • loaded into a BufferedImage.
  • scaled to an Image.
  • converted into a BufferedImage.
  • put into a ByteBuffer.
  • loaded to GPU with glTexture*.

I dont know how to improve this process...

Owner

bjorn commented Feb 24, 2013

@devnewton Well at least in your case you would want to avoid converting to Image and then back into BufferedImage. You should be able to modify libtiled-java to take out the conversion to Image quite easily, right? I don't know whether you can get rid of other steps (I haven't used OpenGL in Java).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment