當前位置: 首頁>>代碼示例>>Java>>正文


Java TiffConstants類代碼示例

本文整理匯總了Java中mil.nga.tiff.util.TiffConstants的典型用法代碼示例。如果您正苦於以下問題:Java TiffConstants類的具體用法?Java TiffConstants怎麽用?Java TiffConstants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TiffConstants類屬於mil.nga.tiff.util包,在下文中一共展示了TiffConstants類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: calculateRowsPerStrip

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Calculate the rows per strip to write
 * 
 * @param planarConfiguration
 *            chunky or planar
 * @param maxBytesPerStrip
 *            attempted max bytes per strip
 * @return rows per strip
 */
public int calculateRowsPerStrip(int planarConfiguration,
		int maxBytesPerStrip) {

	Integer rowsPerStrip = null;

	if (planarConfiguration == TiffConstants.PLANAR_CONFIGURATION_CHUNKY) {
		rowsPerStrip = rowsPerStrip(sizePixel(), maxBytesPerStrip);
	} else {

		for (int sample = 0; sample < getSamplesPerPixel(); ++sample) {
			int rowsPerStripForSample = rowsPerStrip(
					fieldTypes[sample].getBytes(), maxBytesPerStrip);
			if (rowsPerStrip == null
					|| rowsPerStripForSample < rowsPerStrip) {
				rowsPerStrip = rowsPerStripForSample;
			}
		}
	}

	return rowsPerStrip;
}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:31,代碼來源:Rasters.java

示例2: writeTiff

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Write a TIFF to a byte writer
 * 
 * @param writer
 *            byte writer
 * @param tiffImage
 *            TIFF image
 * @throws IOException
 *             upon failure to write
 */
public static void writeTiff(ByteWriter writer, TIFFImage tiffImage)
		throws IOException {

	// Write the byte order (bytes 0-1)
	String byteOrder = writer.getByteOrder() == ByteOrder.BIG_ENDIAN ? TiffConstants.BYTE_ORDER_BIG_ENDIAN
			: TiffConstants.BYTE_ORDER_LITTLE_ENDIAN;
	writer.writeString(byteOrder);

	// Write the TIFF file identifier (bytes 2-3)
	writer.writeUnsignedShort(TiffConstants.FILE_IDENTIFIER);

	// Write the first IFD offset (bytes 4-7), set to start right away at
	// byte 8
	writer.writeUnsignedInt(TiffConstants.HEADER_BYTES);

	// Write the TIFF Image
	writeImageFileDirectories(writer, tiffImage);
}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:29,代碼來源:TiffWriter.java

示例3: populateStripEntries

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Populate the strip entries with placeholder values
 * 
 * @param fileDirectory
 *            file directory
 */
private static void populateStripEntries(FileDirectory fileDirectory) {

	int rowsPerStrip = fileDirectory.getRowsPerStrip().intValue();
	int imageHeight = fileDirectory.getImageHeight().intValue();
	int stripsPerSample = (imageHeight + rowsPerStrip - 1) / rowsPerStrip;
	int strips = stripsPerSample;
	if (fileDirectory.getPlanarConfiguration() == TiffConstants.PLANAR_CONFIGURATION_PLANAR) {
		strips *= fileDirectory.getSamplesPerPixel();
	}

	fileDirectory.setStripOffsetsAsLongs(new ArrayList<>(Collections
			.nCopies(strips, 0l)));
	fileDirectory.setStripByteCounts(new ArrayList<>(Collections.nCopies(
			strips, 0)));
}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:22,代碼來源:TiffWriter.java

示例4: createImage

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Create a new image
 *
 * @param tileWidth  tile width
 * @param tileHeight tile height
 * @return image
 */
public ElevationTiffImage createImage(int tileWidth, int tileHeight) {

    Rasters rasters = new Rasters(tileWidth, tileHeight, 1,
            BITS_PER_SAMPLE, TiffConstants.SAMPLE_FORMAT_FLOAT);

    int rowsPerStrip = rasters.calculateRowsPerStrip(TiffConstants.PLANAR_CONFIGURATION_CHUNKY);

    FileDirectory fileDirectory = new FileDirectory();
    fileDirectory.setImageWidth(tileWidth);
    fileDirectory.setImageHeight(tileHeight);
    fileDirectory.setBitsPerSample(BITS_PER_SAMPLE);
    fileDirectory.setCompression(TiffConstants.COMPRESSION_NO);
    fileDirectory.setPhotometricInterpretation(TiffConstants.PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO);
    fileDirectory.setSamplesPerPixel(SAMPLES_PER_PIXEL);
    fileDirectory.setRowsPerStrip(rowsPerStrip);
    fileDirectory.setPlanarConfiguration(TiffConstants.PLANAR_CONFIGURATION_CHUNKY);
    fileDirectory.setSampleFormat(TiffConstants.SAMPLE_FORMAT_FLOAT);
    fileDirectory.setWriteRasters(rasters);

    ElevationTiffImage image = new ElevationTiffImage(fileDirectory);

    return image;
}
 
