当前位置: 首页>>代码示例>>Java>>正文


Java DataConstants.BITS_PER_BYTE属性代码示例

本文整理汇总了Java中org.andengine.util.adt.data.constants.DataConstants.BITS_PER_BYTE属性的典型用法代码示例。如果您正苦于以下问题:Java DataConstants.BITS_PER_BYTE属性的具体用法?Java DataConstants.BITS_PER_BYTE怎么用?Java DataConstants.BITS_PER_BYTE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.andengine.util.adt.data.constants.DataConstants的用法示例。


在下文中一共展示了DataConstants.BITS_PER_BYTE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeTextureToHardware

@Override
protected void writeTextureToHardware(final GLState pGLState) throws IOException {
	final IPVRTexturePixelBufferStrategyBufferManager pvrTextureLoadStrategyManager = this.mPVRTexturePixelBufferStrategy.newPVRTexturePixelBufferStrategyManager(this);

	int width = this.getWidth();
	int height = this.getHeight();

	final int dataLength = this.mPVRTextureHeader.getDataLength();

	final int bytesPerPixel = this.mPVRTextureHeader.getBitsPerPixel() / DataConstants.BITS_PER_BYTE;

	/* Adjust unpack alignment. */
	GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1);

	int currentLevel = 0;
	int currentPixelDataOffset = 0;
	while (currentPixelDataOffset < dataLength) {
		if (currentLevel > 0 && (width != height || MathUtils.nextPowerOfTwo(width) != width)) {
			Debug.w("Mipmap level '" + currentLevel + "' is not squared. Width: '" + width + "', height: '" + height + "'. Texture won't render correctly.");
		}

		final int currentPixelDataSize = height * width * bytesPerPixel;

		/* Load the current level. */
		this.mPVRTexturePixelBufferStrategy.loadPVRTextureData(pvrTextureLoadStrategyManager, width, height, bytesPerPixel, this.mPixelFormat, currentLevel, currentPixelDataOffset, currentPixelDataSize);

		currentPixelDataOffset += currentPixelDataSize;

		/* Prepare next mipmap level. */
		width = Math.max(width / 2, 1);
		height = Math.max(height / 2, 1);

		currentLevel++;
	}

	/* Restore default unpack alignment. */
	GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, GLState.GL_UNPACK_ALIGNMENT_DEFAULT);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:38,代码来源:PVRTexture.java

示例2: getTextureMemorySize

