package org.jboss.media.format.image.iio;
import javax.imageio.metadata.IIOMetadata;
public class PNGMediaHeader extends IIOMediaHeader
{
private static final long serialVersionUID = 0L;
private static final String PNG_METADATA_FORMAT_NAME =
"javax_imageio_png_1.0";
private static final String[] FIELD_NAMES =
{
"width",
"height",
"bitDepth",
"colorType",
"compressionMethod",
"filterMethod",
"interlaceMethod" };
private static final String IHDR = "IHDR";
public PNGMediaHeader(IIOMetadata imageMetadata)
{
super(imageMetadata, PNG_METADATA_FORMAT_NAME);
}
public String[] getFieldNames()
{
return FIELD_NAMES;
}
public Object getField(String fieldname)
{
Object field = null;
if (fieldname.equals("width"))
{
field = new Integer(getWidth());
}
if (fieldname.equals("height"))
{
field = new Integer(getHeight());
}
if (fieldname.equals("bitDepth"))
{
field = getBitDepth();
}
if (fieldname.equals("colorType"))
{
field = getColorType();
}
if (fieldname.equals("compressionMethod"))
{
field = getCompressionMethod();
}
if (fieldname.equals("filterMethod"))
{
field = getFilterMethod();
}
if (fieldname.equals("interlaceMethod"))
{
field = getInterlaceMethod();
}
return field;
}
public int getWidth()
{
String width = getAttribute(IHDR, "width");
return Integer.parseInt(width);
}
public int getHeight()
{
String height = getAttribute(IHDR, "height");
return Integer.parseInt(height);
}
public String getBitDepth()
{
return getAttribute(IHDR, "bitDepth");
}
public String getColorType()
{
return getAttribute(IHDR, "colorType");
}
public String getCompressionMethod()
{
return getAttribute(IHDR, "compressionMethod");
}
public String getFilterMethod()
{
return getAttribute(IHDR, "filterMethod");
}
public String getInterlaceMethod()
{
return getAttribute(IHDR, "interlaceMethod");
}
public int getGamma()
{
String gamma = getAttribute("gAMA", "value");
return Integer.parseInt(gamma);
}
public int getPixelsPerUnitXAxis()
{
String pixelsPerUnitXAxis = getAttribute("pHYS", "pixelsPerUnitXAxis");
return Integer.parseInt(pixelsPerUnitXAxis);
}
public int getPixelsPerUnitYAxis()
{
String pixelsPerUnitYAxis = getAttribute("pHYS", "pixelsPerUnitYAxis");
return Integer.parseInt(pixelsPerUnitYAxis);
}
public String getPixelsPerUnitSpecifier()
{
return getAttribute("pHYS", "unitSpecifier");
}
}