Resizing sprite (x2)

Hi,

I want to resize sprite (size x2). Right now, the aim is the quality over the speed.

A linear algorithme give a poor quality result, so I do some search and it seems that HQ2x is a good choise. I made a java version of HQ2x (darn what a big source :o) but it was not mean to be use with alpha value. I did some modification but I still have problems. Another problem is that HQ2x create new colors.

If you have an idea of an algorithme that I can use.

If you’re working with game type sprites rather than images then Scale2X/3X has been pretty good to me in the past:

http://www.cokeandcode.com/scale2x/

Kev

Thanks for the link.

There’s the result with the 4 methods :

Scale 2x is quite nice for me. May be there is a "more complet " method ? I will try to find out.

I think HQ2x is more authentic to the original. Look at the knee caps of Scale2x and HQ2x…HQ2x has a nice gradient which is what the original picture is trying to show (as opposed to the white bit of the tail which is meant to be cartoony) whereas Scale2x has a cartoony knee cap…

Just my 2 pence :slight_smile:

DP

I think that HQ2x is nicer too. But it has several disavantages to Scale2x :

  • HQ2x may not have transparency (interpolation on alpha values)
  • HQ2x generate color that are not in the original sprite (may be a probleme for indexed palette)

HQ2x is under the GNU Lesser General Public License by MaxSt. I really not use to licences… What should i do, if i want to provide the source code ? Only copying the header from the original source code ?

I have a set of sprites which need 2x scaling right now and I’d liek to use these tools but Scale2x doesn’t work witrh alpha values - it makes them black pixels, and I don’t know how to run HQ2x, the random exe I find doesn’t start a GUI or anything.

It surprises me that java2d doesn’t have a good filter for this kind of scaling - Bilinear looks so cloudy and and raw is too pixelated. I downloaded Paint.NET and its scaling only uses raw or bilinear which sux.

May I ask how you used Kev’s Scale2x with alphas, like in the sample image you showed?

Cheers,
Keith

I didn’t encounter any problem with Scale2x and alpha value.

For the image, it is take from my sprite sheet editor with one of my plugins (Here’s the source of the plugin for 2x scaling. It contains HQ2x and Scale2x. Both method need 2 TYPE_INT_ARGB BufferedImage as parameters)

The code is under GPL, but AFAIK, you cannot patent/put under license an algorithm. So if they have released the inner workings of the algorithm, then simply make your own…

DP :slight_smile:

Thanks heaps for that code, I used the scaling methods in a little app that popped a filechooser which allowed me to choose a directory and scale-up a whole directory full of images.

You’re right about the scaling working on translucent images, it seems that it just doesn’t work when you try to save the image as a gif using ImageIO (it works fine when you save it as a PNG).

Thanks again :slight_smile:
Keith