開發者ID:ngageoint,項目名稱:geopackage-android,代碼行數:31,代碼來源:ElevationTilesTiff.java

示例5: readTiff

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Read a TIFF from the byte reader
 * 
 * @param reader
 *            byte reader
 * @param cache
 *            true to cache tiles and strips
 * @return TIFF image
 */
public static TIFFImage readTiff(ByteReader reader, boolean cache) {

	// Read the 2 bytes of byte order
	String byteOrderString = null;
	try {
		byteOrderString = reader.readString(2);
	} catch (UnsupportedEncodingException e) {
		throw new TiffException("Failed to read byte order", e);
	}

	// Determine the byte order
	ByteOrder byteOrder = null;
	switch (byteOrderString) {
	case TiffConstants.BYTE_ORDER_LITTLE_ENDIAN:
		byteOrder = ByteOrder.LITTLE_ENDIAN;
		break;
	case TiffConstants.BYTE_ORDER_BIG_ENDIAN:
		byteOrder = ByteOrder.BIG_ENDIAN;
		break;
	default:
		throw new TiffException("Invalid byte order: " + byteOrderString);
	}
	reader.setByteOrder(byteOrder);

	// Validate the TIFF file identifier
	int tiffIdentifier = reader.readUnsignedShort();
	if (tiffIdentifier != TiffConstants.FILE_IDENTIFIER) {
		throw new TiffException("Invalid file identifier, not a TIFF");
	}

	// Get the offset in bytes of the first image file directory (IFD)
	int byteOffset = (int) reader.readUnsignedInt();

	// Get the TIFF Image
	TIFFImage tiffImage = parseTIFFImage(reader, byteOffset, cache);

	return tiffImage;
}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:48,代碼來源:TiffReader.java

示例6: getFieldTypeForSample

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Get the field type for the sample
 *
 * @param sampleIndex
 *            sample index
 * @return field type
 */
public FieldType getFieldTypeForSample(int sampleIndex) {

	List<Integer> sampleFormatList = getSampleFormat();
	int sampleFormat = sampleFormatList == null ? TiffConstants.SAMPLE_FORMAT_UNSIGNED_INT
			: sampleFormatList
					.get(sampleIndex < sampleFormatList.size() ? sampleIndex
							: 0);
	int bitsPerSample = getBitsPerSample().get(sampleIndex);

	FieldType fieldType = FieldType.getFieldType(sampleFormat,
			bitsPerSample);

	return fieldType;
}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:22,代碼來源:FileDirectory.java

示例7: sizeWithValues

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Size in bytes of the image file directory including entry values (not
 * contiguous bytes)
 * 
 * @return size in bytes
 */
public long sizeWithValues() {
	long size = TiffConstants.IFD_HEADER_BYTES
			+ TiffConstants.IFD_OFFSET_BYTES;
	for (FileDirectoryEntry entry : entries) {
		size += entry.sizeWithValues();
	}
	return size;
}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:15,代碼來源:FileDirectory.java

示例8: sizeHeaderAndDirectories

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Size in bytes of the TIFF header and file directories with their entries
 * 
 * @return size in bytes
 */
public long sizeHeaderAndDirectories() {
	long size = TiffConstants.HEADER_BYTES;
	for (FileDirectory directory : fileDirectories) {
		size += directory.size();
	}
	return size;
}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:13,代碼來源:TIFFImage.java

示例9: sizeHeaderAndDirectoriesWithValues

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Size in bytes of the TIFF header and file directories with their entries
 * and entry values
 * 
 * @return size in bytes
 */
public long sizeHeaderAndDirectoriesWithValues() {
	long size = TiffConstants.HEADER_BYTES;
	for (FileDirectory directory : fileDirectories) {
		size += directory.sizeWithValues();
	}
	return size;
}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:14,代碼來源:TIFFImage.java

示例10: testWriteStrippedChunky

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Test writing and reading a stripped TIFF file
 * 
 * @throws IOException
 */
