Android Question How to convert bitmap to byte[] ?

Discussion in 'Android Questions' started by fash866, Apr 14, 2015.

  1. fash866

    fash866 Member Licensed User

    Hi!
    I used LoadBitmapSample to comprees a photo,and want to upload the compressed photo to http server , but httpUtils2 only support post bytes,is there any way to convert bitmap to byte[]?

    Or, is ther other way to compress a photo and upload it ?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Dim out As OutputStream
    out.InitializeToBytesArray(
    0)
    bmp.WriteToStream(out, 
    100"PNG")
    out.Close
    Dim data() As Byte = out.ToBytesArray
     
    DonManfred and Peter Simpson like this.
  3. fash866

    fash866 Member Licensed User

    It's ok now, thanks !
     
  4. Ganiadi

    Ganiadi Member Licensed User

    Can anybody help,

    Im trying to get image file from tab and send it to the desktop server written using vb6.

    What im doing is convert the image to byte array and send it using socket stream
    astream.Write(data)

    Problem:
    My desktop server received the data correctly, but when i open the image file is corrupted.
    It seems the structure is incorrect.


    Tks
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
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