public class PNGDecoder extends Object
Modifier and Type | Class and Description |
---|---|
static class |
PNGDecoder.Format |
Constructor and Description |
---|
PNGDecoder(InputStream input) |
Modifier and Type | Method and Description |
---|---|
PNGDecoder.Format |
decideTextureFormat(PNGDecoder.Format fmt)
Computes 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 |
getHeight() |
int |
getWidth() |
boolean |
hasAlpha()
Checks if the image has transparency information either from
an alpha channel or from a tRNS chunk.
|
boolean |
hasAlphaChannel()
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.
|
public PNGDecoder(InputStream input) throws IOException
IOException
public int getHeight()
public int getWidth()
public boolean hasAlphaChannel()
hasAlpha()
public boolean hasAlpha()
hasAlphaChannel()
,
overwriteTRNS(byte, byte, byte)
public boolean isRGB()
public void overwriteTRNS(byte r, byte g, byte b)
This can only be invoked when the image has no alpha channel.
Calling this method causes hasAlpha()
to return true.
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 transparentUnsupportedOperationException
- if the tRNS chunk data can't be sethasAlphaChannel()
public PNGDecoder.Format decideTextureFormat(PNGDecoder.Format fmt)
fmt
- the desired formatUnsupportedOperationException
- if this PNG file can't be decodedpublic void decode(ByteBuffer buffer, int stride, PNGDecoder.Format fmt) throws IOException
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.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 formatpublic void decodeFlipped(ByteBuffer buffer, int stride, PNGDecoder.Format fmt) throws IOException
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.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 formatCopyright © 2016 Laboratoire COGIT, IGN. All rights reserved.