473,730 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Store Image inside XML

Hi,

I need to store an image from a Graphics object(.NET) inside a xml
data island. Anyone might have came accross or have an idea how to do
this. Please share.

Thanks & Regards,
Raghu, CSS India
+91 98402 56561

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
10 26192
Raghavendra RAV wrote:
I need to store an image from a Graphics object(.NET) inside a xml
data island. Anyone might have came accross or have an idea how to do
this. Please share.


XML doesn't support storing binary data directly, use Base64 encoding
(e.g. use XmlTextWriter.W riteBase64() method).

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
Hi Oleg,

Thanks for the reply.

It is correct that XML doesnt support binary data. If i manage to
store image inside xml, pls suggest me how can i get the image back on
my web page (possibly using xslt).

Also if possible pls suggest me how to save image in Graphics object
of .NET to base64 data.
Thanks and Regards,
Raghu, CSS India
+91 94440 37040

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
> Also if possible pls suggest me how to save image in Graphics object
of .NET to base64 data.


Have a look at
Convert.ToBase6 4String
Regards,

Victor
Nov 12 '05 #4
Raghavendra RAV wrote:
It is correct that XML doesnt support binary data. If i manage to
store image inside xml, pls suggest me how can i get the image back on
my web page (possibly using xslt).
XML is text based format. So to store binary data in it you must encode
it. Usually Base64 encoding is used. When you put image to XML - encode
it (e.g. using XmlTextWriter.W riteBase64() method).
When you read XML, you need to decode image (e.g. using
XmlTextReader.R eadBase64() method).
Also if possible pls suggest me how to save image in Graphics object
of .NET to base64 data.


Basically XML API can handle it itself, but if you want take over - use
Convert.ToBase6 4String()/Convert.FromBas e64String() methods.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #5
> It is correct that XML doesnt support binary data. If i manage to
store image inside xml, pls suggest me how can i get the image back on
my web page (possibly using xslt).


.... I think that there is no "direct" way to embedd the image into a web
page after you've decoded it from Base64.

What happens when a browser reads an html file is that it makes an
additional request for every image it finds defined inside the html code -
they're two different files on the web server, and two different http calls
from the browser.

So, I think it's gonna be *difficult* to use xslt or any other medioum and
"embed" the image inside the html.
( of course I'm not an HTTP expert, but I've been working on web sites for
years and have never come across html that contains the full image data
instead of a link to the actual source of the image :? ... )

Of course, nothing prevents you from actually saving the image on the file
system, and just modifying your html link src to point to the right file on
the web server - although that would be A LOT of reading/writing to the disk
and I'd try to avoid it at all costs ...

Angel
O:]
Nov 12 '05 #6
Actually you can display base-64 images inline, using the data url format -
see the spec. at http://www.ietf.org/rfc/rfc2397.txt .

You'd have to use xslt to convert the xml to something in the format
<IMG SRC="data:image/gif,base64;[...]">where the [...] contains your base-64
string.The only issue with this is the size limit on HTML tags, which is
usually 1,024 bytes. This inline data url method is only meant for very
small amounts of data.Hugo Rodger-Brownhttp://hugo.rodger-brown.com
Nov 12 '05 #7
Hi Brown,

Exactly this kind of this is what i was expecting. Thank you so much
for ur reply. I am yet to test this and if i get any issues i may need
ur help.

Thanks,
Raghu, CSS India
+91 94440 37040

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #8
Well, I stand corrected ! Thanks for the post Hugo, that was something I'd
never seen before, and it's certainly useful in many cases. Do you happen to
know when support for this became commonplace ? I'm afraid that I left html
guis a few years ago and .. god, am i obsolete ?!??!?

Cheers,
Angel
O:]

"Hugo Rodger-Brown" <hu**@coldhams. com> wrote in message
news:eG******** ******@TK2MSFTN GP11.phx.gbl...
Actually you can display base-64 images inline, using the data url format - see the spec. at http://www.ietf.org/rfc/rfc2397.txt .

