General idea:
1. The front page uses JS to obtain the clipping picture ID and the x,y, the width and the height.
2. The server takes out the picture to be cropped based on the ID.
3. Based on these parameters, the cropped image is generated.
[code] Java picture crop view Sourceprint?
| 001 |
Package COM.WODEXIANGCE; |
| 003 |
Import Java.awt.Rectangle; |
| 005 |
Import Java.awt.image.BufferedImage; |
| 009 |
Import Java.io.FileInputStream; |
| 011 |
Import java.io.IOException; |
| 013 |
Import Java.util.Iterator; |
| 015 |
Import Javax.imageio.ImageIO; |
| 017 |
Import Javax.imageio.ImageReadParam; |
| 019 |
Import Javax.imageio.ImageReader; |
| 021 |
Import Javax.imageio.stream.ImageInputStream; |
| 029 |
public class Operateimage { |
| 031 |
= = Source Picture path name: c:\1.jpg |
| 033 |
Private String Srcpath; |
| 035 |
= = = Cut the picture to store the path name. such as: c:\2.jpg |
| 037 |
Private String subpath; |
| 039 |
= = = Cut point x coordinate |
| 045 |
= = = Cut Point width |
| 051 |
Public Operateimage () { |
| 055 |
public operateimage (int x, int y, int width, int height) { |
| 063 |
This.height = height; |
| 069 |
* Crop the picture and save the cropped new picture. |
| 073 |
public void Cut () throws IOException { |
| 075 |
FileInputStream is = null; |
| 077 |
Imageinputstream IIS = NULL; |
| 081 |
Reading picture files |
| 083 |
is = new FileInputStream (Srcpath); |
| 18V |
* Returns the iterator containing all currently registered ImageReader, these ImageReader |
| 089 |
* Claims to be able to decode the specified format. Parameters: FormatName-contains informal format names. |
| 091 |
* (for example, "JPEG" or "TIFF"). |