question: public MosaicJpeg generateFinalMosaic ( boolean highRes ) { int mosaicReturnCode = mMosaicFrameProcessor . createMosaic ( highRes ) ; if ( mosaicReturnCode == Mosaic . MOSAIC_RET_CANCELLED ) { return null ; } else if ( mosaicReturnCode == Mosaic . MOSAIC_RET_ERROR ) { return new MosaicJpeg ( ) ; } byte [ ] imageData = mMosaicFrameProcessor . getFinalMosaicNV21 ( ) ; if ( imageData == null ) { Log . e ( TAG , "getFinalMosaicNV21() returned null." ) ; return new MosaicJpeg ( ) ; } int len = imageData . length - 8 ; int width = ( imageData [ len + 0 ] << 24 ) + ( ( imageData [ len + 1 ] & 0xFF ) << 16 ) + ( ( imageData [ len + 2 ] & 0xFF ) << 8 ) + ( imageData [ len + 3 ] & 0xFF ) ; int height = ( imageData [ len + 4 ] << 24 ) + ( ( imageData [ len + 5 ] & 0xFF ) << 16 ) + ( ( imageData [ len + 6 ] & 0xFF ) << 8 ) + ( imageData [ len + 7 ] & 0xFF ) ; Log . d ( TAG , "ImLength = " + ( len ) + ", W = " + width + ", H = " + height ) ; if ( width <= 0 || height <= 0 ) { Log . e ( TAG , "width|height <= 0!!, len = " + ( len ) + ", W = " + width + ", H = " + height ) ; return new MosaicJpeg ( ) ; } YuvImage yuvimage = new YuvImage ( imageData , ImageFormat . NV21 , width , height , null ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; yuvimage . compressToJpeg ( new Rect ( 0 , 0 , width , height ) , 100 , out ) ; try { out . close ( ) ; } catch ( Exception e ) { Log . e ( TAG , "Exception in storing final mosaic" , e ) ; return new MosaicJpeg ( ) ; } return new MosaicJpeg ( out . toByteArray ( ) , width , height ) ; }
target:  Generate the final mosaic image.