if (w > pic.getWidth() || h > pic.getHeight()) {
throw new CoreException("Subpicture too large: " + w + "x" + h + " at offset " + ToolBox.toHexLeftZeroPadded(pic.getImageBufferOffsetEven(), 8));
}
Bitmap bm = new Bitmap(w, h, (byte)transIdx);
int sizeEven = pic.getImageBufferOffsetOdd() - pic.getImageBufferOffsetEven();
int sizeOdd = pic.getImageBufferSize() + pic.getImageBufferOffsetEven() - pic.getImageBufferOffsetOdd();
if (sizeEven <= 0 || sizeOdd <= 0) {
throw new CoreException("Corrupt buffer offset information");
}
byte evenBuf[] = new byte[sizeEven];
byte oddBuf[] = new byte[sizeOdd];
try {
// copy buffers
try {
for (int i=0; i < evenBuf.length; i++) {
evenBuf[i] = (byte)buffer.getByte(pic.getImageBufferOffsetEven() + i);
}
} catch (ArrayIndexOutOfBoundsException ex) {
warnings++;
}
try {
for (int i=0; i < oddBuf.length; i++) {
oddBuf[i] = (byte)buffer.getByte(pic.getImageBufferOffsetOdd() +i);
}
} catch (ArrayIndexOutOfBoundsException ex) {
warnings++;
}
// decode even lines
try {
BitStream even = new BitStream(evenBuf);
decodeLine(bm.getInternalBuffer(), 0, w, w*(h/2+(h&1)), even);
} catch (ArrayIndexOutOfBoundsException ex) {
warnings++;
}
// decode odd lines
try {
BitStream odd = new BitStream(oddBuf);
decodeLine(bm.getInternalBuffer(), w, w, (h/2)*w, odd);
} catch (ArrayIndexOutOfBoundsException ex) {
warnings++;
}
if (warnings > 0) {