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


Java PixelFormat类代码示例

本文整理汇总了Java中org.andengine.opengl.texture.PixelFormat的典型用法代码示例。如果您正苦于以下问题:Java PixelFormat类的具体用法?Java PixelFormat怎么用?Java PixelFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getPixels

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
public static Buffer getPixels(final Bitmap pBitmap, final PixelFormat pPixelFormat, final ByteOrder pByteOrder) {
	final int[] pixelsARGB_8888 = GLHelper.getPixelsARGB_8888(pBitmap);

	switch (pPixelFormat) {
		case RGB_565:
			return ShortBuffer.wrap(GLHelper.convertARGB_8888toRGB_565(pixelsARGB_8888, pByteOrder)); // TODO Is ShortBuffer or IntBuffer faster?
		case RGBA_8888:
			// HACK =(
			final ByteOrder reverseByteOrder = (pByteOrder == ByteOrder.LITTLE_ENDIAN) ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
			return IntBuffer.wrap(GLHelper.convertARGB_8888toRGBA_8888(pixelsARGB_8888, reverseByteOrder));
		case RGBA_4444:
			return ShortBuffer.wrap(GLHelper.convertARGB_8888toRGBA_4444(pixelsARGB_8888, pByteOrder)); // TODO Is ShortBuffer or IntBuffer faster?
		case A_8:
			return ByteBuffer.wrap(GLHelper.convertARGB_8888toA_8(pixelsARGB_8888));
		default:
			throw new IllegalArgumentException("Unexpected " + PixelFormat.class.getSimpleName() + ": '" + pPixelFormat + "'.");
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:19,代码来源:GLHelper.java

示例2: ETC1Texture

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
public ETC1Texture(final TextureManager pTextureManager, final TextureOptions pTextureOptions, final ITextureStateListener pTextureStateListener) throws IOException {
	super(pTextureManager, PixelFormat.RGB_565, pTextureOptions, pTextureStateListener);

	InputStream inputStream = null;
	try {
		inputStream = this.getInputStream();

		this.mETC1TextureHeader = new ETC1TextureHeader(StreamUtils.streamToBytes(inputStream, ETC1.ETC_PKM_HEADER_SIZE));

		if (BuildConfig.DEBUG) {
			if (!(MathUtils.isPowerOfTwo(this.mETC1TextureHeader.mWidth) && MathUtils.isPowerOfTwo(this.mETC1TextureHeader.mHeight))) {
				Debug.w("ETC1 textures with NPOT sizes can cause a crash on PowerVR GPUs!");
			}
		}
	} finally {
		StreamUtils.close(inputStream);
	}
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:19,代码来源:ETC1Texture.java

示例3: update

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
public synchronized void update(final GLState pGLState) {
	if (this.mTexture.isLoadedToHardware()) {
		final ArrayList<Letter> lettersPendingToBeDrawnToTexture = this.mLettersPendingToBeDrawnToTexture;
		if (lettersPendingToBeDrawnToTexture.size() > 0) {
			this.mTexture.bind(pGLState);
			final PixelFormat pixelFormat = this.mTexture.getPixelFormat();

			final boolean preMultipyAlpha = this.mTexture.getTextureOptions().mPreMultiplyAlpha;
			for (int i = lettersPendingToBeDrawnToTexture.size() - 1; i >= 0; i--) {
				final Letter letter = lettersPendingToBeDrawnToTexture.get(i);
				if (!letter.isWhitespace()) {
					final Bitmap bitmap = this.getLetterBitmap(letter);

					final boolean useDefaultAlignment = MathUtils.isPowerOfTwo(bitmap.getWidth()) && MathUtils.isPowerOfTwo(bitmap.getHeight()) && (pixelFormat == PixelFormat.RGBA_8888);
					if (!useDefaultAlignment) {
						/* Adjust unpack alignment. */
						GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1);
					}

					if (preMultipyAlpha) {
						GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, letter.mTextureX, letter.mTextureY, bitmap);
					} else {
						pGLState.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, letter.mTextureX, letter.mTextureY, bitmap, pixelFormat);
					}

					if (!useDefaultAlignment) {
						/* Restore default unpack alignment. */
						GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, GLState.GL_UNPACK_ALIGNMENT_DEFAULT);
					}

					bitmap.recycle();
				}
			}
			lettersPendingToBeDrawnToTexture.clear();

			System.gc();
		}
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:40,代码来源:Font.java

示例4: writeTextureToHardware

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
@Override
protected void writeTextureToHardware(final GLState pGLState) throws IOException {
	final Config bitmapConfig = this.mBitmapTextureFormat.getBitmapConfig();
	final Bitmap bitmap = this.onGetBitmap(bitmapConfig);

	if (bitmap == null) {
		throw new NullBitmapException("Caused by: '" + this.toString() + "'.");
	}

	final boolean useDefaultAlignment = MathUtils.isPowerOfTwo(bitmap.getWidth()) && MathUtils.isPowerOfTwo(bitmap.getHeight()) && (this.mPixelFormat == PixelFormat.RGBA_8888);
	if (!useDefaultAlignment) {
		/* Adjust unpack alignment. */
		GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1);
	}

	final boolean preMultipyAlpha = this.mTextureOptions.mPreMultiplyAlpha;
	if (preMultipyAlpha) {
		GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
	} else {
		pGLState.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0, this.mPixelFormat);
	}

	if (!useDefaultAlignment) {
		/* Restore default unpack alignment. */
		GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, GLState.GL_UNPACK_ALIGNMENT_DEFAULT);
	}

	bitmap.recycle();
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:30,代码来源:BitmapTexture.java

