Bartlomiej Lewandowski
Bartlomiej Lewandowski

Reputation: 11170

Resize Buffered Image - resize by multiple of 2

I'm looking to resize a small pixel image - 16x16 to 512x512. Is there any library that already does this?

I have looked at imgscalr and Thumbnailator but they produce a smooth output which I am trying to avoid.

To illustrate:

a b
c d

a a b b
a a b b
c c d d
c c d d

Upvotes: 0

Views: 94

Answers (1)

Apace
Apace

Reputation: 36

You don't need an external library for this.

This should do the trick:

BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
Image scaledImage = img.getScaledInstance(512, 512, BufferedImage.SCALE_DEFAULT);

Upvotes: 2

Related Questions