shrinkstretchfilteruse.java

来自「包含6个源码。主要是使用APPLET对图形图像进行处理。 有旋转」· Java 代码 · 共 41 行

JAVA
41
字号
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 + =
减小字号Ctrl + -
显示快捷键?