示例5: RenderTexture

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
public RenderTexture(final TextureManager pTextureManager, final int pWidth, final int pHeight, final PixelFormat pPixelFormat, final TextureOptions pTextureOptions, final ITextureStateListener pTextureStateListener) {
	super(pTextureManager, pPixelFormat, pTextureOptions, pTextureStateListener);

	this.mWidth = pWidth;
	this.mHeight = pHeight;

	this.mPixelFormat = pPixelFormat;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:9,代码来源:RenderTexture.java

示例6: getBitmap

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
public Bitmap getBitmap(final GLState pGLState, final int pX, final int pY, final int pWidth, final int pHeight) {
	if (this.mPixelFormat != PixelFormat.RGBA_8888) {
		throw new IllegalStateException("Currently only 'PixelFormat." + PixelFormat.RGBA_8888 + "' is supported to be retrieved as a Bitmap.");
	}

	return Bitmap.createBitmap(this.getPixelsARGB_8888(pGLState, pX, pY, pWidth, pHeight), pWidth, pHeight, Config.ARGB_8888);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:8,代码来源:RenderTexture.java

示例7: loadPVRTextureData

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
@Override
public void loadPVRTextureData(final IPVRTexturePixelBufferStrategyBufferManager pPVRTexturePixelBufferStrategyManager, final int pWidth, final int pHeight, final int pBytesPerPixel, final PixelFormat pPixelFormat, final int pLevel, final int pCurrentPixelDataOffset, final int pCurrentPixelDataSize) throws IOException {
	/* Adjust buffer. */
	final Buffer pixelBuffer = pPVRTexturePixelBufferStrategyManager.getPixelBuffer(PVRTextureHeader.SIZE + pCurrentPixelDataOffset, pCurrentPixelDataSize);

	/* Send to hardware. */
	GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, pLevel, pPixelFormat.getGLInternalFormat(), pWidth, pHeight, 0, pPixelFormat.getGLFormat(), pPixelFormat.getGLType(), pixelBuffer);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:9,代码来源:GreedyPVRTexturePixelBufferStrategy.java

示例8: loadPVRTextureData

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
@Override
public void loadPVRTextureData(final IPVRTexturePixelBufferStrategyBufferManager pPVRTexturePixelBufferStrategyManager, final int pWidth, final int pHeight, final int pBytesPerPixel, final PixelFormat pPixelFormat, final int pLevel, final int pCurrentPixelDataOffset, final int pCurrentPixelDataSize) throws IOException {
	final int glFormat = pPixelFormat.getGLFormat();
	final int glType = pPixelFormat.getGLType();

	/* Create the texture with the required parameters but without data. */
	GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, pLevel, pPixelFormat.getGLInternalFormat(), pWidth, pHeight, 0, glFormat, glType, null);

	final int bytesPerRow = pWidth * pBytesPerPixel;
	final int stripeHeight = Math.max(1, this.mAllocationSizeMaximum / bytesPerRow);

	/* Load stripes. */
	int currentStripePixelDataOffset = pCurrentPixelDataOffset;
	int currentStripeOffsetY = 0;
	while (currentStripeOffsetY < pHeight) {
		final int currentStripeHeight = Math.min(pHeight - currentStripeOffsetY, stripeHeight);
		final int currentStripePixelDataSize = currentStripeHeight * bytesPerRow;

		/* Adjust buffer. */
		final Buffer pixelBuffer = pPVRTexturePixelBufferStrategyManager.getPixelBuffer(PVRTextureHeader.SIZE + currentStripePixelDataOffset, currentStripePixelDataSize);

		/* Send to hardware. */
		GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, pLevel, 0, currentStripeOffsetY, pWidth, currentStripeHeight, glFormat, glType, pixelBuffer);

		currentStripePixelDataOffset += currentStripePixelDataSize;
		currentStripeOffsetY += currentStripeHeight;
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:29,代码来源:SmartPVRTexturePixelBufferStrategy.java

示例9: fromPixelFormat

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
public static PVRTextureFormat fromPixelFormat(final PixelFormat pPixelFormat) throws IllegalArgumentException {
	switch (pPixelFormat) {
		case RGBA_8888:
			return PVRTextureFormat.RGBA_8888;
		case RGBA_4444:
			return PVRTextureFormat.RGBA_4444;
		case RGB_565:
			return PVRTextureFormat.RGB_565;
		default:
			throw new IllegalArgumentException("Unsupported " + PixelFormat.class.getName() + ": '" + pPixelFormat + "'.");
	}
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:13,代码来源:PVRTexture.java

示例10: update

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
public synchronized void update(final GLState pGLState) {
	if(this.mTexture.isLoadedToHardware()) {
		final ArrayList<Letter> lettersPendingToBeDrawnToTexture = this.mLettersPendingToBeDrawnToTexture;
		if(lettersPendingToBeDrawnToTexture.size() > 0) {
			this.mTexture.bind(pGLState);
			final PixelFormat pixelFormat = this.mTexture.getPixelFormat();

			final boolean preMultipyAlpha = this.mTexture.getTextureOptions().mPreMultiplyAlpha;
			for(int i = lettersPendingToBeDrawnToTexture.size() - 1; i >= 0; i--) {
				final Letter letter = lettersPendingToBeDrawnToTexture.get(i);
				if(!letter.isWhitespace()) {
					final Bitmap bitmap = this.getLetterBitmap(letter);

					final boolean useDefaultAlignment = MathUtils.isPowerOfTwo(bitmap.getWidth()) && MathUtils.isPowerOfTwo(bitmap.getHeight()) && (pixelFormat == PixelFormat.RGBA_8888);
					if(!useDefaultAlignment) {
						/* Adjust unpack alignment. */
						GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1);
					}

					if(preMultipyAlpha) {
						GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, letter.mTextureX, letter.mTextureY, bitmap);
					} else {
						pGLState.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, letter.mTextureX, letter.mTextureY, bitmap, pixelFormat);
					}

					if(!useDefaultAlignment) {
						/* Restore default unpack alignment. */
						GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, GLState.GL_UNPACK_ALIGNMENT_DEFAULT);
					}

					bitmap.recycle();
				}
			}
			lettersPendingToBeDrawnToTexture.clear();

			System.gc();
		}
	}
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:40,代码来源:Font.java

