wood burning stoves 2.0*
The moose likes Java in General and the fly likes Image manipulation question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Image manipulation question" Watch "Image manipulation question" New topic
Author

Image manipulation question

James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
I've got a button image that I need to modify in my code.

The code will need to increase the size of the image, and add new pixel data to it.

I imagine the code will need to:
1. convert the jpg image into a data array
2. manipulate the data array
3. convert back to jpg

Can anyone advise me how to perform steps 1 and 3. Any example code would be also be much appreciated.

Cheers,
James
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Where is this "pixel data" coming from? Capturing something from the screen? Performing a transformation of some sort? Making a composite of two images? It's very simple to insert a filter to make all red pixels blue, for example, and does not involve a "data array".
James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
Hiya Ken,

The original image is a jpeg file.

Basically, the operation from step 2 will be to elongate the image (but not 'stretch', as this will distort the curves in the image).

The new image will be bigger than the original and have new pixel data added to it. (The new pixel data to be inserted will actually be taken from the original image.)

Cheers,
James
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
You can use ImageIO to read and write images.


There is no emoticon for what I am feeling!
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Originally posted by James Hodgkiss:
Hiya Ken,

The original image is a jpeg file.

Basically, the operation from step 2 will be to elongate the image (but not 'stretch', as this will distort the curves in the image).

The new image will be bigger than the original and have new pixel data added to it. (The new pixel data to be inserted will actually be taken from the original image.)

Cheers,
James


Well you can use ImageIO as mentioned. JAI also has a "fileload" operation that will return a PlanarImage. How you're going to elongate this is beyond me. I'm no expert on image manipulation but it seems to me you're going to need to cut it up, stretch the portion(s) being extended, then put it all back together.
James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
Many thanks for the replies. I've now come across the PixelGrabber and MemoryImageSource APIs - which look just the job.

Cheers,
James
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by James Hodgkiss:
Many thanks for the replies. I've now come across the PixelGrabber and MemoryImageSource APIs - which look just the job.


Hmmm... Most folks find BufferedImage and the 2D API both easier to work with and more powerful to boot. Take the 2D Graphics tutorial: http://java.sun.com/docs/books/tutorial/2d/index.html
 
 
subject: Image manipulation question