Pictures

F

freesoft_2000

Hi everyone,

I am trying to add pictures into a html document and so
far everthing has been going well but i have a question. Wen i insert the
pictures into the html document they show up and i am able to save them to
disk in html format.


The thing is when i delete the picture on the disk and
read the html document the picture does not show up but if the picture is
not deleted from the disk then when i read the html document the picture
shows up.

Basically what i need to know if there is a way in
which i can embed a picture into the html document without any reliance on
the picture that is saved on a different location on the disk.

For example if the Styled Document is serialized with an
embedded picture even if the picture is deleted from the disk when the
Styled Document is read the picture is not there but this is not so for
the HTML Document class.

Basically my question is that is it possible to
implement something like that in which that the picture is embedded in the
HTML Document and it does not matter if the picture is deleted or not from
the disk thus even when the html document is read the embedded picture is
still there.

This is what i am doing to insert the picture into the HTML Document
Note that the file name of the picture is converted to a URL and the Html
Tag there always depend on the file name with the picture being there

FileChooser3.setDialogType(JFileChooser.OPEN_DIALOG);
FileChooser3.setDialogTitle("Select a picture to insert into document");

if(FileChooser3.showDialog(fr,"Insert") != JFileChooser.APPROVE_OPTION)
{
return;
}

File g = FileChooser3.getSelectedFile();
ImageIcon image1 = new ImageIcon(g.toString());

MutableAttributeSet mas1 = new SimpleAttributeSet();
//The below command line gets the width and height of the image

int w = image1.getIconWidth();
int h = image1.getIconHeight();

try
{
//The below six command line insertss the currently read in image into
//the JTextPane

mas1.addAttribute(StyleConstants.NameAttribute, HTML.Tag.IMG);
//The below command line is where the reliance occurs

mas1.addAttribute(HTML.Attribute.SRC, g.toURL().toString());
mas1.addAttribute(HTML.Attribute.HEIGHT, Integer.toString(h));
mas1.addAttribute(HTML.Attribute.WIDTH, Integer.toString(w));
int p = TextPane1.getCaretPosition();
htmldoc.insertString(p, " ", mas1);
}

catch(Exception e)
{
e.printStackTrace();
}

please note that htmldoc is an instance of the Java HTMLDocument class and
TextPane1 is an instance of the Java JTextPane class

This is its HTMl equivalent that is generated in the html document

<html>
<head>
</head>
<body>
<p>
<img height="400" width="400" src="file:/D:/Sample_Pics/venu.jpg">
</p>
</body>
</html>

See the reliance on the picture picture always being on that location on
the disk on this line

src="file:/D:/Sample_Pics/venu.jpg"

Is there a way to achieve what i need by simple ways or style sheets or
any other way??

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
A

Andrew Thompson

What other group?

The other group to which the OP multi-posted.

I would normally ask the poster *not* to multi-post, on
*one* of the groups, and direct them the the 'X-Post'
link ay my site. But this person has consistently not
taken the hint.

To ..Richard. You seem to not get subtle hints,
so I will be blunt.

If you continue to multi-post across the comp.lang.java.*
technical groups, I will make a point of forewarning other
posters that you are doing so, on every group that I observe
it. They still might help you, but it is less likely.

*Please* refrain from multi-posting. When posting, choose
*one* group to which to make your post, and leave it at that.
 
J

Joan

freesoft_2000 said:
Hi everyone,
Basically what i need to know if there is a way in
which i can embed a picture into the html document without any reliance on
the picture that is saved on a different location on the disk.

<snip>

It is possible because Microsoft Outlook Express does it. They embed a
base64 coded version of the picture right in the html. I don't know how.
If you look at such an email and do some searching you can figure it out.

p.s. you have to use "insert picture" and "Rich Text" format, do not make
it an attachment.
 
R

Raymond DeCampo

Joan said:
<snip>

It is possible because Microsoft Outlook Express does it. They embed a
base64 coded version of the picture right in the html. I don't know how.
If you look at such an email and do some searching you can figure it out.

p.s. you have to use "insert picture" and "Rich Text" format, do not make
it an attachment.
Embedding in an e-mail is not the same as embedding in an HTML file.

The way an e-mail message would do it is to have a multipart format with
the HTML and the image being separate parts.

Ray
 
J

Joan

Raymond DeCampo said:
Embedding in an e-mail is not the same as embedding in an HTML file.

The way an e-mail message would do it is to have a multipart format with
the HTML and the image being separate parts.
Then you need to rewrite your question which stated
"...saved on a different location on the disk..."
All of the parts I mentioned are in the same file.
 
R

Raymond DeCampo

Joan said:
Then you need to rewrite your question which stated
"...saved on a different location on the disk..."
All of the parts I mentioned are in the same file.

A number of points:

1. I did not posit the original question.
2. The OP wanted to embed pictures in an HTML document, not a different
format, e.g. a multipart e-mail message. I believe the OP wants
something that is handled by browsers and/or JEditorPane without tweaking.
3. Whether or not the parts of an e-mail message are in the same "file"
is an implementation detail of your e-mail client and/or server. I
think if you look at some of the common e-mail client formats, you will
see that every message in a particular folder is actually in the same file.

