http://www.b4x.com/android/forum/threads/from-camera-to-imageview.8952/#post-49800Instead of setting the bitmap with Imageview.Bitmap=, try using Imageview.background=bd. Of course first you need to Dim bd as BitmapDrawable and then bd.Initialize with the JPG you took from camera. Then only set Imageview.background=bd
Inman, May 2, 2011
Hello,
I found the previous post from long ago. This is exactly what I want to do, but I'm lost on the bd.initialize step.
I'm using Erel's Camera and CameraEX examples. He has the Sub:
B4X:
Sub Camera1_Preview (PreviewPic() As Byte)
If DateTime.Now > lastPreviewSaved + IntervalMs Then
Dim jpeg() As Byte = camEx.PreviewImageToJpeg(PreviewPic, 70)
lastPreviewSaved = DateTime.Now
CallSubDelayed2(Communicator, "Send", jpeg)
End If
End Sub
Basically he ends up with the byte array named jpeg. This is a compressed representation of the bitmap from the camera preview. I plan to send this data to another android device, then I would like to show the JPEG in an ImageView.Bitmap or Panel.Background. I would prefer to use the byte array – not working via files as an interim step.
So you have the byte array jpeg(). Somehow you want to initialize a bitmap or bitmap drawable from the byte array:
bd.initialize(??? what ???)
I have a feeling an input stream from bytes will be in there somewhere, but I just can't seem to make the full connection.
Any help?
Thanks,
Barry.