📄 shrinkstretchfilteruse.java
字号:
import java.awt.*;
import java.applet.Applet;
import java.awt.image.*;
public class shrinkStretchFilterUse extends Applet
{
Image img,stretch,shrink;
int nwidth,nheight;
public void init()
{
img = getImage(getDocumentBase(),getParameter("image"));
MediaTracker mt = new MediaTracker(this);
mt.addImage(img,0);
try
{
mt.waitForAll();
}
catch(InterruptedException ie)
{
ie.printStackTrace();
}
nwidth = img.getWidth(this);
nheight =img.getHeight(this);
ImageFilter stretchF = new ReplicateScaleFilter(nwidth * 2,nheight * 2);
FilteredImageSource stretchS = new FilteredImageSource(img.getSource(),stretchF);
stretch = createImage(stretchS);
ImageFilter shrinkF = new ReplicateScaleFilter(nwidth / 2,nheight / 2);
FilteredImageSource shrinkS = new FilteredImageSource(img.getSource(),shrinkF);
shrink = createImage(shrinkS);
}
public void paint(Graphics g)
{
g.drawImage(img,0,0,this);
g.drawImage(shrink,nwidth + 50,0,this);
g.drawImage(stretch,nwidth + 100,0,this);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -