473,378 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Conversion issue: Image>Byte array>Image

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.
Nov 19 '05 #1
2 1511
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.

Nov 19 '05 #2
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.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Henri Schomaecker | last post by:
Hi again, as I already wrote, I'm trying to get image binary data into a var holding an unsigned char string and then print it directly to the browser. I now already did some tries with an array...
3
by: Csaba Gabor | last post by:
When I click on the image form element <INPUT type=image name=point src="map.png"> point.x and point.y values get submitted to the server specifying where on the image I have clicked. Is there...
2
by: skavan | last post by:
Hi, Trying to wrap my head around the following problem. Let's say I have a 2 dimensional array: Dim arrS(3,4) As String I want to copy the subarray arrS(0,) to a new array arrLoop(4) As...
0
by: Matteo | last post by:
Hi, i sent image byte via bt from j2me phone to c# application, after i have to create image using this code: .... byte pixels .... Bitmap bmp = new Bitmap(160, 120,...
4
by: Rainer Queck | last post by:
Hi NG, is there a way to copy a buffer pointed to by a IntPtr directly into a two dimensional byte-array? I tried this, what obviously doesn't work: byte image = new byte; IntPtr p =...
5
by: Steve JORDI | last post by:
Just a question using images as submit buttons and PHP4.4.4. It seems that my code correctly works in FireFox but not in IExplorer. For example, I have a FORM with 2 buttons called "search" and...
3
by: Jason B | last post by:
Hi all, I'm somewhat new to Python and I'm trying to figure out the best way to accomplish the following: From an array of pixel data in an XML file (given the format, width and height of the...
3
by: Bimawen | last post by:
Hi, I tried to grab an image from the internet, forexample from www.microsoft.com/image1.jpg, by using WinHttp. but WinHttp.ResponseBody is a byte, so when I tried to show them back to my...
2
by: Casey | last post by:
I'm doing some image processing that requires accessing the individual pixels of the image. I'm using PIL 1.1.6 and creating a 2D array of pixel RGB tuples using the Image class instance load()...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.