示例11: writeTextureToHardware

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
@Override
protected void writeTextureToHardware(final GLState pGLState) throws IOException {
	final Config bitmapConfig = this.mBitmapTextureFormat.getBitmapConfig();
	final Bitmap bitmap = this.onGetBitmap(bitmapConfig);

	if(bitmap == null) {
		throw new NullBitmapException("Caused by: '" + this.toString() + "'.");
	}

	final boolean useDefaultAlignment = MathUtils.isPowerOfTwo(bitmap.getWidth()) && MathUtils.isPowerOfTwo(bitmap.getHeight()) && (this.mPixelFormat == PixelFormat.RGBA_8888);
	if(!useDefaultAlignment) {
		/* Adjust unpack alignment. */
		GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1);
	}

	final boolean preMultipyAlpha = this.mTextureOptions.mPreMultiplyAlpha;
	if(preMultipyAlpha) {
		GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
	} else {
		pGLState.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0, this.mPixelFormat);
	}

	if(!useDefaultAlignment) {
		/* Restore default unpack alignment. */
		GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, GLState.GL_UNPACK_ALIGNMENT_DEFAULT);
	}

	bitmap.recycle();
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:30,代码来源:BitmapTexture.java

示例12: getBitmap

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
public Bitmap getBitmap(final GLState pGLState, final int pX, final int pY, final int pWidth, final int pHeight) {
	if(this.mPixelFormat != PixelFormat.RGBA_8888) {
		throw new IllegalStateException("Currently only 'PixelFormat." + PixelFormat.RGBA_8888 + "' is supported to be retrieved as a Bitmap.");
	}

	return Bitmap.createBitmap(this.getPixelsARGB_8888(pGLState, pX, pY, pWidth, pHeight), pWidth, pHeight, Config.ARGB_8888);
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:8,代码来源:RenderTexture.java

示例13: fromPixelFormat

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
public static PVRTextureFormat fromPixelFormat(final PixelFormat pPixelFormat) throws IllegalArgumentException {
	switch(pPixelFormat) {
		case RGBA_8888:
			return PVRTextureFormat.RGBA_8888;
		case RGBA_4444:
			return PVRTextureFormat.RGBA_4444;
		case RGB_565:
			return PVRTextureFormat.RGB_565;
		default:
			throw new IllegalArgumentException("Unsupported " + PixelFormat.class.getName() + ": '" + pPixelFormat + "'.");
	}
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:13,代码来源:PVRTexture.java

示例14: loadPVRTextureData

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
@Override
public void loadPVRTextureData(final IPVRTexturePixelBufferStrategyBufferManager pPVRTexturePixelBufferStrategyManager, final int pWidth, final int pHeight, final int pBytesPerPixel, final PixelFormat pPixelFormat, final int pLevel, final int pCurrentPixelDataOffset, final int pCurrentPixelDataSize) throws IOException {
	final int glFormat = pPixelFormat.getGLFormat();
	final int glType = pPixelFormat.getGLType();

	/* Create the texture with the required parameters but without data. */
	GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, pLevel, pPixelFormat.getGLInternalFormat(), pWidth, pHeight, 0, glFormat, glType, null);

	final int bytesPerRow = pWidth * pBytesPerPixel;
	final int stripeHeight = Math.max(1, this.mAllocationSizeMaximum / bytesPerRow);

	/* Load stripes. */
	int currentStripePixelDataOffset = pCurrentPixelDataOffset;
	int currentStripeOffsetY = 0;
	while(currentStripeOffsetY < pHeight) {
		final int currentStripeHeight = Math.min(pHeight - currentStripeOffsetY, stripeHeight);
		final int currentStripePixelDataSize = currentStripeHeight * bytesPerRow;

		/* Adjust buffer. */
		final Buffer pixelBuffer = pPVRTexturePixelBufferStrategyManager.getPixelBuffer(PVRTextureHeader.SIZE + currentStripePixelDataOffset, currentStripePixelDataSize);

		/* Send to hardware. */
		GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, pLevel, 0, currentStripeOffsetY, pWidth, currentStripeHeight, glFormat, glType, pixelBuffer);

		currentStripePixelDataOffset += currentStripePixelDataSize;
		currentStripeOffsetY += currentStripeHeight;
	}
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:29,代码来源:SmartPVRTexturePixelBufferStrategy.java

示例15: ETC1Texture

import org.andengine.opengl.texture.PixelFormat; //导入依赖的package包/类
public ETC1Texture(final TextureManager pTextureManager, final TextureOptions pTextureOptions, final ITextureStateListener pTextureStateListener) throws IOException {
	super(pTextureManager, PixelFormat.RGB_565, pTextureOptions, pTextureStateListener);

	InputStream inputStream = null;
	try {
		inputStream = this.getInputStream();

		this.mETC1TextureHeader = new ETC1TextureHeader(StreamUtils.streamToBytes(inputStream, ETC1.ETC_PKM_HEADER_SIZE));
	} finally {
		StreamUtils.close(inputStream);
	}
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:13,代码来源:ETC1Texture.java


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