Slick Forums
http://slick.ninjacave.com/forum/

[BUG] AppGameContainer.setIcons() flips tga images
http://slick.ninjacave.com/forum/viewtopic.php?f=1&t=6085
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 http://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf page 9, field 5.6, bits 5 & 4 for more information on TGA orientation.

Code:
   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) {
            Log.error(e);
            throw new SlickException("Failed to set the icon");
         }
      }
      
      Display.setIcon(bufs);
   }

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/