954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Can I make a Java Image Editing Photshop-like program

Hi Everybody,

I was wondering how to make a java image editing application. Basically, I really want to make a program that allows the user to drag and stretch images. I don't want the code. I'm only in search of a decent tutorial.

Thanks in advanced for your help.

Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

Should be lots of resources on this. Check out the Java Tutorials http://java.sun.com/docs/books/tutorial/index.html and also the demos that you will have recieved in your sdk.

There are two features of Java that make it easy to do this kind of thing.
1. The API contains support for viewing many graphic types by default.
2. The Graphic Components in Java allow you to extract the displayed Graphics object, that you may then manipulate as you see fit and export to file.

Have fun.

alpha_foobar
Junior Poster
182 posts since May 2005
Reputation Points: 20
Solved Threads: 5
 

hi,

For drag and drop you can try java.awt.datatransfer API. For scaling the images try java.awt.Image method getScaledInstance(int width, int height, int hints) and other related api.

Hope this helps
Regards
Srinivas

cheenu78
Light Poster
45 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

thanks for your replies!

sorry if i wasn't clear in my question, but how do you distort the image (make someone's smile bigger, etc.). I think the feature in photoshop is called liquify.

Thanks again for your help.

Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

You need to access the pixels directly. Then you can do any thing you want with the image. To do this you use:

java.awt.image.PixelGrabber

Then it all gets down to doing the "math" on the pixels to do the effect you want.

Jeff
http://www.heatonresearch.com

JeffHeaton
Junior Poster in Training
58 posts since Jul 2005
Reputation Points: 12
Solved Threads: 0
 

Jeff,

Thank you! I think I already know how to use PixelGrabber (I think I used it in another on another one of my programs). It's actually the math part that I need help with.

Thanks again.

Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

The math part is language independent.
There are books about image manipulation out there, many highly theoretical.
Lowpass and highpass filters work essentially the same as in electronics, so filter theory books for that should work as well.

Start out writing a simple filter, and work your way up :)
Essentially a basic filter takes a pixel and based on its value and a mathematical formula performs some operation on pixels surrounding it.
For example, a very simple filter indeed would just decrease that value by a set amount:

---------------
| -1 | -1 | -1 |
| -1 |  0 | -1 |
| -1 | -1 | -1 |
---------------


If you consider a pixel to be a single value (greyscale) for now, putting this matrix over a pixel would decrease (darken) all pixels surrounding it slightly.
That's the easiest example. Once you get something like this working, more complex filters are possible to do things like edge detection and working on larger areas.

But the math involved quickly gets rather complex. Now I don't mind complex math (it used to be a hobby of mine as well as part of my study) but I'm no expert at this and my knowledge is rather rusty.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

I thought it was a lot of bit flipping and crap like that involved. I doubt just one person can write a full fledged photoshop by themeself.

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

Thanks, guys!

jwenting - would you usee PixelGrabber to grab the pixels and then decrease all of them by 1 to darken the image? Could you do the same thing and increase it by 1 to brighten the image? Thanks. Also, does this work on color images, or only greyscale?

Thanks again.

Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

I don't know what to use to get the pixels (like I said, I've never done anything like this in Java, last time was C++ under DOS).
Best way would be to get access to the raw image data and manipulate that, would certainly be a lot faster.

You can apply filters to do pretty much anything. Where I put -1 for each, you could have any combination of values including mathematical functions, possibly different for each pixel.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

PixelGrabber will make it easier. You don't have to follow that route, but I think any other way would be more complicated than what it's worth.

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

thanks.

server_crash, I was looking at your site and wondering how you make your programs executable. Thanks again.

Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

thanks.

server_crash, I was looking at your site and wondering how you make your programs executable. Thanks again.

You can't. You can run the applets but they will only be run from my webserver. I'm trying to sell them(fat chance!) so right now it requires you to contact me about them.

By the way, how did you change your name?

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

ok and all u need to do is go into the site feedback area and make a thread and ask dani.

Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

Hi everyone,

I for one can personally say that it is possible to build a clone of photoshop in java as i have a beta unrealeased version but it still needs a lot of work. If you want a hint look at the graphics 2d and graphics 3d classes.

And one more thing this photoshop clone has to have printing capabilities and that itself can drive you up the wall. You can start by first having a image simple editor and build on that. I have one function that i am really happy about in that if i have a fully colored picture, i can make it black-white. That really gives certain images a classy look.

One thing is the huge amount of libraries you will have to build as to my knowledge there are few to none image processing libraries in java.

Try your bst and see what happens

Richard West

freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10
 

how to start create image editor in java?

manojnbn
Newbie Poster
2 posts since Feb 2010
Reputation Points: 8
Solved Threads: 0
 

give a image editor code in java

manojnbn
Newbie Poster
2 posts since Feb 2010
Reputation Points: 8
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You