"Rune Johansen" <rune[insert_current_year_here]@runevision.com> wrote in message > However, I really want an application rather than an applet, I just
can't figure out how to do the image loading and manipulation when it's
not from inside an applet. Any hints on the subject are appreciated.
Thanks in advance,
Rune
For loading and saving images, you have several options:
Use javax.imageio.ImageIO is the easiest way to load images. It
currently can only handle JPEG, GIF and PNG, but with Java1.5 should
be able to load TIFFs too. ImageIO.read() will read your images and
ImageIO.write() will write them.
The other main way to load images is through the Toolkit.
java.awt.Toolkit.getDefaultToolkit().getImage(file name) will load any
GIF, JPEG or PNG.
If you used the first method to load your image, you'll have a
BufferedImage who's data you can access directly.
If you used the second method, you'll have an ordinary Image. You can
read it's data by creating an array to hold pixel data, then creating
PixelGrabber and calling grabPixels() to get the data. To turn your
data back into an image, you'll need to create a
java.awt.image.MemoryImageSource.
While the first method is much easier to use, the second method is, in
my experience, much faster. The second method is the 'classic' way to
manipulate images.
There is also a way to do all of this with the Java Media Framework,
but I've been unable to figure out how to use it. The docs for it
contain much information, but are nearly impossible to learn from.
Mark McKay
--
http://www.kitfox.com