Slick Forums

Discuss the Slick 2D Library
It is currently Sat Jan 18, 2020 12:06 am

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sat Jan 12, 2013 10:00 pm 

Joined: Wed Dec 09, 2009 6:56 pm
Posts: 135
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");

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group