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


Java PixelFormat.RGBA_8888属性代码示例

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


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

示例1: writeTextureToHardware

@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,代码行数:29,代码来源:BitmapTexture.java

示例2: getBitmap

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,代码行数:7,代码来源:RenderTexture.java

示例3: update

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,代码行数:39,代码来源:Font.java

示例4: getBitmap

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,代码行数:7,代码来源:RenderTexture.java

示例5: RenderTexture

public RenderTexture(final TextureManager pTextureManager, final int pWidth, final int pHeight, final TextureOptions pTextureOptions) {
	this(pTextureManager, pWidth, pHeight, PixelFormat.RGBA_8888, pTextureOptions);
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:3,代码来源:RenderTexture.java

示例6: RenderTexture

public RenderTexture(final TextureManager pTextureManager, final int pWidth, final int pHeight) {
	this(pTextureManager, pWidth, pHeight, PixelFormat.RGBA_8888, TextureOptions.NEAREST);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:3,代码来源:RenderTexture.java

示例7: writeTextureToHardware

@Override
protected void writeTextureToHardware(final GLState pGLState) {
	final PixelFormat pixelFormat = this.mBitmapTextureFormat.getPixelFormat();
	final int glInternalFormat = pixelFormat.getGLInternalFormat();
	final int glFormat = pixelFormat.getGLFormat();
	final int glType = pixelFormat.getGLType();

	GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, glInternalFormat, this.mWidth, this.mHeight, 0, glFormat, glType, null);

	final boolean preMultipyAlpha = this.mTextureOptions.mPreMultiplyAlpha;
	/* Non alpha premultiplied bitmaps are loaded with ARGB_8888 and converted down manually. */
	final Config bitmapConfig = (preMultipyAlpha) ? this.mBitmapTextureFormat.getBitmapConfig() : Config.ARGB_8888;

	final ArrayList<IBitmapTextureAtlasSource> textureSources = this.mTextureAtlasSources;
	final int textureSourceCount = textureSources.size();

	final ITextureAtlasStateListener<IBitmapTextureAtlasSource> textureStateListener = this.getTextureAtlasStateListener();
	for (int i = 0; i < textureSourceCount; i++) {
		final IBitmapTextureAtlasSource bitmapTextureAtlasSource = textureSources.get(i);
		try {
			final Bitmap bitmap = bitmapTextureAtlasSource.onLoadBitmap(bitmapConfig);
			if (bitmap == null) {
				throw new NullBitmapException("Caused by: " + bitmapTextureAtlasSource.getClass().toString() + " --> " + bitmapTextureAtlasSource.toString() + " returned a null Bitmap.");
			}

			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, bitmapTextureAtlasSource.getTextureX(), bitmapTextureAtlasSource.getTextureY(), bitmap, glFormat, glType);
			} else {
				pGLState.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, bitmapTextureAtlasSource.getTextureX(), bitmapTextureAtlasSource.getTextureY(), bitmap, this.mPixelFormat);
			}

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

			bitmap.recycle();

			if (textureStateListener != null) {
				textureStateListener.onTextureAtlasSourceLoaded(this, bitmapTextureAtlasSource);
			}
		} catch (final NullBitmapException e) {
			if (textureStateListener != null) {
				textureStateListener.onTextureAtlasSourceLoadExeption(this, bitmapTextureAtlasSource, e);
			} else {
				throw e;
			}
		}
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:56,代码来源:BitmapTextureAtlas.java

示例8: writeTextureToHardware

@Override
protected void writeTextureToHardware(final GLState pGLState) {
	final PixelFormat pixelFormat = this.mBitmapTextureFormat.getPixelFormat();
	final int glInternalFormat = pixelFormat.getGLInternalFormat();
	final int glFormat = pixelFormat.getGLFormat();
	final int glType = pixelFormat.getGLType();

	GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, glInternalFormat, this.mWidth, this.mHeight, 0, glFormat, glType, null);

	final boolean preMultipyAlpha = this.mTextureOptions.mPreMultiplyAlpha;
	/* Non alpha premultiplied bitmaps are loaded with ARGB_8888 and converted down manually. */
	final Config bitmapConfig = (preMultipyAlpha) ? this.mBitmapTextureFormat.getBitmapConfig() : Config.ARGB_8888;

	final ArrayList<IBitmapTextureAtlasSource> textureSources = this.mTextureAtlasSources;
	final int textureSourceCount = textureSources.size();

	final ITextureAtlasStateListener<IBitmapTextureAtlasSource> textureStateListener = this.getTextureAtlasStateListener();
	for(int i = 0; i < textureSourceCount; i++) {
		final IBitmapTextureAtlasSource bitmapTextureAtlasSource = textureSources.get(i);
		try {
			final Bitmap bitmap = bitmapTextureAtlasSource.onLoadBitmap(bitmapConfig);
			if(bitmap == null) {
				throw new NullBitmapException("Caused by: " + bitmapTextureAtlasSource.getClass().toString() + " --> " + bitmapTextureAtlasSource.toString() + " returned a null Bitmap.");
			}

			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, bitmapTextureAtlasSource.getTextureX(), bitmapTextureAtlasSource.getTextureY(), bitmap, glFormat, glType);
			} else {
				pGLState.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, bitmapTextureAtlasSource.getTextureX(), bitmapTextureAtlasSource.getTextureY(), bitmap, this.mPixelFormat);
			}

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

			bitmap.recycle();

			if(textureStateListener != null) {
				textureStateListener.onTextureAtlasSourceLoaded(this, bitmapTextureAtlasSource);
			}
		} catch (final NullBitmapException e) {
			if(textureStateListener != null) {
				textureStateListener.onTextureAtlasSourceLoadExeption(this, bitmapTextureAtlasSource, e);
			} else {
				throw e;
			}
		}
	}
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:56,代码来源:BitmapTextureAtlas.java


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