@Override
public int getTextureMemorySize() {
	final int pixelCount = this.getWidth() * this.getHeight();
	final int bytesPerPixel = this.mPixelFormat.getBitsPerPixel() / DataConstants.BITS_PER_BYTE;
	return pixelCount * bytesPerPixel / DataConstants.BYTES_PER_KILOBYTE;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:6,代码来源:Texture.java

示例3: LongBackedBitVector

public LongBackedBitVector(final byte[] pData) throws IllegalArgumentException, NullPointerException {
	this(pData.length * DataConstants.BITS_PER_BYTE);

	final long[] data = this.mData;

	/* Check if bytes perfectly fit into the data fields or if there are some overflow bytes that need special treatment. */
	final boolean perfectDataFit = (pData.length % DataConstants.BYTES_PER_LONG) == 0;

	final int dataLength = data.length;
	final int lastCompleteDataIndex = (perfectDataFit) ? dataLength - 1 : dataLength - 2;

	for (int i = lastCompleteDataIndex; i >= 0; i--) {
		final int bytesOffset = i * DataConstants.BYTES_PER_LONG;

		data[i] = ((((long)pData[bytesOffset + 0]) << 56) & 0xFF00000000000000L)
				| ((((long)pData[bytesOffset + 1]) << 48) & 0xFF000000000000L)
				| ((((long)pData[bytesOffset + 2]) << 40) & 0xFF0000000000L)
				| ((((long)pData[bytesOffset + 3]) << 32) & 0xFF00000000L)
				| ((((long)pData[bytesOffset + 4]) << 24) & 0xFF000000L)
				| ((((long)pData[bytesOffset + 5]) << 16) & 0xFF0000L)
				| ((((long)pData[bytesOffset + 6]) <<  8) & 0xFF00L)
				| ((((long)pData[bytesOffset + 7]) <<  0) & 0xFFL);
	}

	/* Put overflow bytes into last data field. */
	if (!perfectDataFit) {
		long overflowData = 0;

		final int overflowDataIndex = dataLength - 1;
		final int overflowBytesOffset = overflowDataIndex * DataConstants.BYTES_PER_LONG;

		final int overflowByteCount = pData.length - overflowBytesOffset;
		switch (overflowByteCount) {
			case 7:
				overflowData = overflowData | ((((long)pData[overflowBytesOffset + 6]) <<  8) & 0xFF00L);
			case 6:
				overflowData = overflowData | ((((long)pData[overflowBytesOffset + 5]) << 16) & 0xFF0000L);
			case 5:
				overflowData = overflowData | ((((long)pData[overflowBytesOffset + 4]) << 24) & 0xFF000000L);
			case 4:
				overflowData = overflowData | ((((long)pData[overflowBytesOffset + 3]) << 32) & 0xFF00000000L);
			case 3:
				overflowData = overflowData | ((((long)pData[overflowBytesOffset + 2]) << 40) & 0xFF0000000000L);
			case 2:
				overflowData = overflowData | ((((long)pData[overflowBytesOffset + 1]) << 48) & 0xFF000000000000L);
			case 1:
				overflowData = overflowData | ((((long)pData[overflowBytesOffset + 0]) << 56) & 0xFF00000000000000L);
		}

		data[overflowDataIndex] = overflowData;
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:52,代码来源:LongBackedBitVector.java

示例4: toByteArray

@Override
public byte[] toByteArray() {
	final int byteArrayLength;
	if ((this.mSize % DataConstants.BITS_PER_BYTE) == 0) {
		byteArrayLength = this.mSize / DataConstants.BITS_PER_BYTE;
	} else {
		byteArrayLength = (this.mSize / DataConstants.BITS_PER_BYTE) + 1;
	}

	final byte[] bytes = new byte[byteArrayLength];
	/* Check if bytes perfectly fit into the data fields or if there are some overflow bytes that need special treatment. */
	final boolean perfectDataFit = (this.mSize % DataConstants.BITS_PER_LONG) == 0;

	final long[] data = this.mData;
	final int dataLength = data.length;
	final int lastCompleteDataIndex = (perfectDataFit) ? dataLength - 1 : dataLength - 2;

	int bytesOffset = (lastCompleteDataIndex * DataConstants.BYTES_PER_LONG) + (DataConstants.BYTES_PER_LONG - 1);
	for (int i = lastCompleteDataIndex; i >= 0; i--) {
		final long dataField = data[i];

		bytes[bytesOffset--] = (byte) ((dataField >> 0) & 0xFF);
		bytes[bytesOffset--] = (byte) ((dataField >> 8) & 0xFF);
		bytes[bytesOffset--] = (byte) ((dataField >> 16) & 0xFF);
		bytes[bytesOffset--] = (byte) ((dataField >> 24) & 0xFF);
		bytes[bytesOffset--] = (byte) ((dataField >> 32) & 0xFF);
		bytes[bytesOffset--] = (byte) ((dataField >> 40) & 0xFF);
		bytes[bytesOffset--] = (byte) ((dataField >> 48) & 0xFF);
		bytes[bytesOffset--] = (byte) ((dataField >> 56) & 0xFF);
	}

	/* Put overflow bytes into last data field. */
	if (!perfectDataFit) {
		final int overflowDataIndex = dataLength - 1;
		final long overflowDataField = data[overflowDataIndex];

		final int overflowBytesOffset = overflowDataIndex * DataConstants.BYTES_PER_LONG;

		final int overflowByteCount = bytes.length % DataConstants.BYTES_PER_LONG;
		switch (overflowByteCount) {
			case 7:
				bytes[overflowBytesOffset + 6] = (byte) ((overflowDataField >> 8) & 0xFF);
			case 6:
				bytes[overflowBytesOffset + 5] = (byte) ((overflowDataField >> 16) & 0xFF);
			case 5:
				bytes[overflowBytesOffset + 4] = (byte) ((overflowDataField >> 24) & 0xFF);
			case 4:
				bytes[overflowBytesOffset + 3] = (byte) ((overflowDataField >> 32) & 0xFF);
			case 3:
				bytes[overflowBytesOffset + 2] = (byte) ((overflowDataField >> 40) & 0xFF);
			case 2:
				bytes[overflowBytesOffset + 1] = (byte) ((overflowDataField >> 48) & 0xFF);
			case 1:
				bytes[overflowBytesOffset + 0] = (byte) ((overflowDataField >> 56) & 0xFF);
		}
	}

	return bytes;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:59,代码来源:LongBackedBitVector.java


注:本文中的org.andengine.util.adt.data.constants.DataConstants.BITS_PER_BYTE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。