Transfer image from webservice

I need transfer a bitmap from webservice:

01 - create bitmap;
02 - create filestream
03 - return bitmap - stream

Example webservice:
Public Function Image() As Byte()
Dim Imagem As String
Imagem = "C:\Marcos\winxp.gif"
Dim Img As New Bitmap(Imagem)

'here i modify the bitmap

'Here, i need return modify bitmap to application like stream

Marcos A Ferreira







Answer this question

Transfer image from webservice

  • amitdevelopernet

    If you want to send a bitmap via webservices you will need to send it as a byte array (becomes base64 string when serialized).
    To do this:
    The bitmap object has a save method which allows you to save the bitmap to a memory stream:

    Dim stream as new memorystream()
    bitmap.Save (Stream, System.Drawing.ImageFormat)

    the MemoryStream class has a method to return a ByteArray.

    stream.ToArray


    another choice might be to save the bitmap locally and then to return an http:// url to the image which can then be downloaded in binary instead of XML.

  • Transfer image from webservice