Package zombie.core.textures
Class PNGDecoder
java.lang.Object
zombie.core.textures.PNGDecoder
A PNGDecoder. The slick PNG decoder is based on this class :)
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionComputes the implemented format conversion for the desired format.void
decode
(ByteBuffer buffer, int stride, PNGDecoder.Format fmt) Decodes the image into the specified buffer.void
decodeFlipped
(ByteBuffer buffer, int stride, PNGDecoder.Format fmt) Decodes the image into the specified buffer.int
int
getWidth()
boolean
hasAlpha()
Checks if the image has transparency information either from an alpha channel or from a tRNS chunk.boolean
Checks if the image has a real alpha channel.boolean
isRGB()
void
overwriteTRNS
(byte r, byte g, byte b) Overwrites the tRNS chunk entry to make a selected color transparent.
-
Field Details
-
maskID
public int maskID -
mask
-
bDoMask
public boolean bDoMask -
readTotal
public long readTotal
-
-
Constructor Details
-
PNGDecoder
- Throws:
IOException
-
-
Method Details
-
getHeight
public int getHeight() -
getWidth
public int getWidth() -
hasAlphaChannel
public boolean hasAlphaChannel()Checks if the image has a real alpha channel. This method does not check for the presence of a tRNS chunk.- Returns:
- true if the image has an alpha channel
- See Also:
-
hasAlpha
public boolean hasAlpha()Checks if the image has transparency information either from an alpha channel or from a tRNS chunk.- Returns:
- true if the image has transparency
- See Also:
-
isRGB
public boolean isRGB() -
overwriteTRNS
public void overwriteTRNS(byte r, byte g, byte b) Overwrites the tRNS chunk entry to make a selected color transparent.This can only be invoked when the image has no alpha channel.
Calling this method causes
hasAlpha()
to return true.- Parameters:
r
- the red component of the color to make transparentg
- the green component of the color to make transparentb
- the blue component of the color to make transparent- Throws:
UnsupportedOperationException
- if the tRNS chunk data can't be set- See Also:
-
decideTextureFormat
Computes the implemented format conversion for the desired format.- Parameters:
fmt
- the desired format- Returns:
- format which best matches the desired format
- Throws:
UnsupportedOperationException
- if this PNG file can't be decoded
-
decode
Decodes the image into the specified buffer. The first line is placed at the current position. After decode the buffer position is at the end of the last line.- Parameters:
buffer
- the bufferstride
- the stride in bytes from start of a line to start of the next line, can be negative.fmt
- the target format into which the image should be decoded.- Throws:
IOException
- if a read or data error occurredIllegalArgumentException
- if the start position of a line falls outside the bufferUnsupportedOperationException
- if the image can't be decoded into the desired format
-
decodeFlipped
Decodes the image into the specified buffer. The last line is placed at the current position. After decode the buffer position is at the end of the first line.- Parameters:
buffer
- the bufferstride
- the stride in bytes from start of a line to start of the next line, must be positive.fmt
- the target format into which the image should be decoded.- Throws:
IOException
- if a read or data error occurredIllegalArgumentException
- if the start position of a line falls outside the bufferUnsupportedOperationException
- if the image can't be decoded into the desired format
-