Package games.stendhal.tools.charas
Class CharasConverter
java.lang.Object
games.stendhal.tools.charas.CharasConverter
Utility to convert images saved from Charas to be suitable for Stendhal. Basically this means making the background color transparent and scaling the image using the scale2x algorithm.
Usage:
- command line mode: "java tools.CharasConverter source.png destination.png"
- graphical mode: start without any parameters to use the file selectors
- Author:
- johnnnny
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
convertImage(String srcFilename, String dstFilename)
Convert a single image file to destination file.protected BufferedImage
getImageWithTransparency(BufferedImage image, int px, int py)
Get a copy of the image with a single color transparent.protected BufferedImage
getScaled2x(BufferedImage srcImage)
Scale an image to double size using the scale2x algorithm.protected BufferedImage
Loads an image.static void
protected void
savePNGImage(String filename, BufferedImage image)
Saves an image as PNG.
-
Constructor Details
-
CharasConverter
public CharasConverter()
-
-
Method Details
-
main
-
convertImage
Convert a single image file to destination file.- Parameters:
srcFilename
- full path to source image filedstFilename
- full path to destination image file- Throws:
IOException
- if loading or saving fails
-
getImageWithTransparency
Get a copy of the image with a single color transparent. The color made to be transparent is specified by pixel.- Parameters:
image
- source imagepx
- X index of the pixel for transparency colorpy
- Y index of the pixel for transparency color- Returns:
- Copy of the image with one color changed to transparent
-
savePNGImage
Saves an image as PNG.- Parameters:
filename
- destination filenameimage
- imagedata- Throws:
IOException
- if writing fails
-
loadImage
Loads an image.- Parameters:
filename
- the name of the file from which the image file- Returns:
- loaded image
- Throws:
IOException
- if reading the file fails
-
getScaled2x
Scale an image to double size using the scale2x algorithm.- Parameters:
srcImage
- source image data- Returns:
- scaled image
-