@Test
public void testWriteStrippedChunky() throws IOException {

	File strippedFile = TiffTestUtils
			.getTestFile(TiffTestConstants.FILE_STRIPPED);
	TIFFImage strippedTiff = TiffReader.readTiff(strippedFile);

	FileDirectory fileDirectory = strippedTiff.getFileDirectory();
	Rasters rasters = fileDirectory.readRasters();
	Rasters rastersInterleaved = fileDirectory.readInterleavedRasters();

	fileDirectory.setWriteRasters(rasters);
	fileDirectory.setCompression(TiffConstants.COMPRESSION_NO);
	fileDirectory
			.setPlanarConfiguration(TiffConstants.PLANAR_CONFIGURATION_CHUNKY);
	int rowsPerStrip = rasters.calculateRowsPerStrip(fileDirectory
			.getPlanarConfiguration());
	fileDirectory.setRowsPerStrip(rowsPerStrip);
	byte[] tiffBytes = TiffWriter.writeTiffToBytes(strippedTiff);

	TIFFImage readTiffImage = TiffReader.readTiff(tiffBytes);
	FileDirectory fileDirectory2 = readTiffImage.getFileDirectory();
	Rasters rasters2 = fileDirectory2.readRasters();
	Rasters rasters2Interleaved = fileDirectory2.readInterleavedRasters();

	TiffTestUtils.compareRastersSampleValues(rasters, rasters2);
	TiffTestUtils.compareRastersInterleaveValues(rastersInterleaved,
			rasters2Interleaved);

}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:36,代碼來源:TiffWriteTest.java

示例11: testWriteStrippedPlanar

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Test writing and reading a stripped TIFF file
 * 
 * @throws IOException
 */
@Test
public void testWriteStrippedPlanar() throws IOException {

	File strippedFile = TiffTestUtils
			.getTestFile(TiffTestConstants.FILE_STRIPPED);
	TIFFImage strippedTiff = TiffReader.readTiff(strippedFile);

	FileDirectory fileDirectory = strippedTiff.getFileDirectory();
	Rasters rasters = fileDirectory.readRasters();
	Rasters rastersInterleaved = fileDirectory.readInterleavedRasters();

	fileDirectory.setWriteRasters(rasters);
	fileDirectory.setCompression(TiffConstants.COMPRESSION_NO);
	fileDirectory
			.setPlanarConfiguration(TiffConstants.PLANAR_CONFIGURATION_PLANAR);
	int rowsPerStrip = rasters.calculateRowsPerStrip(fileDirectory
			.getPlanarConfiguration());
	fileDirectory.setRowsPerStrip(rowsPerStrip);
	byte[] tiffBytes = TiffWriter.writeTiffToBytes(strippedTiff);

	TIFFImage readTiffImage = TiffReader.readTiff(tiffBytes);
	FileDirectory fileDirectory2 = readTiffImage.getFileDirectory();
	Rasters rasters2 = fileDirectory2.readRasters();
	Rasters rasters2Interleaved = fileDirectory2.readInterleavedRasters();

	TiffTestUtils.compareRastersSampleValues(rasters, rasters2);
	TiffTestUtils.compareRastersInterleaveValues(rastersInterleaved,
			rasters2Interleaved);

}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:36,代碼來源:TiffWriteTest.java

示例12: validateImageType

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Validate that the image type
 *
 * @param directory file directory
 */
public static void validateImageType(FileDirectory directory) {
    if (directory == null) {
        throw new GeoPackageException("The image is null");
    }

    int samplesPerPixel = directory.getSamplesPerPixel();
    Integer bitsPerSample = null;
    if (directory.getBitsPerSample() != null && !directory.getBitsPerSample().isEmpty()) {
        bitsPerSample = directory.getBitsPerSample().get(0);
    }
    Integer sampleFormat = null;
    if (directory.getSampleFormat() != null && !directory.getSampleFormat().isEmpty()) {
        sampleFormat = directory.getSampleFormat().get(0);
    }

    if (samplesPerPixel != SAMPLES_PER_PIXEL
            || bitsPerSample == null || bitsPerSample != BITS_PER_SAMPLE
            || sampleFormat == null || sampleFormat != TiffConstants.SAMPLE_FORMAT_FLOAT) {
        throw new GeoPackageException(
                "The elevation tile is expected to be a single sample 32 bit float. Samples Per Pixel: "
                        + samplesPerPixel
                        + ", Bits Per Sample: " + bitsPerSample
                        + ", Sample Format: " + sampleFormat);
    }

}
 
開發者ID:ngageoint,項目名稱:geopackage-android,代碼行數:32,代碼來源:ElevationTilesTiff.java

示例13: validateImageType

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Validate that the image type
 *
 * @param directory
 *            file directory
 */
public static void validateImageType(FileDirectory directory) {
	if (directory == null) {
		throw new GeoPackageException("The image is null");
	}

	int samplesPerPixel = directory.getSamplesPerPixel();
	Integer bitsPerSample = null;
	if (directory.getBitsPerSample() != null
			&& !directory.getBitsPerSample().isEmpty()) {
		bitsPerSample = directory.getBitsPerSample().get(0);
	}
	Integer sampleFormat = null;
	if (directory.getSampleFormat() != null
			&& !directory.getSampleFormat().isEmpty()) {
		sampleFormat = directory.getSampleFormat().get(0);
	}

	if (samplesPerPixel != SAMPLES_PER_PIXEL || bitsPerSample == null
			|| bitsPerSample != BITS_PER_SAMPLE || sampleFormat == null
			|| sampleFormat != TiffConstants.SAMPLE_FORMAT_FLOAT) {
		throw new GeoPackageException(
				"The elevation tile is expected to be a single sample 32 bit float. Samples Per Pixel: "
						+ samplesPerPixel
						+ ", Bits Per Sample: "
						+ bitsPerSample
						+ ", Sample Format: "
						+ sampleFormat);
	}

}
 
開發者ID:ngageoint,項目名稱:geopackage-java,代碼行數:37,代碼來源:ElevationTilesTiff.java

示例14: createImage

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Create a new image
 *
 * @param tileWidth
 *            tile width
 * @param tileHeight
 *            tile height
 * @return image
 */
public ElevationTiffImage createImage(int tileWidth, int tileHeight) {

	Rasters rasters = new Rasters(tileWidth, tileHeight, 1,
			BITS_PER_SAMPLE, TiffConstants.SAMPLE_FORMAT_FLOAT);

	int rowsPerStrip = rasters
			.calculateRowsPerStrip(TiffConstants.PLANAR_CONFIGURATION_CHUNKY);

	FileDirectory fileDirectory = new FileDirectory();
	fileDirectory.setImageWidth(tileWidth);
	fileDirectory.setImageHeight(tileHeight);
	fileDirectory.setBitsPerSample(BITS_PER_SAMPLE);
	fileDirectory.setCompression(TiffConstants.COMPRESSION_NO);
	fileDirectory
			.setPhotometricInterpretation(TiffConstants.PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO);
	fileDirectory.setSamplesPerPixel(SAMPLES_PER_PIXEL);
	fileDirectory.setRowsPerStrip(rowsPerStrip);
	fileDirectory
			.setPlanarConfiguration(TiffConstants.PLANAR_CONFIGURATION_CHUNKY);
	fileDirectory.setSampleFormat(TiffConstants.SAMPLE_FORMAT_FLOAT);
	fileDirectory.setWriteRasters(rasters);

	ElevationTiffImage image = new ElevationTiffImage(fileDirectory);

	return image;
}
 
開發者ID:ngageoint,項目名稱:geopackage-java,代碼行數:36,代碼來源:ElevationTilesTiff.java

示例15: getEncoder

import mil.nga.tiff.util.TiffConstants; //導入依賴的package包/類
/**
 * Get the compression encoder
 * 
 * @param fileDirectory
 *            file directory
 * @return encoder
 */
@SuppressWarnings("deprecation")
private static CompressionEncoder getEncoder(FileDirectory fileDirectory) {

	CompressionEncoder encoder = null;

	// Determine the encoder based upon the compression
	Integer compression = fileDirectory.getCompression();
	if (compression == null) {
		compression = TiffConstants.COMPRESSION_NO;
	}

	switch (compression) {
	case TiffConstants.COMPRESSION_NO:
		encoder = new RawCompression();
		break;
	case TiffConstants.COMPRESSION_CCITT_HUFFMAN:
		throw new TiffException("CCITT Huffman compression not supported: "
				+ compression);
	case TiffConstants.COMPRESSION_T4:
		throw new TiffException("T4-encoding compression not supported: "
				+ compression);
	case TiffConstants.COMPRESSION_T6:
		throw new TiffException("T6-encoding compression not supported: "
				+ compression);
	case TiffConstants.COMPRESSION_LZW:
		encoder = new LZWCompression();
		break;
	case TiffConstants.COMPRESSION_JPEG_OLD:
	case TiffConstants.COMPRESSION_JPEG_NEW:
		throw new TiffException("JPEG compression not supported: "
				+ compression);
	case TiffConstants.COMPRESSION_DEFLATE:
	case TiffConstants.COMPRESSION_PKZIP_DEFLATE:
		encoder = new DeflateCompression();
		break;
	case TiffConstants.COMPRESSION_PACKBITS:
		encoder = new PackbitsCompression();
		break;
	default:
		throw new TiffException("Unknown compression method identifier: "
				+ compression);
	}

	return encoder;
}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:53,代碼來源:TiffWriter.java


注:本文中的mil.nga.tiff.util.TiffConstants類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。