图象裁剪:
Image imgpart=getImage("1.jpg");
imgf=new CropImageFilter(x,y,width,height);
imgpart=Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(imgpart.getSource(),imgf));
关于读取像素,参考以下我写的例子:
一张图片渐渐消失,然后又渐渐显示
import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.util.*;public class applet2 extends Applet implements Runnable {
Image img[]=new Image[30];
Image imgx=null;
int imgIndex=0;
int imgAdd=1;
Thread thread=null;
MediaTracker mt;
ImageFilter imgf=null;
FilteredImageSource fis=null;
Image im=null;
Graphics g2=null;
public void init() {
  imgx=this.getImage(this.getCodeBase(),"d.jpg");
  mt=new MediaTracker(this);
  thread=new Thread(this);
  loadImage(mt);
  try {
    mt.waitForAll();
  } catch(Exception ex) {System.err.println(ex.toString());}
  im=this.createImage(imgx.getWidth(this),imgx.getHeight(this));
  g2=im.getGraphics();
}public void loadImage(MediaTracker mt) {
for(int i=0;i<30;i++) {
  imgf=new myImage(imgx.getWidth(this),imgx.getHeight(this),i*8);
  fis=new FilteredImageSource(imgx.getSource(),imgf);
  img[i]=this.createImage(fis);
  mt.addImage(img[i],0);
}
}public void run() {
try {
while(true) {
this.repaint();
Thread.sleep(100);
}
}catch(Exception e) {
System.out.println(e.toString());
}
}public void paint(Graphics g) {
g2.drawImage(img[imgIndex],0,0,this);
g.drawImage(im,0,0,this);
}public void update(Graphics g) {
if(imgIndex>=29)
  imgAdd=-1;
if(imgIndex<=0)
  imgAdd=1;
imgIndex+=imgAdd;
g2.clearRect(0,0,imgx.getWidth(this),imgx.getHeight(this));
g2.drawImage(img[imgIndex],0,0,this);
g.drawImage(im,0,0,this);
}public void start() {
thread.start();
}public void stop() {
if(thread!=null) {
  thread.stop();
  thread=null;
}
}
}class myImage extends RGBImageFilter {
int width=0;
int height=0;
int alpha=0;
public myImage(int width,int height,int alpha) {
this.canFilterIndexColorModel=true;
this.width=width;
this.height=height;
this.alpha=alpha;
}public int filterRGB(int x,int y,int rgb) {//这里操作的就是每个像素的ARGB
DirectColorModel dcm=(DirectColorModel)ColorModel.getRGBdefault();
int red=dcm.getRed(rgb);
int green=dcm.getGreen(rgb);
int blue=dcm.getBlue(rgb);
return alpha<<24|red<<16|green<<8|blue;
}
}