473,785 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

converting byte[] to image file


Hi

i want to save the read the image file and show it on a image control of
a mobile webform .But the mobile control does not support html images
,so i am forced to use the server image control to show the read image.

i have the image available in a datarow which is read from db. As
control only has the imageurl property ,i need to save the read image to
an image image file and then assign it to the control .

Please tell me
how can i convert the byte[] form of a image to an image file so that
i can assign it to the image control

Thanks
Raghu

Six faces rule the world

*** Sent via Developersdex http://www.developersdex.com ***
Sep 13 '06 #1
3 3023
Just save the byte [] as a temp file and generate the appropriate filename
.... or you could use another page that returns the byte [] directly to
response with a content type appropriate for an image then use a link that
pointed to this page with an appropriate id set in the querystring.

Cheers,

Greg

"Raghu Raman" <ra************ @rediffmail.com wrote in message
news:OQ******** *****@TK2MSFTNG P05.phx.gbl...
>
Hi

i want to save the read the image file and show it on a image control of
a mobile webform .But the mobile control does not support html images
,so i am forced to use the server image control to show the read image.

i have the image available in a datarow which is read from db. As
control only has the imageurl property ,i need to save the read image to
an image image file and then assign it to the control .

Please tell me
how can i convert the byte[] form of a image to an image file so that
i can assign it to the image control

Thanks
Raghu

Six faces rule the world

*** Sent via Developersdex http://www.developersdex.com ***

Sep 13 '06 #2
Greg

Thx that works

FileStream fs=new FileStream(@"c: \abc.jpeg",
FileMode.OpenOr Create,FileAcce ss.ReadWrite);
BinaryWriter w= new BinaryWriter(fs );
w.Write((byte[])dr["Image"]);
w.Close();

Regds
Raghu
Six faces rule the world

*** Sent via Developersdex http://www.developersdex.com ***
Sep 13 '06 #3
What about this?
using (MemoryStream stream = new MemoryStream((b yte[])dr["Image"], false))
pictureBox1.Ima ge = Image.FromStrea m(stream);

"Raghu Raman" <ra************ @rediffmail.com wrote in message
news:e8******** ******@TK2MSFTN GP04.phx.gbl...
Greg

Thx that works

FileStream fs=new FileStream(@"c: \abc.jpeg",
FileMode.OpenOr Create,FileAcce ss.ReadWrite);
BinaryWriter w= new BinaryWriter(fs );
w.Write((byte[])dr["Image"]);
w.Close();

Regds
Raghu
Six faces rule the world

*** Sent via Developersdex http://www.developersdex.com ***

Sep 13 '06 #4

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

Similar topics

8
4568
by: iyuen | last post by:
I'm having problems with converting a byte array to an image object~ My byte array is an picture in VB6 StdPicture format. I've used propertybag to convert the picture into base64Array format in XML, and embedded the array as some child element in an xml file, i.e.: <Mask>bHQAAH4AAABCTX4AAAAAAAAAPgAAACgAAAAQAAAAEAAAAAEAAQAAAAAAQAAAAAAAAAAAAA AA AAAAAAAAAAAAAAAA////AP//AAD//wAA//8AAP//AAD/7wAA//cAALtzAABVeQAAVUAAAFVA...
3
6116
by: Sharon | last post by:
I have a buffer of byte that contains a raw data of a 1 byte-per-pixel image data. I need to convert this buffer to a Bitmap of Format32bppArgb and to a Bitmap of Format24bppRgb. Can anybody tell how to do it? ------ Thanks
3
6660
by: grawsha2000 | last post by:
Hi, I'm trying to convert this simple string into image: Dim bytes() as byte()=System.text.Encoding.ascii.GetBytes("123") Dim memStream as System.IO.MemoryStream Dim img as image memStream.Write(bytes,0.bytes.length)
9
30522
by: Gregory.A.Book | last post by:
I am interested in converting sets of 4 bytes to floats in C++. I have a library that reads image data and returns the data as an array of unsigned chars. The image data is stored as 4-byte floats. How can I convert the sets of 4 bytes to floats? Thanks, Greg Book
3
3693
by: Howler | last post by:
Hello all, I am having a hard time seeing what I am doing wrong with a program I am having to write that converts pbm monochrome images into a similar pgm file. The problem I am having is understanding how to properly convert the bit/pixel in pbm to byte/pixel in pgm. My program is very straight forward conceptually open files, read header, read binary data, convert to p5 in loop and then write file out. My for loop is where I am...
2
10353
by: Laurent Navarro | last post by:
Hello, I am using a library which returns a byte containing RAW data, ie all pixels' color values coded in a byte array without header. I would like to save those data into a JPEG file so I tried to use the MetaFile class. byte data; (...) // Creating the RAW image through the DLL call. MemoryStream memoryStream = new MemoryStream(data);
2
2686
by: Bjorn Sagbakken | last post by:
Hi. This story is about uploading jpg's, then resize them to fixed width or height and storing them to an SQL table. The only way I have found so far is to read the uploaded file to an image-variable, then using the method of creating thumbnails for the resizing. Next, I write this to a temp file on the disk, and read the file back to a byte array in order to insert/update the SQL table. Now, this works well, and even fast enough, no...
2
2314
by: jenniamia | last post by:
I need to make the string "myFile" into a byte and then put it in the database as a file/image, where later it needs to be pulled out and back into a string from the byte. I'm really having trouble gettting it back into a string afterwards, but I don't even know if the data is being put in the database with correct values. Any suggestions or pointers would be much appreciated. Thanks! (I posted the main section I'm having trouble with, but I...
0
2749
by: Sudhagar76 | last post by:
Hi all, I am working on creating ACTIVEX control for smart client application. I need to convert the image avialable in my local folder (C:\Scan\Image.tiff or Image.bmp) into Byte Array. I need to do this convertion in a method, so that i can expose it to those projects consuming my ACTIVEX control.So my input would be filename and output would be Byte Array. I am new to VB6 and really facing very difficult to handle this. Please site me...
0
9489
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10162
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10100
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.