All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twelvemonkeys.imageio.plugins.sgi.SGIMetadata Maven / Gradle / Ivy

There is a newer version: 3.12.0
Show newest version
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