Slick Forums

[BUG] AppGameContainer.setIcons() flips tga images
Page 1 of 1

Author:  zeroone [ Sat Jan 12, 2013 10:00 pm ]
Post subject:  [BUG] AppGameContainer.setIcons() flips tga images

TGA files contain orientation bits at offset byte 17 from the start of the file. Paint programs may arbitrarily set these bits. It is possible that the author of the setIcons() method couldn't figure out why his TGA files were appearing upside-down and consequentially, the author decided to always flip such files in the code. This is unnecessary and it should be removed.

See page 9, field 5.6, bits 5 & 4 for more information on TGA orientation.

   public void setIcons(String[] refs) throws SlickException {
      ByteBuffer[] bufs = new ByteBuffer[refs.length];
      for (int i=0;i<refs.length;i++) {
         LoadableImageData data;
         boolean flip = true;
         if (refs[i].endsWith(".tga")) {
            data = new TGAImageData();
         } else {
            flip = false;
            data = new ImageIOImageData();
         try {
            bufs[i] = data.loadImage(ResourceLoader.getResourceAsStream(refs[i]), flip, false, null);
         } catch (Exception e) {
            throw new SlickException("Failed to set the icon");

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group