You'd have to use xslt to convert the xml to something in the format
<IMG SRC="data:image/gif,base64;[...]">where the [...] contains your base-64 string.The only issue with this is the size limit on HTML tags, which is
usually 1,024 bytes. This inline data url method is only meant for very
small amounts of data.Hugo Rodger-Brownhttp://hugo.rodger-brown.com

Nov 12 '05 #9
Hugo Rodger-Brown wrote:
Actually you can display base-64 images inline, using the data url format -
see the spec. at http://www.ietf.org/rfc/rfc2397.txt .

You'd have to use xslt to convert the xml to something in the format
<IMG SRC="data:image/gif,base64;[...]">where the [...] contains your base-64
string.The only issue with this is the size limit on HTML tags, which is
usually 1,024 bytes. This inline data url method is only meant for very
small amounts of data.Hugo Rodger-Brownhttp://hugo.rodger-brown.com


Of course it should be mentioned IE doesn't support this cool stuff.
Another option to give a shot is MHT format, but I never tried that.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #10

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

Similar topics

3
13388
by: Karen Grube | last post by:
Hi! Each week, we receive a two-page PDF file from UPS along with a separate flat file (a CSV) The PDF file contains the overview of our weekly invoice and the CSV contains the details of each shipment. I download the file from UPS and then use DTS to import the data into SQL. At that point, I have a Crystal report that prints what looks like a regular UPS invoice. The only problem is that I wind up with having to print two...
6
1917
by: Rudy | last post by:
Hello all! I am amazed how many posts I have read to store an image in SQL, and just as many against it. So I learned how to store an image in a SQL db and retrieve the image. A little tricky, but not too bad. But then I thought I wanted to try the other way, by putting the file location in SQL and storing the actual image in another directory. I plan to have many images on my web application, up to as many as 5000. Not to mention the...
5
10632
by: moondaddy | last post by:
I'm caching a dataset in an asp.net session variable to hold a user's data. one data item I need to store is an image the user uploaded. My problem is that I don't know how to get the image into the dataset because I don't know what datatype to set the dataset column and then set this image to. I saw an example where someone defended a datatable in the global class and defined the column as an object, however, when I define a strongly...
2
2351
by: wschanks | last post by:
I have an .adp (Access 2003) file and I need to store files in a field on the database. I have figured out that I need the data type to be 'Image', so I have my table with the this datatype. I can't figure out how to upload/store files (.bmp, .doc, .xls, etc) in this field. I have been searching books online, and google groups all day. Maybe my
2
2981
by: sachaburnett | last post by:
Hi everyone! I'm new to Javascript and am finding so much useful information on this group, so thanks to you all! I have a question about preloading images for onmouseover/out effects and found so many different ways to do it on the Net but am not sure about something. Right now I have the following code inside my <head> tag:
0
1824
by: wizardworkz | last post by:
Hello All! Having a bit of a problem combining php with javascript here. What I have is a store with images (There will be a smaller image of each item, and a larger image of each item, but I want users to click on a link under the image shown (Smaller image) for a popup window showing a larger image. I have already setup an additional table line named "image2" and want the image be puleed from the db (images folder) to pop up to a window...
4
1403
by: =?Utf-8?B?YWxiZXJ0b3Nvcmlh?= | last post by:
Hi everydoby! I have an issue, I have an static image, and I need to write text inside it in runtime, but I don't know how! I can't use absolute position in atributtes style. Thanks.
1
4082
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two hotspots on the image. One being correct(a) and the other incorrect(b). When the user clicks on the correct hotspot or place on the image, it should score and retain that value until the end of the quiz. At the end of the quiz, there is a submit button...
8
15893
meenakshia
by: meenakshia | last post by:
hi i m not sure but wanted to use a variable to store an image and then show it inside the table something like var img1; img1="c:\myself.jpg"; and inside the table it shows like <table> <td>img1</td>
0
8943
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9300
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
9229
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
9176
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
8182
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6725
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6029
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
4542
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
4801
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.