private TinyPlanetImage createTinyPlanet(){
  mResultLock.lock();
  try {
    mResultBitmap.recycle();
    mResultBitmap=null;
    mSourceBitmap.recycle();
    mSourceBitmap=null;
  }
  finally {
    mResultLock.unlock();
  }
  Bitmap sourceBitmap=createPaddedSourceImage(mSourceImageUri,false);
  int width=sourceBitmap.getWidth();
  int height=sourceBitmap.getHeight();
  int outputSize=width / 2;
  Bitmap resultBitmap=Bitmap.createBitmap(outputSize,outputSize,Bitmap.Config.ARGB_8888);
  TinyPlanetNative.process(sourceBitmap,width,height,resultBitmap,outputSize,mCurrentZoom,mCurrentAngle);
  sourceBitmap.recycle();
  sourceBitmap=null;
  ByteArrayOutputStream jpeg=new ByteArrayOutputStream();
  resultBitmap.compress(CompressFormat.JPEG,100,jpeg);
  return new TinyPlanetImage(addExif(jpeg.toByteArray()),outputSize);
}

private TinyPlanetImage createTinyPlanet ( ) { mResultLock . lock ( ) ; try { mResultBitmap . recycle ( ) ; mResultBitmap = null ; mSourceBitmap . recycle ( ) ; mSourceBitmap = null ; } finally { mResultLock . unlock ( ) ; } Bitmap sourceBitmap = createPaddedSourceImage ( mSourceImageUri , false ) ; int width = sourceBitmap . getWidth ( ) ; int height = sourceBitmap . getHeight ( ) ; int outputSize = width / 2 ; Bitmap resultBitmap = Bitmap . createBitmap ( outputSize , outputSize , Bitmap . Config . ARGB_8888 ) ; TinyPlanetNative . process ( sourceBitmap , width , height , resultBitmap , outputSize , mCurrentZoom , mCurrentAngle ) ; sourceBitmap . recycle ( ) ; sourceBitmap = null ; ByteArrayOutputStream jpeg = new ByteArrayOutputStream ( ) ; resultBitmap . compress ( CompressFormat . JPEG , 100 , jpeg ) ; return new TinyPlanetImage ( addExif ( jpeg . toByteArray ( ) ) , outputSize ) ; }
creates the high quality tiny planet file and adds it to the media service . don ' t call this on the ui thread .
