Slick Forums

Discuss the Slick 2D Library
It is currently Sun Oct 20, 2019 9:10 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Oct 09, 2011 9:58 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
The current implementation of image filtering has some fallbacks and problems...

Empty image bug
Code:
image = new Image(x,y);
image.setFilter(Image.FILTER_NEAREST);

=> throws a RuntimeException
setFilter tries to load an image based on ref, but for empty images
ref is just the toString() of the Image object so the ResourceLoader fails


Loss of modifications through getGraphics
Code:
myImg = new Image("img.png");
myImg.getGraphics().drawOval(0, 0, 25, 25);
myImg.getGraphics().flush();
myImg.setFilter(Image.FILTER_NEAREST);

=> the image will revert back to the img.png file. any getGraphics modifications will be lost


Other problems/inconsistencies
The getFilter method won't always return the actual filtering of the image. For example:
Code:
img = new Image("blah.png", false, Image.FILTER_NEAREST);

img.getSubImage(0, 0, 25, 25).getFilter()
=> returns FILTER_LINEAR

img.setTexture(myTex)
=> myTex might still be LINEAR even though img.getFilter() returns NEAREST


And this one is more of an annoyance than a bug:
Code:
setFilter(Image.FILTER_NEAREST);
getFilter() == Image.FILTER_NEAREST
=> returns false

//currently users need to do this...
int realFilter = getFilter()==SGL.GL_LINEAR ? Image.FILTER_LINEAR : Image.FILTER_NEAREST;


Top
 Profile  
 
PostPosted: Sat May 12, 2012 9:28 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
This was posted when I was using an outdated version of Slick.

Resolved, in dev branch.


Top
 Profile  
 
PostPosted: Tue Sep 11, 2012 12:32 pm 
Offline

Joined: Tue Sep 11, 2012 12:08 pm
Posts: 1
For those ( like me ) who are still working with the old release, i found a good way to have a pixelated look to your images by using ImageBuffer instead :

Code:
Image tmp=new ImageBuffer(8, 56).getImage(Image.FILTER_NEAREST);
Graphics canvas=tmp.getGraphics();
canvas.drawImage(this.mlifecontainer, 0.0f, 0.0f);
...
return tmp; // => tmp will have the pixelated look as we want! :)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 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