Java Slick scale Image without anti-aliasing
Asked Answered
S

1

6

In the Slick library (based off of LWJGL), you can scale images after you load them with getScaledCopy, but it will apply anti-aliasing. I want the edges to stay rough; I'm making pixel art. How can I do this?

Stereogram answered 30/5, 2012 at 0:52 Comment(2)
Wild guess based on the javadocs: try using setFilter() to set the image filter to FILTER_NEAREST before scaling the image.Arabic
This worked, thanks! Post this answer and I'll accept it ;)Stereogram
A
7

Based on the comments:

The documentation implies that the filter property of Images controls how images are scaled. To scale an image without smoothing, use the nearest neighbour filter:

Image original = …;
original.setFilter(Image.FILTER_NEAREST);
Image scaled = original.getScaledCopy();
Arabic answered 31/5, 2012 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.