Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Embed graphic file directly in a script ?

Status
Not open for further replies.

tystent

Programmer
Jan 25, 1999
15
0
0
US
Is there a way in Javascript (or HTML) to embed graphic file data (a BLOB) directly into the code, rather than referencing an external file? I know this goes against the grain of the modularity of normal HTML/JS programming, but I'm still interested... This would be akin to embedding blobs in XML files, like .resx files.
 
Thanks Dan, that thread is an interesting discussion. [I also found a related pixel-drawing discussion from Edward (How do I display graphics using JavaScript? faq216-3516, Apr 03) which has other interesting suggestions on drawing directly to a graphics image.]

I too am interested in an all-in-one HTML file that doesn't link to any outside files, for a very particular client.

Interesting update on your sample graphic file formats: XBM (suggested for IE) is also recognized by recent versions of Netscape and Firefox, but the GIF (suggested for NN) is still not recognized by IE. Big surprise there. Maybe I'll play around with the GIF to try to nudge IE into recognizing it, or maybe look for another file format that can be read by both...
 
So, I tried BMP and JPG and PNG formats, and Netscape 7.2 recognizes both, but IE 6 does not. Neither one recognized TIF. IE still only recognizes XBM, that crazily inefficient C-code, monochrome format. I even tried a simple XPM file, supposedly derived from XBM but for color images, but neither browser recognized it, which isn't surprising considering how few OS's and viewers do.
 
Ah well - I guess MS never saw a need to create images dynamically from script (or saw it as a potential security risk, with malformed image data potentially causing buffer overflows, etc).

One thing to note: With IE & XBMs, you can get these to be 2-colour (other than black and white) by using filters, so they are good for the most basic icons. This still may not be enough for your needs, however.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top