Conversion issue: Image>Byte array>Image

Discussion in 'ASP .Net' started by =?Utf-8?B?RGVhc3Vu?=, Jul 14, 2005.

  1. Heres the code I have:

    Dim objTheStream As MemoryStream = New MemoryStream
    Dim objPhoto As Image = pic_PhotoToUpload.Image()
    With objPhoto
    .Save(objTheStream, System.Drawing.Imaging.ImageFormat.Jpeg)
    End With
    Dim objByteToSend(objTheStream.Length) As Byte
    objByteToSend = objTheStream.ToArray()

    Dim objPhoto2 As Image
    Dim objTheStream2 As MemoryStream = New
    MemoryStream(objByteToSend, 0, objByteToSend.Length)
    objTheStream2.Write(objByteToSend, 0,
    objByteToSend.Length)
    objPhoto2.FromStream(objTheStream, True)

    Why does objPhoto2 = nothing after that last line ?

    Thanks
    Deasun
    --
    Deasun
    Home Site: www.tirnaog.com
    Check out: The Code Vault in my forums section.
     
    =?Utf-8?B?RGVhc3Vu?=, Jul 14, 2005
    #1
    1. Advertising

  2. Don't you want to be calling stream2 there?

    Jason Lind

    "Deasun" wrote:

    > Heres the code I have:
    >
    > Dim objTheStream As MemoryStream = New MemoryStream
    > Dim objPhoto As Image = pic_PhotoToUpload.Image()
    > With objPhoto
    > .Save(objTheStream, System.Drawing.Imaging.ImageFormat.Jpeg)
    > End With
    > Dim objByteToSend(objTheStream.Length) As Byte
    > objByteToSend = objTheStream.ToArray()
    >
    > Dim objPhoto2 As Image
    > Dim objTheStream2 As MemoryStream = New
    > MemoryStream(objByteToSend, 0, objByteToSend.Length)
    > objTheStream2.Write(objByteToSend, 0,
    > objByteToSend.Length)
    > objPhoto2.FromStream(objTheStream, True)
    >
    > Why does objPhoto2 = nothing after that last line ?
    >
    > Thanks
    > Deasun
    > --
    > Deasun
    > Home Site: www.tirnaog.com
    > Check out: The Code Vault in my forums section.
     
    =?Utf-8?B?SmFzb24gTCBMaW5k?=, Jul 14, 2005
    #2
    1. Advertising

  3. thanks for the reply.
    Just had to make objPhoto2 = objPhoto2.FromStream(objTheStream, True)
    And it works. :)

    --
    Deasun
    Home Site: www.tirnaog.com
    Check out: The Code Vault in my forums section.


    "Jason L Lind" wrote:

    > Don't you want to be calling stream2 there?
    >
    > Jason Lind
    >
    > "Deasun" wrote:
    >
    > > Heres the code I have:
    > >
    > > Dim objTheStream As MemoryStream = New MemoryStream
    > > Dim objPhoto As Image = pic_PhotoToUpload.Image()
    > > With objPhoto
    > > .Save(objTheStream, System.Drawing.Imaging.ImageFormat.Jpeg)
    > > End With
    > > Dim objByteToSend(objTheStream.Length) As Byte
    > > objByteToSend = objTheStream.ToArray()
    > >
    > > Dim objPhoto2 As Image
    > > Dim objTheStream2 As MemoryStream = New
    > > MemoryStream(objByteToSend, 0, objByteToSend.Length)
    > > objTheStream2.Write(objByteToSend, 0,
    > > objByteToSend.Length)
    > > objPhoto2.FromStream(objTheStream, True)
    > >
    > > Why does objPhoto2 = nothing after that last line ?
    > >
    > > Thanks
    > > Deasun
    > > --
    > > Deasun
    > > Home Site: www.tirnaog.com
    > > Check out: The Code Vault in my forums section.
     
    =?Utf-8?B?RGVhc3Vu?=, Jul 14, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bharat Bhushan

    Appending byte[] to another byte[] array

    Bharat Bhushan, Aug 5, 2003, in forum: Java
    Replies:
    15
    Views:
    40,453
    Roedy Green
    Aug 5, 2003
  2. Kirby
    Replies:
    3
    Views:
    678
    Kirby
    Oct 8, 2004
  3. Replies:
    20
    Views:
    9,941
    licebmi
    Sep 7, 2009
  4. Tom McGlynn
    Replies:
    4
    Views:
    889
    Mark Space
    Apr 19, 2008
  5. Patricia Shanahan
    Replies:
    0
    Views:
    415
    Patricia Shanahan
    Apr 17, 2008
Loading...

Share This Page