Writes one IFD (Image File Directory).
(OutputStream out, int imageOffset, int nextIFD)
| 279 | |
| 280 | /** Writes one IFD (Image File Directory). */ |
| 281 | void writeIFD(OutputStream out, int imageOffset, int nextIFD) throws IOException { |
| 282 | int tagDataOffset = HDR_SIZE + ifdSize; |
| 283 | writeShort(out, nEntries); |
| 284 | writeEntry(out, TiffDecoder.NEW_SUBFILE_TYPE, 4, 1, 0); |
| 285 | writeEntry(out, TiffDecoder.IMAGE_WIDTH, 4, 1, fi.width); |
| 286 | writeEntry(out, TiffDecoder.IMAGE_LENGTH, 4, 1, fi.height); |
| 287 | if (fi.fileType==FileInfo.RGB||fi.fileType==FileInfo.RGB48) { |
| 288 | writeEntry(out, TiffDecoder.BITS_PER_SAMPLE, 3, 3, tagDataOffset); |
| 289 | tagDataOffset += BPS_DATA_SIZE; |
| 290 | } else |
| 291 | writeEntry(out, TiffDecoder.BITS_PER_SAMPLE, 3, 1, bitsPerSample); |
| 292 | writeEntry(out, TiffDecoder.COMPRESSION, 3, 1, 1); //No Compression |
| 293 | writeEntry(out, TiffDecoder.PHOTO_INTERP, 3, 1, photoInterp); |
| 294 | if (description!=null) { |
| 295 | writeEntry(out, TiffDecoder.IMAGE_DESCRIPTION, 2, description.length, tagDataOffset); |
| 296 | tagDataOffset += description.length; |
| 297 | } |
| 298 | writeEntry(out, TiffDecoder.STRIP_OFFSETS, 4, 1, imageOffset); |
| 299 | writeEntry(out, TiffDecoder.SAMPLES_PER_PIXEL,3, 1, samplesPerPixel); |
| 300 | writeEntry(out, TiffDecoder.ROWS_PER_STRIP, 4, 1, fi.height); |
| 301 | writeEntry(out, TiffDecoder.STRIP_BYTE_COUNT, 4, 1, imageSize); |
| 302 | if (fi.unit!=null && fi.pixelWidth!=0 && fi.pixelHeight!=0) { |
| 303 | writeEntry(out, TiffDecoder.X_RESOLUTION, 5, 1, tagDataOffset); |
| 304 | writeEntry(out, TiffDecoder.Y_RESOLUTION, 5, 1, tagDataOffset+8); |
| 305 | tagDataOffset += SCALE_DATA_SIZE; |
| 306 | int unit = 1; |
| 307 | if (fi.unit.equals("inch")) |
| 308 | unit = 2; |
| 309 | else if (fi.unit.equals("cm")) |
| 310 | unit = 3; |
| 311 | writeEntry(out, TiffDecoder.RESOLUTION_UNIT, 3, 1, unit); |
| 312 | } |
| 313 | if (fi.fileType==fi.GRAY32_FLOAT) { |
| 314 | int format = TiffDecoder.FLOATING_POINT; |
| 315 | writeEntry(out, TiffDecoder.SAMPLE_FORMAT, 3, 1, format); |
| 316 | } |
| 317 | if (colorMapSize>0) { |
| 318 | writeEntry(out, TiffDecoder.COLOR_MAP, 3, MAP_SIZE, tagDataOffset); |
| 319 | tagDataOffset += MAP_SIZE*2; |
| 320 | } |
| 321 | if (metaDataSize>0) { |
| 322 | writeEntry(out, TiffDecoder.META_DATA_BYTE_COUNTS, 4, nMetaDataEntries, tagDataOffset); |
| 323 | writeEntry(out, TiffDecoder.META_DATA, 1, metaDataSize, tagDataOffset+4*nMetaDataEntries); |
| 324 | tagDataOffset += nMetaDataEntries*4 + metaDataSize; |
| 325 | } |
| 326 | writeInt(out, nextIFD); |
| 327 | } |
| 328 | |
| 329 | /** Writes the 6 bytes of data required by RGB BitsPerSample tag. */ |
| 330 | void writeBitsPerPixel(OutputStream out) throws IOException { |
no test coverage detected