473,394 Members | 1,770 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,394 software developers and data experts.

Convert Byte() to System.Drawing.Image?

Using VB.Net (VS.Net 2k3)...

I'm at a bit of an impasse I think... Is there any way to convert an array
of Byte() into a System.Drawing.Image object without writing the array to a
file, then reading back into the s.d.i object? Couldn't find anything in
MSDN or by Googling...

Thanks!
Jan 20 '06 #1
3 41683
>I'm at a bit of an impasse I think... Is there any way to convert an array
of Byte() into a System.Drawing.Image object without writing the array to a
file, then reading back into the s.d.i object?


Create a MemoryStream around the byte array and call Image.FromStream.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 20 '06 #2
"JackBlack" <ja********@hotmail.com> schrieb
Using VB.Net (VS.Net 2k3)...

I'm at a bit of an impasse I think... Is there any way to convert
an array of Byte() into a System.Drawing.Image object without
writing the array to a file, then reading back into the s.d.i
object? Couldn't find anything in MSDN or by Googling...

dim stream as System.IO.MemoryStream
dim img as image

stream = new System.IO.MemoryStream(bytearray)
img = image.fromstream(stream)
Armin

Jan 20 '06 #3
"JackBlack" <ja********@hotmail.com> schrieb:
I'm at a bit of an impasse I think... Is there any way to convert an
array of Byte() into a System.Drawing.Image object


Create a 'MemoryStream' object, write the byte array to the stream and use
'Image.FromStream' to construct the image. Note that the stream must be
kept open as long as the 'Image' object exists.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 20 '06 #4

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

Similar topics

7
by: Toby Mathews | last post by:
Hi, In an ASP.Net application I want to convert open create a FileStream object from a System.Drawing.Image - is this possible? I create an instance of an Image object using the FromFile method,...
0
by: Roland Moschel | last post by:
Hi ! I have an 2-Dimensional System.Array of byte with Image-Data. How can I create an System.Drawing.Image with this Data ? All the Examples I found are working with MemoryStream(byte), but...
2
by: Josema | last post by:
Hi, I get from database a field of type binary (its a gif image) into byte until here no problem, cause i veryfied that the binary its stored into the byte variable (called arrayb in my...
3
by: anastasia | last post by:
I get an out of memory exception when attempting to excecute the following code: original = System.Drawing.Image.FromFile(file.FileName,true); I ONLY get this exception when the file is in the...
1
by: Mchuck | last post by:
I've seen several newsgroup topics everywhere concerning this, as well as a couple of articles from the MSDN website, but this error still baffles me. It has to do with using the...
2
by: Jeremy | last post by:
I am creating an imaging service using WIA (Windows Imaging Acquisition). The problem is that I cannot convert a WIA.ImageFile to a System.Drawing.Image to put a timestamp on the image without...
5
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
7
by: bookon | last post by:
I was running into the System.Drawing.Image.FromStream "parameter is not valid" on some of the images I was retrieving from a blob column in Sql Server. I thought there were corrupt images as...
3
by: Dave Keen | last post by:
Hi all. Hope you can help me. This should be easy but I can't make this work. In brief I am building a page of thumbnails using images held in a SQLServer 2000 database. I do this by creating...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.