public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
            throws ImageReadException, IOException
    {
        ArrayList segments = readSegments(byteSource,
                new int[] { JPEG_APP2_Marker, }, false);

        if (segments != null)
        {
            // throw away non-icc profile app2 segments.
            ArrayList filtered = new ArrayList();
            for (int i = 0; i < segments.size(); i++)
            {
                App2Segment segment = (App2Segment) segments.get(i);
                if (segment.icc_bytes != null)
                    filtered.add(segment);
            }
            segments = filtered;
        }

        if ((segments == null) || (segments.size() < 1))
            return null;

        byte bytes[] = assembleSegments(segments);

        if (debug)
            System.out.println("bytes" + ": "
                    + ((bytes == null) ? null : "" + bytes.length));

        if (debug)
            System.out.println("");

        return (bytes);
    }