Slick Forums

Discuss the Slick 2D Library
It is currently Wed Jun 19, 2013 3:16 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Oct 09, 2008 5:12 pm 
Offline

Joined: Fri May 04, 2007 9:05 am
Posts: 36
I believe there's a bug (or design goof) in getTextureData; it appears as if Image.getTextureData() only returns valid data after Image.getGraphics() has been called.

IMO, either getTextureData should initialize properly, or it should be moved to Graphics to force the correct use.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2008 11:54 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Can you post your code, I've just tired the ImageReadTest from the Slick tests here and it works as expected.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 18, 2008 6:55 pm 
Offline

Joined: Fri May 04, 2007 9:05 am
Posts: 36
Sorry, I missed your question (had e-mail notification disabled, silly me :) )

Basically, in paint(Graphics g) I load an image, then call getTexture().getTextureData()... If I don't do image.getGraphics() first, i get an empty buffer (all zeros).

I.e.

m_Image = new Image(filename);
byte data[] = m_Image.getTexture().getTextureData();

returns all zeros, whereas

m_Image = new Image(filename);
Graphics gfx = m_Image.getGraphics();
byte data[] = m_Image.getTexture().getTextureData();

works fine...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 18, 2008 9:35 pm 
Offline

Joined: Fri May 04, 2007 9:05 am
Posts: 36
Hm, you probably shouldn't waste anymore time on this, my code must have some odd twist somewhere :oops:

I still don't know why this happens, but the reason I even started using getTextureData in the first place was that getColor(x,y) returned garbage (i.e. 0,0,0,0) .

Well, I needed similar functionality somewhere else in the code and called getColor there without thinking about it, and suddenly realised that it works just fine. So, I went back and changed the old code back to getColor, and guess what... Works fine too.

I can still reproduce the getGraphics problem in the original part of the code when using getTextureData, but since everything else now suddenly works It's not a high priority - it must be my code that does or did something really fishy.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 0 guests


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