In PreviewCall back of surface we are getting YUV420SP format in camera Preview but due to wrong rotation of that image I want to perform correct rotation of YUV image as I need to send it through network.so correct rotation need to be applied.

I found this link it does correct rotation but image loose the color.

<http://www.wordsaretoys.com/2013/10/25/roll-that-camera-zombie-rotation-and-coversion-from-yv12-to-yuv420planar/>

also checked [Rotate an YUV byte array on Android](https://stackoverflow.com/questions/14167976/rotate-an-yuv-byte-array-on-android?rq=1) but it does not show image properly.

I do have checked links on stckoverflow but none of them have satisfactory answer about correctly using the code in android environment.

do any one have idea how to correctly rotate NV21 Image bytes[] with retaining its color information correctly.