Ray
 
V

Virgil Green

Andrew said:
The other group to which the OP multi-posted.

Yeah... so WHICH ONE WAS IT? I want to see the thread and don't want to go
hunting through groups to find it.
 
F

freesoft_2000

Hi everyone,

I noticed that the the Java HTML class has a tag called
HTML.TAG.EM
Does the EM tag by any chance actually mean the html embed tag or does it
mean something else in Java??

If the EM is the html embed tag then how would i go about
using it to embed the image??

Sample codes would be helpfull

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West

ps. I am the OP
 
A

Andrew Thompson

Yeah... so WHICH ONE WAS IT?

....hmm. I was working under the misapprehension that a
simple Google would reveal all, but ..apparently not.

This search is specific to c.l.j.gui.
<http://groups-beta.google.com/groups?q=pictures+serialized+group:comp.lang.java.gui>
...it only finds the c.l.j.gui post.

This search *should* show both, but only shows the c.l.j.p. post.
<http://groups-beta.google.com/groups?q=pictures+serialized+group:comp.lang.java.*>
While this alternate search should also show both, but only
displays the post in c.l.j.g.!
<http://groups-beta.google.com/groups?q=pictures+serialized+group:comp.lang.java.*&start=0&scoring=d&>

Bloody Google!
..I want to see the thread...

Why? How many times do you need to see the same words?
.. and don't want to go hunting through groups to find it.

...and why go *hunting* for them?!?

Multi-posting is something that I care not a toss about,
...unless I /notice/ it. ;-)
 
R

Raymond DeCampo

freesoft_2000 said:
Hi everyone,

I noticed that the the Java HTML class has a tag called
HTML.TAG.EM
Does the EM tag by any chance actually mean the html embed tag or does it
mean something else in Java??

If the EM is the html embed tag then how would i go about
using it to embed the image??

Sample codes would be helpfull

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West

ps. I am the OP

I would imagine it means the HTML EM tag.

<http://www.w3.org/TR/html4/struct/text.html#edef-EM>

In any case, I do not think the EMBED tag, which is not standard HTML,
does what you want.

Ray
 
J

jonck

Hi Richard,
I have struggled extensively with the same problem in the past but was
not able to find a solution other than writing the picture to a
temporary directory and linking to it in the HTML document. Should you
find a solution to your problem I would be very interested in hearing
how you solved it (and of course I will keep this newsgroup posted
should I find a solution to your problem).

Kind regards, Jonck
 
V

Virgil Green

Andrew said:
...hmm. I was working under the misapprehension that a
simple Google would reveal all, but ..apparently not.

I don't know that the identical post was made... nor did I know at the time
how quickly it would be archived. It's just a simple request... easily
answered in your first response.
This search is specific to c.l.j.gui.
<http://groups-beta.google.com/groups?q=pictures+serialized+group:comp.lan
g.java.gui>
..it only finds the c.l.j.gui post.

This search *should* show both, but only shows the c.l.j.p. post.
<http://groups-beta.google.com/groups?q=pictures+serialized+group:comp.lan
g.java.*>
While this alternate search should also show both, but only
displays the post in c.l.j.g.!
<http://groups-beta.google.com/groups?q=pictures+serialized+group:comp.lang.
java.*&start=0&scoring=d&>

Bloody Google!


Why? How many times do you need to see the same words?

Well, once would be enough. The only thing I'd seen when I posted that
request was your post stating that you'd answered his question in some other
unnamed group.
..and why go *hunting* for them?!?

Because I wish to see the thread that contained your answer.
 
A

Andrew Thompson

Andrew Thompson wrote: ....

Because I wish to see the thread that contained your answer.

To quote my answer on 'the other group' specifically and exactly.
"See my answer on the other group."

...I never stated it was the answer to the OP's technical problem,
it was simply the answer to not being plonked.

But most people, perhaps not in this thread, would realise
- the hidden meaning
- the subtle irony of 'the answer'

If, in future, you see any post from me where I simply
put 'See my answer on the other group.', you can bet
the message to the other group is exactly the same.

(sigh..)
 
J

Joan

jonck said:
Hi Richard,
I have struggled extensively with the same problem in the past but was
not able to find a solution other than writing the picture to a
temporary directory and linking to it in the HTML document. Should you
find a solution to your problem I would be very interested in hearing
how you solved it (and of course I will keep this newsgroup posted
should I find a solution to your problem).

Kind regards, Jonck

to OP

How about MHT format ?
 
V

Virgil Green

Andrew said:
To quote my answer on 'the other group' specifically and exactly.
"See my answer on the other group."

..I never stated it was the answer to the OP's technical problem,
it was simply the answer to not being plonked.

Oh, apparently I was caught up in your little game.
But most people, perhaps not in this thread, would realise
- the hidden meaning
- the subtle irony of 'the answer'

If, in future, you see any post from me where I simply
put 'See my answer on the other group.', you can bet
the message to the other group is exactly the same.

Yes, I'll know what to put to noise rather than signal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top