Search code examples
javaswingjframeimage-resizing

Upscale 2D low-res images


I am using the program ImageResizer with the XBR4x algorithm to upscale .gif images from an old 2D game from 32x32 to 48x48.

The exact procedure:

  1. Manually rename all images to .jpeg because the program wont open .gif
  2. Resize the images, they are saved by the program as .bmp
  3. Manually rename the images to .gif again.

The problem:

When looking at the images in Paint they look very good, when drawn in my RGB BufferedImage they suddenly all have a white/grey ~1px border which is not the Background Color, the images are placed directly next to each other. As I have a whole mosaic of those images the white borders are a no go.

Image 32x32: enter image description here

Image 48x48 after upscaling: enter image description here

Ingame screenshot of 4 of those earth images with white borders: enter image description here

The question:

How do those borders originate? And if not possible to answer this, are there more reliable methods of upscaling low resolution game images making them look less pixelated?


Solution

  • I emailed Hawkynt, the developer of the tool and it seems the error is not in the tool but in Microsofts implementation and he fixed it (actually even bigger tools like Multiple Image Resizer .NET have the problem). This is what he said about his program:

    "When you entered width and/or height manually, the image got resized by the chosen algorithm where everything went fine.

    Afterwards I used the resample command from GDI+ which implements a Microsoft version of the bicubic resize algorithm. This implementation is flawed, so it produces one pixel on the left and upper side for images under 300px.

    I fixed it by simply making the resized image one pixel larger than wanted and shifting it to the left and up one pixel, so the white border is no longer visible and the target image hast he expected dimensions."