Class TileUtils
java.lang.Object
VASSAL.tools.image.tilecache.TileUtils
A class for reading and writing image tiles.
The VASSAL tile format consists of the 18-byte header, followed by gzipped
4-bpp image data. The header is the signature 'VASSAL' (6 bytes), the tile
width (4 bytes), the tile height (4 bytes), and the image type (4 bytes).
- Since:
- 3.2.0
- Author:
- Joel Uckelman
-
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImage
Reads an image tile file.static BufferedImage
read
(InputStream in) Reads an image tile.static BufferedImage
Reads an image tile file.static Dimension
Reads the dimensions of the tile in an image tile file.static Dimension
size
(InputStream in) Reads the dimensions of the tile from a stream.static Dimension
Reads the dimensions of the tile in an image tile file.static int
tileCount
(int iw, int ih, int tw, int th) Calculates the number of tiles needed to cover an image, summed over all sizes from 1:1 to the vanishing point.static int
Calculates the number of tiles needed to cover an image, summed over all sizes from 1:1 to the vanishing point.static int
tileCountAtScale
(int iw, int ih, int tw, int th, int div) Calculates the number of tiles needed to cover an image at a given scale.static int
tileCountAtScale
(Dimension i, Dimension t, int div) Calculates the number of tiles needed to cover an image at a given scale.static String
Gets the name of a tile file.static void
write
(BufferedImage tile, File dst) Write a tile image to a tile file.static void
write
(BufferedImage tile, OutputStream out) Write a tile image to a stream.static void
write
(BufferedImage tile, String dst) Write a tile image to a tile file.
-
Method Details
-
read
Reads an image tile file.- Parameters:
src
- the path of the tile file- Returns:
- the tile image
- Throws:
ImageIOException
- if the read failsTileNotFoundException
- if the file isn't found
-
read
Reads an image tile file.- Parameters:
src
- the path of the tile file- Returns:
- the tile image
- Throws:
ImageIOException
- if the read failsTileNotFoundException
- if the file isn't found
-
read
Reads an image tile.- Parameters:
in
- a stream containing the tile data- Returns:
- the tile image
- Throws:
IOException
- if the read fails
-
size
Reads the dimensions of the tile in an image tile file.- Parameters:
src
- the path of the tile file- Returns:
- the dimensions
- Throws:
ImageIOException
- if the read failsTileNotFoundException
- if the file isn't found
-
size
Reads the dimensions of the tile in an image tile file.- Parameters:
src
- the path of the tile file- Returns:
- the dimensions
- Throws:
ImageIOException
- if the read failsTileNotFoundException
- if the file isn't found
-
size
Reads the dimensions of the tile from a stream.- Parameters:
in
- the stream- Returns:
- the dimensions
- Throws:
IOException
- if the read fails
-
write
Write a tile image to a tile file.- Parameters:
tile
- the imagedst
- the tile file- Throws:
ImageIOException
- if the write fails
-
write
Write a tile image to a tile file.- Parameters:
tile
- the imagedst
- the tile file- Throws:
ImageIOException
- if the write fails
-
write
Write a tile image to a stream.- Parameters:
tile
- the imageout
- the stream- Throws:
ImageIOException
- if the write failsIOException
-
tileCount
Calculates the number of tiles needed to cover an image, summed over all sizes from 1:1 to the vanishing point.- Parameters:
i
- the image dimensionst
- the tile dimensions- Returns:
- the number of tiles needed to cover the image
- Throws:
IllegalArgumentException
- if any argument is nonpositive
-
tileCount
public static int tileCount(int iw, int ih, int tw, int th) Calculates the number of tiles needed to cover an image, summed over all sizes from 1:1 to the vanishing point.- Parameters:
iw
- the image widthih
- the image heighttw
- the tile widthth
- the tile height- Returns:
- the number of tiles needed to cover the image
- Throws:
IllegalArgumentException
- if any argument is nonpositive
-
tileCountAtScale
Calculates the number of tiles needed to cover an image at a given scale.- Parameters:
i
- the image dimensionst
- the tile dimensionsdiv
- the scale divisor- Returns:
- the number of tiles needed to cover the image
- Throws:
IllegalArgumentException
- if any argument is nonpositive
-
tileCountAtScale
public static int tileCountAtScale(int iw, int ih, int tw, int th, int div) Calculates the number of tiles needed to cover an image at a given scale.- Parameters:
iw
- the image widthih
- the image heighttw
- the tile widthth
- the tile heightdiv
- the scale divisor- Returns:
- the number of tiles needed to cover the image
- Throws:
IllegalArgumentException
- if any argument is nonpositive
-
tileName
-