Android Question Write bitmap to file

davelt99

Member
Licensed User
After taking a picture in portrait mode with cameraEx the image is always in landscape mode.

I'm showing a preview with:

Dim imgPreview As ImageView
imgPreview.Initialize("")
imgPreview.Bitmap=RotateImage(LoadBitmap(File.DirRootExternal, sPicName),90)

which corrects the orientation of the jpg file.

I can't figure out how to save the corrected imgView to a file for uploading.

Thanks in advance,
 

davelt99

Member
Licensed User
Yes, but I need to copy the rotated imgView to a file. The imgView is not yet a file. Not sure how this might work,
 

davelt99

Member
Licensed User
I Think that I've been confusing an ImageView bitmap with a bitmap.

' saving the camera picture taken to a file

Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal, "myImage.jpg", False)
out.WriteBytes(Data, 0, Data.Length)
out.Close


dim imgPreview as ImageView
imgPreview.Initialize("")
imgPreview.Bitmap=RotateImage(LoadBitmap(File.DirRootExternal, "myImage.jpg"),90)

' now this rotated image, imgPreview.Bitmap, I would like to save to the original filename - "myImage.jpg"

Sorry for the confusion.
 

davelt99

Member
Licensed User
I found It!!

Had to store ImageView.Bitmap to a Bitmap first and then write to the outputstream.
Dim b As Bitmap
b = imgPreview.Bitmap

Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal, sPicName, False)
b.WriteToStream(Out, 100, "JPEG")
Out.Close

Thank you for your assistance - I'll try to search more diligently in the future.
 
Top