Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

saving an image to file (with other contents...)

Thread view: 
tiewknvc9 - 16 Sep 2007 13:58 GMT
Hi!

Im having trouble finding a resource that discusses this topic, so I
figured I would make a post here.

I have a little program where the user can enter text and select
graphics to show within the program.  I offer the ability to save
their creations... BUT since I store the graphics that they have
selected as the path to the graphic...  if they want to share their
creations with their friends the graphics do not show up because their
friends dont have the graphics!

SO my question is, is there a way to embed the graphics into the save
file?  How can I do this?  Then how would I grab the file from the
save file when their friends open the file?  Is there an example
somewhere online?

Thanks!
Knute Johnson - 17 Sep 2007 00:37 GMT
> Hi!
>
[quoted text clipped - 14 lines]
>
> Thanks!

It is really not clear what you are asking as can be seen from the lack
of response to your post.

                Do you want to save an image to a file?
                                   |
                                   |
                                   |
                       Yes ------------------ No
                        |                      |
                        |                      |
                     ImageIO                   |
                                               |
                                               |
                          Is it really a just drawing and not an image?
                                               |
                                               |
                                               |
                       Yes --------------------------------- No
                        |                                    |
                        |                                    |
           Then you are going to have to         Then what the heck
           create an image because you           is it?
           can't just save your drawing.
           (See the answer above)

Signature

Knute Johnson
email s/nospam/knute/

tiewknvc9 - 17 Sep 2007 01:00 GMT
ok - to clarify...

What I would like to save is a set of data.  so for instance, a text
field, and an image.  I want to combine these items into a single save
file.  The text (entirely seperate from the image) should be saved to
file, along with the image.

When the user opens the file that was saved (a single file containing
the text, and the image) it will open the file and insert the text
into a text box, and the image (if specified) into the image area...

On Sep 16, 7:37 pm, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> > Hi!
>
[quoted text clipped - 46 lines]
>
> - Show quoted text -
Knute Johnson - 17 Sep 2007 02:10 GMT
> ok - to clarify...
>
[quoted text clipped - 6 lines]
> the text, and the image) it will open the file and insert the text
> into a text box, and the image (if specified) into the image area...

OK that makes a lot more sense.  Many objects can be serialized and
saved to disk.  Although the Image class can't be serialized, the
BufferedImage can have its data saved in an array and an array can be
serialized.  A JTextField keeps its data in a String which can also be
serialized.  So you could create a class that held your String and your
array and write that to disk.  If they don't have to be in the same
exact file your could easily write the image to one file and the string
data to the other.  The only drawback is two files but the advantages
are obvious.

Signature

Knute Johnson
email s/nospam/knute/

tiewknvc9 - 17 Sep 2007 05:05 GMT
On Sep 16, 9:10 pm, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> > ok - to clarify...
>
[quoted text clipped - 21 lines]
> Knute Johnson
> email s/nospam/knute/

thanks!
Andrew Thompson - 17 Sep 2007 05:05 GMT
>ok - to clarify...

Top-posting is not a good way to clarify things. I
for one, find it most confusing.
...
>When the user opens the file that was saved (a single file containing
>the text, and the image) it will open the file ...

There are a numer of aspects to this problem, and the file
format itself has been covered by a number of people, so
I will limit my reply to invoking the app. to open the file.

Web start provides mechanisms to associate a filetype
with an application.  I show the technique in this example
that links the '.zzz' file type with the filetest app.
<http://www.physci.org/jws/#fs>

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Roedy Green - 17 Sep 2007 03:50 GMT
>SO my question is, is there a way to embed the graphics into the save
>file?  How can I do this?  Then how would I grab the file from the
>save file when their friends open the file?  Is there an example
>somewhere online?

With HTML you never embed the file.  You save the image an a separate
file, and embed a link to it in the HTML.  see
http://mindprod.com/jgloss/pngencoder.html for how you create image
files.

If you create your own file format, you can embed images.  You might
do it with a length followed by the binary image, identical to what it
would be as a standalone file. You might then compress the whole
thing, or compress the embedded images.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

tiewknvc9 - 17 Sep 2007 05:04 GMT
thanks for the feedback, but I am working with an application.  The
HTML does not apply...

On Sep 16, 10:50 pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:

> >SO my question is, is there a way to embed the graphics into the save
> >file?  How can I do this?  Then how would I grab the file from the
[quoted text clipped - 13 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.