Sub Camera1_Preview (PreviewPic() As Byte)
'prevent queued events from previous camera settings, if any. Just in case
If PreviewPic.Length<>(3*myBitmap.Width*myScale*myBitmap.Height*myScale/2) Then
Log("Not processing")
Return
End If
If flg_take_picture=True Then 'Set it to true externally when you want to take a preview picture
flg_take_picture=False
NV21toRGB.proceed( PreviewPic, myBitmap.Width*myScale, myBitmap.Height*myScale, myScale, myBitmap, camVertical , camEx.Front, camEx.DispRotation, myIndexEffect )
Dim b2 As Bitmap
' Call these two lines if you want the bitmap to be saved with the same dimensions as the preview panel
b2=ScaleToPanelDims( myBitmap)
SaveBitmap(b2,File.DirRootExternal,"test.jpg")
'Otherwise, if you want to save with the original preview width and height, just call this
'SaveBitmap(myBitmap,File.DirRootExternal,"test.jpg")
End If
End Sub