473,320 Members | 2,054 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,320 software developers and data experts.

picture file in XML

VJ
I am looking for ways to store a picture file as a data element in a XML
file. Is the below the best option available, to convert a picture file to
string format..

string data = null;
Bitmap bmp = new Bitmap(@"e:Image.bmp");
using (MemoryStream mem = new MemoryStream())
{
bmp.Save(mem, System.Drawing.Imaging.ImageFormat.Bmp);
//Convert the bytes to a string.
data = Convert.ToBase64String(mem.ToArray());
}

VJ
Nov 16 '05 #1
4 1827
VJ,

Pretty much. The only option you have now is to convert the bytes into
a text format, and then embed that text in your XML.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"VJ" <vi********@yahoo.com> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
I am looking for ways to store a picture file as a data element in a XML
file. Is the below the best option available, to convert a picture file to
string format..

string data = null;
Bitmap bmp = new Bitmap(@"e:Image.bmp");
using (MemoryStream mem = new MemoryStream())
{
bmp.Save(mem, System.Drawing.Imaging.ImageFormat.Bmp);
//Convert the bytes to a string.
data = Convert.ToBase64String(mem.ToArray());
}

VJ

Nov 16 '05 #2
One problem with this is that the binary data might convert to characters
outside of the standard ASCII range (i.e. control characters). Some control
characters are not valid within an XML document.

But normally when you want to store binary data in a text format, Base64
encoding is usually the way to go.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:O7**************@TK2MSFTNGP09.phx.gbl...
VJ,

Pretty much. The only option you have now is to convert the bytes into a text format, and then embed that text in your XML.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"VJ" <vi********@yahoo.com> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
I am looking for ways to store a picture file as a data element in a XML
file. Is the below the best option available, to convert a picture file to string format..

string data = null;
Bitmap bmp = new Bitmap(@"e:Image.bmp");
using (MemoryStream mem = new MemoryStream())
{
bmp.Save(mem, System.Drawing.Imaging.ImageFormat.Bmp);
//Convert the bytes to a string.
data = Convert.ToBase64String(mem.ToArray());
}

VJ


Nov 16 '05 #3
Sorry, I should have clarified, I didn't mean directly into text, but
rather, a text format which accounts for something like this (like base 64).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:OS**************@TK2MSFTNGP12.phx.gbl...
One problem with this is that the binary data might convert to characters
outside of the standard ASCII range (i.e. control characters). Some control characters are not valid within an XML document.

But normally when you want to store binary data in a text format, Base64
encoding is usually the way to go.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:O7**************@TK2MSFTNGP09.phx.gbl...
VJ,

Pretty much. The only option you have now is to convert the bytes into
a text format, and then embed that text in your XML.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"VJ" <vi********@yahoo.com> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
I am looking for ways to store a picture file as a data element in a XML file. Is the below the best option available, to convert a picture
file to string format..

string data = null;
Bitmap bmp = new Bitmap(@"e:Image.bmp");
using (MemoryStream mem = new MemoryStream())
{
bmp.Save(mem, System.Drawing.Imaging.ImageFormat.Bmp);
//Convert the bytes to a string.
data = Convert.ToBase64String(mem.ToArray());
}

VJ



Nov 16 '05 #4
On Tue, 4 May 2004 14:43:41 -0500, "VJ" <vi********@yahoo.com> wrote:
I am looking for ways to store a picture file as a data element in a XML
file. Is the below the best option available, to convert a picture file to
string format..

string data = null;
Bitmap bmp = new Bitmap(@"e:Image.bmp");
using (MemoryStream mem = new MemoryStream())
{
bmp.Save(mem, System.Drawing.Imaging.ImageFormat.Bmp);
//Convert the bytes to a string.
data = Convert.ToBase64String(mem.ToArray());
}


You could convert the file to SVG, it is an Xml image format
specifically designed for embedding.

There are a number of converts out there, don't know if there are .Net
ones yet.

Vin
Nov 16 '05 #5

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

Similar topics

3
by: Trevor Fairchild | last post by:
I am making a program that categorizes pictures. The picture paths are stored in an Access Database, vb6 connects using adodc controls. This program works specifically with .jpg files. It will be...
10
by: Chris Coho, Jr. | last post by:
Ok, I'll explain the whole problem because there may be several ways to solve this and hopefully someone knows one. What I'm doing is creating a specialty template editor, similar to say a corel...
4
by: DraguVaso | last post by:
Hi, In my application I receive a Byte Stream (Dim bytFile() As Byte) which contains a jpeg-picture, which I want to display in a picturebox. I want to display it directly from the bytfile()...
2
by: Lyn | last post by:
I am trying to embed a picture into a Bound Object Frame (Me!Photograph) with the following code which is based on MS article http://support.microsoft.com/?id=158941: strPathname =...
2
by: zheng | last post by:
ÇçÌì I have a word document and it has a picture object, I want save the picture object as other single picture file by C# program. I have a idea, by clipboard, copy the picture to clipboard, and...
4
by: NASAdude | last post by:
I'm working on distributing a database using VS Tools for Office, and am having trouble with linked images on forms/reports. The image objects have a default path\file set on the .Picture property,...
3
by: Jim S. | last post by:
ok, am trying to do a picture preview before i upload a picture, but i have a tiny problem , it used to work but, not anymore. here is the partial code (u do not need more to find the problem):...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
1
by: ApexData | last post by:
I have an ImageBox with PictureType set to LINK. I have a string with a path strPicFolderPath = "C:\Pictures" In the OnCurrent event of the form I have this code: If...
13
by: bytesc | last post by:
Hey guys, I have created many picture files using gd_library, I recently decided to rename all of my pictures files on my web server to text instead of just numbers. Example: productsssh.jpg ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.