com.twelvemonkeys.imageio.plugins.sgi.SGIMetadata Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of imageio-sgi Show documentation
Show all versions of imageio-sgi Show documentation
ImageIO plugin for Silicon Graphics Image Format (SGI)
package com.twelvemonkeys.imageio.plugins.sgi;
import com.twelvemonkeys.imageio.StandardImageMetadataSupport;
import javax.imageio.ImageTypeSpecifier;
final class SGIMetadata extends StandardImageMetadataSupport {
public SGIMetadata(ImageTypeSpecifier type, SGIHeader header) {
super(builder(type)
.withSignificantBitsPerSample(computeSignificantBits(header))
.withCompressionTypeName(compressionName(header))
.withOrientation(ImageOrientation.FlipV)
.withTextEntry("DocumentName", header.getName())
);
}
private static int computeSignificantBits(SGIHeader header) {
int maxSample = header.getMaxValue();
int significantBits = 1;
while ((maxSample >>>= 1) != 0) {
significantBits++;
}
return significantBits;
}
private static String compressionName(SGIHeader header) {
switch (header.getCompression()) {
case SGI.COMPRESSION_NONE:
return "None";
case SGI.COMPRESSION_RLE:
return "RLE";
}
return "Uknown";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy