posInt.x + currentIPPosition,
posInt.y + currentBPPosition,
posInt.width,
posInt.height);
} else if (img instanceof ImageRawCCITTFax) {
ImageRawCCITTFax ccitt = (ImageRawCCITTFax)img;
int afpx = mpts2units(posInt.x + currentIPPosition);
int afpy = mpts2units(posInt.y + currentBPPosition);
int afpw = mpts2units(posInt.getWidth());
int afph = mpts2units(posInt.getHeight());
int afpres = getResolution();
ImageObject io = afpDataStream.getImageObject(afpx, afpy, afpw, afph,
afpres, afpres);
io.setImageParameters(
(int) (ccitt.getSize().getDpiHorizontal() * 10),
(int) (ccitt.getSize().getDpiVertical() * 10),
ccitt.getSize().getWidthPx(),
ccitt.getSize().getHeightPx());
int compression = ccitt.getCompression();
switch (compression) {
case TIFFImage.COMP_FAX_G3_1D :
io.setImageEncoding((byte) 0x80);
break;
case TIFFImage.COMP_FAX_G3_2D :
io.setImageEncoding((byte) 0x81);
break;
case TIFFImage.COMP_FAX_G4_2D :
io.setImageEncoding((byte) 0x82);
break;
default:
throw new IllegalStateException(
"Invalid compression scheme: " + compression);
}
InputStream in = ccitt.createInputStream();
try {
byte[] buf = IOUtils.toByteArray(in);
io.setImageData(buf);
} finally {
IOUtils.closeQuietly(in);