제 어플리케이션의 경우 텍스처가 고해상도입니다.텍스처 크기 줄이기
@Override
public void onLoadResources(){
Options options = new BitmapFactory.Options();
options.inScaled = false;
// calculation inSampleSize
int sm = 1;
if (cameraWidth+cameraHeight < 1280) sm = 2;// < 800x480
if (cameraWidth+cameraHeight < 800) sm = 4;// < 480x320
options.inSampleSize = sm;
mTexture = new BitmapTextureAtlas(2048/sm, 2048/sm, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
// Loading bitmap
sky_bm = BitmapFactory.decodeResource(getResources(), R.drawable.sky, options);
sky_src = new BitmapTextureAtlasSource(sky_bm);
skyRegion = TextureRegionFactory.createFromSource(mTexture, sky_src, 0, 0, false);
mEngine.getTextureManager().loadTexture(mTexture);
BitmapTextureAtlasSource 코드 : 작은 화면의 크기를 줄이기 위해 내가 그렇게 할
public class BitmapTextureAtlasSource extends BaseTextureAtlasSource implements IBitmapTextureAtlasSource {
private Bitmap mBitmap;
public BitmapTextureAtlasSource(Bitmap pBitmap) {
super(0,0);
//this.mBitmap = pBitmap;
this.mBitmap = pBitmap.copy(Bitmap.Config.ARGB_8888, false);
}
public int getWidth() {
return mBitmap.getWidth();
}
public int getHeight() {
return mBitmap.getHeight();
}
@Override
public BitmapTextureAtlasSource clone() {
return new BitmapTextureAtlasSource(Bitmap.createBitmap(mBitmap));
}
public Bitmap onLoadBitmap(Config pBitmapConfig) {
return mBitmap;
}
@Override
public IBitmapTextureAtlasSource deepCopy() {
return null;
}
}
그러나 화면을 회전시킬 때, 나는 오류 얻을 :
FATAL EXCEPTION: GLThread 4895
java.lang.IllegalArgumentException: bitmap is recycled
at android.opengl.GLUtils.texSubImage2D(GLUtils.java:220)
at org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas.writeTextureToHardware(BitmapTextureAtlas.java:162)
at org.anddev.andengine.opengl.texture.Texture.loadToHardware(Texture.java:116)
at org.anddev.andengine.opengl.texture.TextureManager.updateTextures(TextureManager.java:146)
at org.anddev.andengine.engine.Engine.onDrawFrame(Engine.java:507)
at org.anddev.andengine.opengl.view.RenderSurfaceView$Renderer.onDrawFrame(RenderSurfaceView.java:154)
at net.rbgrn.opengl.GLThread.guardedRun(GLThread.java:235)
at net.rbgrn.opengl.GLThread.run(GLThread.java:94)
말해주십시오 내가 뭘 잘못하고있어. 어떤 정보에 대해서도 감사 할 것입니다.
내가 문제가 BitmapTextureAtlasSource에있을 수 있습니다 생각합니다. 코드를 게시 할 수 있습니까? –
다른 질문은 2048x2048의 BitmapTextureAtlas를 사용하는 것입니다. 심지어 일부 고급 장치는 그 문제에 대해 불평 할 수 있습니다. – jmroyalty