private Bitmap decodePreview(BitmapSource source,int targetSize){
  Bitmap result=source.getPreviewBitmap();
  if (result == null) {
    return null;
  }
  float scale=(float)targetSize / (float)(Math.max(result.getWidth(),result.getHeight()));
  if (scale <= 0.5) {
    result=BitmapUtils.resizeBitmapByScale(result,scale,true);
  }
  return ensureGLCompatibleBitmap(result);
}

private Bitmap decodePreview ( BitmapSource source , int targetSize ) { Bitmap result = source . getPreviewBitmap ( ) ; if ( result == null ) { return null ; } float scale = ( float ) targetSize / ( float ) ( Math . max ( result . getWidth ( ) , result . getHeight ( ) ) ) ; if ( scale <= 0.5 ) { result = BitmapUtils . resizeBitmapByScale ( result , scale , true ) ; } return ensureGLCompatibleBitmap ( result ) ; }
note that the returned bitmap may have a long edge that ' s longer than the targetsize , but it will always be less than 2x the targetsize
