Writing Mat from AndroidBitmapGetPixels saves black image

I was able to save it as png while running java code separately and image looks fine. Can you tell me what piece I am missing to not include pixels as part of bitmap? May be I am wrong