2012-04-12 16 views
0

エンジンを解像度1000x1000で初期化し、シーン全体をファイルに保存します。 ScreenCaptureクラスでスクリーンショットを撮ると、画像の最大解像度は800x480です(私のデバイス(htc desire)が800x480で、画面からさらにピクセルを持つことは不可能です)。しかし、シーンが大きくなり、シーンのすべてのピクセルを繰り返し処理し、1000x1000の画像を保存する方法があるかもしれません。シーンのアンドロイドandengineスクリーンショット

私はRenderTextureから画像を保存するために、次のコードを試してみた:

@Override 
public Engine onCreateEngine(EngineOptions pEngineOptions) 
{ 
     return new Engine(pEngineOptions) { 

      private boolean mRenderTextureInitialized; 

      int r[]; 

      private RenderTexture mRenderTextures; 

      @Override 
      public void onDrawFrame(final GLState pGLState) throws InterruptedException { 
       final boolean firstFrame = !this.mRenderTextureInitialized; 

       if(firstFrame) { 
        this.initRenderTextures(pGLState); 
        this.mRenderTextureInitialized = true; 
       } 
       this.mRenderTextures.begin(pGLState); 

       super.onDrawFrame(pGLState); 

       this.mRenderTextures.end(pGLState); 

       if (needToSave) 
       { 
        needToSave = false; 
        final String location = SAVED_PATH + "/Screen_" + System.currentTimeMillis() + ".png"; 
        FSHelper.saveBitmapToFile(mRenderTextures.getBitmap(pGLState), location); 
       } 


      } 

      private void initRenderTextures(final GLState pGLState) { 
       final int surfaceWidth = this.mCamera.getSurfaceWidth(); 
       final int surfaceHeight = this.mCamera.getSurfaceHeight(); 


        this.mRenderTextures = new RenderTexture(EnchantActivity.this.getTextureManager(), surfaceWidth, surfaceHeight); 
        this.mRenderTextures.init(pGLState); 

       } 

     }; 
} 

答えて

1

あなたがレンダリングされていないもののスクリーンショットを取ることができません!

しかし、GLES2ブランチを使用すると、シーンを任意のサイズにできるレンダリングテクスチャにレンダリングできます。この例は役に立ちます:

+0

私はこのサンプルを試しましたが、ボタンを押してシーン全体を保存する方法を理解できません。 getBitmap(GLState)があります。GLStateを保存し、RenderTextureからビットマップをファイルに書き込もうとしました。 – dilix

関連する問題