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


Java TiffConstants.PLANAR_CONFIGURATION_CHUNKY屬性代碼示例

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


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

示例1: calculateRowsPerStrip

/**
 * 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,代碼行數:30,代碼來源:Rasters.java

示例2: FileDirectory

/**
 * Constructor, for reading TIFF files
 * 
 * @param entries
 *            file directory entries
 * @param reader
 *            TIFF file byte reader
 * @param cacheData
 *            true to cache tiles and strips
 */
public FileDirectory(SortedSet<FileDirectoryEntry> entries,
		ByteReader reader, boolean cacheData) {
	// Set the entries and the field tag type mapping
	this.entries = entries;
	for (FileDirectoryEntry entry : entries) {
		fieldTagTypeMapping.put(entry.getFieldTag(), entry);
	}

	this.reader = reader;

	// Set the cache
	setCache(cacheData);

	// Determine if tiled
	tiled = getRowsPerStrip() == null;

	// Determine and validate the planar configuration
	Integer pc = getPlanarConfiguration();
	planarConfiguration = pc != null ? pc
			: TiffConstants.PLANAR_CONFIGURATION_CHUNKY;
	if (planarConfiguration != TiffConstants.PLANAR_CONFIGURATION_CHUNKY
			&& planarConfiguration != TiffConstants.PLANAR_CONFIGURATION_PLANAR) {
		throw new TiffException("Invalid planar configuration: "
				+ planarConfiguration);
	}

	// Determine the decoder based upon the compression
	Integer compression = getCompression();
	if (compression == null) {
		compression = TiffConstants.COMPRESSION_NO;
	}
	switch (compression) {
	case TiffConstants.COMPRESSION_NO:
		decoder = 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:
		decoder = 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:
		decoder = new DeflateCompression();
		break;
	case TiffConstants.COMPRESSION_PACKBITS:
		decoder = new PackbitsCompression();
		break;
	default:
		throw new TiffException("Unknown compression method identifier: "
				+ compression);
	}
}
 
開發者ID:ngageoint,項目名稱:tiff-java,代碼行數:73,代碼來源:FileDirectory.java

示例3: getTileOrStrip

/**
 * Get the tile or strip for the sample coordinate
 * 
 * @param x
 *            x coordinate
 * @param y
 *            y coordinate
 * @param sample
 *            sample index
 * @return bytes
 */
private byte[] getTileOrStrip(int x, int y, int sample) {

	byte[] tileOrStrip = null;

	int imageWidth = getImageWidth().intValue();
	int imageHeight = getImageHeight().intValue();
	int tileWidth = getTileWidth().intValue();
	int tileHeight = getTileHeight().intValue();
	int numTilesPerRow = (imageWidth + tileWidth - 1) / tileWidth;
	int numTilesPerCol = (imageHeight + tileHeight - 1) / tileHeight;

	int index = 0;
	if (planarConfiguration == TiffConstants.PLANAR_CONFIGURATION_CHUNKY) {
		index = y * numTilesPerRow + x;
	} else if (planarConfiguration == TiffConstants.PLANAR_CONFIGURATION_PLANAR) {
		index = sample * numTilesPerRow * numTilesPerCol + y
				* numTilesPerRow + x;
	}

	// Attempt to pull from the cache
	if (cache != null && cache.containsKey(index)) {
		tileOrStrip = cache.get(index);
	} else if (lastBlockIndex == index && lastBlock != null) {
		tileOrStrip = lastBlock;
	} else {

		// Read and decode the block

		int offset = 0;
		int byteCount = 0;
		if (tiled) {
			offset = getTileOffsets().get(index).intValue();
			byteCount = getTileByteCounts().get(index).intValue();
		} else {
			offset = getStripOffsets().get(index).intValue();
			byteCount = getStripByteCounts().get(index).intValue();
		}

		reader.setNextByte(offset);
		byte[] bytes = reader.readBytes(byteCount);
		tileOrStrip = decoder.decode(bytes, reader.getByteOrder());

		// Cache the data
		if (cache != null) {
			cache.put(index, tileOrStrip);
		} else {
			lastBlockIndex = index;
			lastBlock = tileOrStrip;
		}
	}

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


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