Android Question Write bitmap to file

Discussion in 'Android Questions' started by davelt99, Mar 26, 2015.

  1. davelt99

    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,
     
  2. DonManfred

    DonManfred Expert Licensed User

    Have you trie dto use the forum search? I think no. Fault!
     
  3. davelt99

    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,
     
  4. DonManfred

    DonManfred Expert Licensed User

    The first link in the search i posted is this. Here you can see how to write a Bitmap to a file.
     
  5. davelt99

    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.
     
  6. davelt99

    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.
     
    konradwalsh likes this.
  7. DonManfred

    DonManfred Expert Licensed User

    Something like
    Code:
    'save image to file
        Dim out As OutputStream
        out = 
    File.OpenOutput(File.DirRootExternal, "myImage_rotaged.jpg"False)
        imgPreview.Bitmap.WriteToStream(out, 
    100"JPEG")
        out.Close
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice