📄 handleimage.java
字号:
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
public class HandleImage extends JComponent{
int imageWidth,imageHeight;
Toolkit tool;
HandleImage(){
tool=getToolkit();
}
public Image [] getImages(Image image,int rows,int colums){
Image [] blockImage=new Image[rows*colums];
try{
imageWidth=image.getWidth(this);
imageHeight=image.getHeight(this);
int w=imageWidth/colums;
int h=imageHeight/rows;
int k=0;
PixelGrabber pg=null;
ImageProducer ip=null;
for(int i=0;i<rows;i++){
for(int j=0;j<colums;j++){
int pixels[]= new int[w*h];
pg=new PixelGrabber(image,j*w,i*h,w,h,pixels,0,w);
pg.grabPixels();
ip=new MemoryImageSource(w,h,pixels,0,w);
blockImage[k]=tool.createImage(ip);
k++;
}
}
}
catch(Exception ee){}
return blockImage;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -