Package VASSAL.tools.image.tilecache
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 BufferedImageReads an image tile file.static BufferedImageread(InputStream in) Reads an image tile.static BufferedImageReads an image tile file.static DimensionReads the dimensions of the tile in an image tile file.static Dimensionsize(InputStream in) Reads the dimensions of the tile from a stream.static DimensionReads the dimensions of the tile in an image tile file.static inttileCount(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 intCalculates the number of tiles needed to cover an image, summed over all sizes from 1:1 to the vanishing point.static inttileCountAtScale(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 inttileCountAtScale(Dimension i, Dimension t, int div) Calculates the number of tiles needed to cover an image at a given scale.static StringGets the name of a tile file.static voidwrite(BufferedImage tile, File dst) Write a tile image to a tile file.static voidwrite(BufferedImage tile, OutputStream out) Write a tile image to a stream.static voidwrite(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
Gets the name of a tile file.- Parameters:
iname- the image nametileX- the X coordinate of the tiletileY- the Y coordinate of the tilediv- the scale divisor- Returns:
- the name of the tile file
-