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 getGraphicsCode:
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/inconsistenciesThe 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;