aspose file tools*
The moose likes Beginning Java and the fly likes Assigning a GIF/JPG to Image object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Assigning a GIF/JPG to Image object" Watch "Assigning a GIF/JPG to Image object" New topic
Author

Assigning a GIF/JPG to Image object

donepudi madhu
Greenhorn

Joined: Sep 25, 2002
Posts: 11
Can anyone tell me how to assign a GIF/JPG(in my directory)to an Image object(or BufferedImage object)?
Chad McGowan
Ranch Hand

Joined: May 10, 2001
Posts: 265
Take a look at the Java Advanced Imaging API.
JAI
There should be some tutorials and/or examples on how to encode and decode different image formats.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
donepudi_madhu,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Displaying GIFs is pretty easy. For example...
Download the big moose graphic in the upper left corner of this page and save it as "moosebig.gif" in the same directory where you'll create a Java applet. In this directory, create a text file named FooApplet.java and edit it to have these contents:Compile the .java file. Now create a new text document and name it MyApplet.html. Edit it to have these contents:Save the html file and view it using the appletviewer (appletviewer MyApplet.html) or with a web browser.
donepudi madhu
Greenhorn

Joined: Sep 25, 2002
Posts: 11
Sir, very thankfull for your reply. It worked well in Applets.If I try it in Swing, it says that getDocumentBase is not found.Can you please tell me how to do that?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Gladly. But do me a favor first and please change your display name as requested.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Thanks.
Take a look at the methods of java.awt.Toolkit.
Image image = java.awt.Toolkit.getDefaultToolkit().getImage( String );
[ September 27, 2002: Message edited by: Dirk Schreckmann ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assigning a GIF/JPG to Image object
 
Similar Threads
Serialization to a blob in a db
how to change a frame or applets icon
Image Loading
How do i save an image object in any format (gif,jpg)....urgent
using servlet to create a html page with embedded Image