📄 zoomwindow.java
字号:
package a.a.a.b;
import java.awt.*;
import java.awt.image.*;
import javax.swing.JWindow;
public class ZoomWindow extends JWindow {
public static final long serialVersionUID=1;
private BufferedImage image;
private int zoom;
public ZoomWindow(Frame owner) {
super(owner);
this.setBackground(Color.BLACK);
}
public void setZoom(int zoomSize){
zoom=zoomSize;
}
synchronized public void update(BufferedImage img){
int ow=img.getWidth();
int oh=img.getHeight();
int w=ow*zoom;
int h=oh*zoom;
int[] ori=new int[ow*oh];
img.getRGB(0,0,ow,oh,ori,0,ow);
int[] dst=new int[w*h];
int op=0;
int dp=0;
for(int y=0;y<oh;++y){
for(int x=0;x<ow;++x,++op){
for(int j=0;j<zoom;++j,dp++){
dst[dp]=ori[op];
}
}
int o=dp-w;
for(int l=1;l<zoom;++l,dp+=w){
o=dp-w;
for(int x=0;x<w;++x,++o){
dst[dp+x]=dst[o];
}
}
}
ori=null;
image=null;
image=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
image.setRGB(0,0,w,h,dst,0,w);
dst=null;
//image=img;//.getScaledInstance(ow*zoom,oh*zoom)
this.repaint();
}
public void paint(Graphics g){
if(image!=null){
g.drawImage(image,0,0,null);
}else{
g.setColor(Color.BLACK);
g.fillRect(0,0,this.getWidth(),this.getHeight());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -