TMI-JPEG-22: Fixed issue with trash 0x00 padding in JPEG.

This commit is contained in:
Harald Kuhr
2013-12-16 18:08:39 +01:00
parent 55a373b0ff
commit ce87171026
2 changed files with 30 additions and 2 deletions

View File

@@ -157,6 +157,22 @@ public final class JPEGSegmentUtil {
static JPEGSegment readSegment(final ImageInputStream stream, final Map<Integer, List<String>> segmentIdentifiers) throws IOException {
int marker = stream.readUnsignedShort();
// Skip over weird 0x00 padding...?
int bad = 0;
while (marker == 0) {
marker = stream.readUnsignedShort();
bad += 2;
}
if (marker == 0x00ff) {
bad++;
marker = 0xff00 | stream.readUnsignedByte();
}
if (bad != 0) {
// System.err.println("bad: " + bad);
}
// Skip over 0xff padding between markers
while (marker == 0xffff) {
marker = 0xff00 | stream.readUnsignedByte();