int offset = start_with_zero ? 0 : 1;
int total = 0;
for (int i = 0; i < v.size(); i++)
{
App2Segment segment = (App2Segment) v.get(i);
if ((i + offset) != segment.cur_marker)
{
dumpSegments(v);
throw new ImageReadException(
"Incoherent App2 Segment Ordering. i: " + i
+ ", segment[" + i + "].cur_marker: "
+ segment.cur_marker + ".");
}
if (markerCount != segment.num_markers)
{
dumpSegments(v);
throw new ImageReadException(
"Inconsistent App2 Segment Count info. markerCount: "
+ markerCount + ", segment[" + i
+ "].num_markers: " + segment.num_markers + ".");
}
total += segment.icc_bytes.length;
}
byte result[] = new byte[total];
int progress = 0;
for (int i = 0; i < v.size(); i++)
{
App2Segment segment = (App2Segment) v.get(i);
System.arraycopy(segment.icc_bytes, 0, result, progress,
segment.icc_bytes.length);
progress += segment.icc_bytes.length;
}