Example usage for org.apache.commons.imaging.common.bytesource ByteSourceArray ByteSourceArray

List of usage examples for org.apache.commons.imaging.common.bytesource ByteSourceArray ByteSourceArray

Introduction

In this page you can find the example usage for org.apache.commons.imaging.common.bytesource ByteSourceArray ByteSourceArray.

Prototype

public ByteSourceArray(final byte bytes[]) 

Source Link

Usage

From source file:org.gmdev.pdftrick.utils.CustomExtraImgReader.java

/**
 * Check if the images has Adobe byte marker and if is a YCCK type
 * @param imageByteArray//from ww w. ja  va2 s. c  o m
 * @throws IOException
 * @throws ImageReadException
 */
private static void checkAdobeMarker(byte[] imageByteArray) throws IOException, ImageReadException {
    JpegImageParser parser = new JpegImageParser();
    ByteSource byteSource = new ByteSourceArray(imageByteArray);
    List<Segment> segments = parser.readSegments(byteSource, new int[] { 0xffee }, true);
    if (segments != null && segments.size() >= 1) {
        //UnknownSegment app14Segment = (UnknownSegment) segments.get(0);
        //App14Segment app14Segment = (App14Segment) segments.get(0);
        GenericSegment app14Segment = (GenericSegment) segments.get(0);
        byte[] data = app14Segment.getSegmentData();
        if (data.length >= 12 && data[0] == 'A' && data[1] == 'd' && data[2] == 'o' && data[3] == 'b'
                && data[4] == 'e') {
            hasAdobeMarker = true;
            byte[] data_2 = app14Segment.getSegmentData();
            int transform = data_2[11] & 0xff;
            if (transform == 2)
                colorType = COLOR_TYPE_YCCK;
        }
    }
}