Slick Forums

Discuss the Slick 2D Library
It is currently Thu Aug 22, 2019 7:49 am

All times are UTC




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

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 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);
   }


Top
 Profile  
 
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:  
cron
Powered by phpBB® Forum Software © phpBB Group