当前位置: 技术问答>java相关
求java图象处理的源码~~~交作业~~死大了
来源: 互联网 发布时间:2017-04-02
本文导语: 偶才知道 都要交了~~~~ 多么简单的都可以 分分好说啊~~~ | import java.applet.*; import java.awt.*; import java.awt.image.* ; import java.awt.event.*; public class RGBImageFilterTest extends Applet { Image img = nul...
偶才知道
都要交了~~~~
多么简单的都可以
分分好说啊~~~
都要交了~~~~
多么简单的都可以
分分好说啊~~~
|
import java.applet.*;
import java.awt.*;
import java.awt.image.* ;
import java.awt.event.*;
public class RGBImageFilterTest extends Applet {
Image img = null ;
Image img2 = null ;
public void init() {
MediaTracker mt = new MediaTracker(this) ;
try {
img = Toolkit.getDefaultToolkit().getImage("../test.gif") ;
mt.addImage(img, 0) ;
mt.waitForID(0) ;
}
catch (Exception e) {
e.printStackTrace() ;
}
int w = img.getWidth(this) ;
int h = img.getHeight(this) ;
ImageFilter imgFilter = new TransparentImageFilter(w, h) ;
FilteredImageSource fImgSource = new FilteredImageSource(img.getSource(), imgFilter) ;
img2 = this.createImage(fImgSource) ;
}
public void paint(Graphics g) {
g.drawImage(img, 0, 0, this) ;
g.drawImage(img2, 100, 100, this) ;
}
}
/**
* RGBImageFilter Extends Class - TransparentImageFilter
*/
class TransparentImageFilter extends RGBImageFilter {
private int width = 0 ;
private int height = 0 ;
public TransparentImageFilter(int width, int height) {
this.width = width ;
this.height = height ;
}
public int filterRGB(int x, int y, int rgb) {
DirectColorModel cm = (DirectColorModel)ColorModel.getRGBdefault() ;
int alpha = cm.getAlpha(rgb) ;
int red = cm.getRed(rgb) ;
int green = cm.getGreen(rgb) ;
int blue = cm.getBlue(rgb) ;
alpha = 255 * y / height ;
return alpha
import java.awt.*;
import java.awt.image.* ;
import java.awt.event.*;
public class RGBImageFilterTest extends Applet {
Image img = null ;
Image img2 = null ;
public void init() {
MediaTracker mt = new MediaTracker(this) ;
try {
img = Toolkit.getDefaultToolkit().getImage("../test.gif") ;
mt.addImage(img, 0) ;
mt.waitForID(0) ;
}
catch (Exception e) {
e.printStackTrace() ;
}
int w = img.getWidth(this) ;
int h = img.getHeight(this) ;
ImageFilter imgFilter = new TransparentImageFilter(w, h) ;
FilteredImageSource fImgSource = new FilteredImageSource(img.getSource(), imgFilter) ;
img2 = this.createImage(fImgSource) ;
}
public void paint(Graphics g) {
g.drawImage(img, 0, 0, this) ;
g.drawImage(img2, 100, 100, this) ;
}
}
/**
* RGBImageFilter Extends Class - TransparentImageFilter
*/
class TransparentImageFilter extends RGBImageFilter {
private int width = 0 ;
private int height = 0 ;
public TransparentImageFilter(int width, int height) {
this.width = width ;
this.height = height ;
}
public int filterRGB(int x, int y, int rgb) {
DirectColorModel cm = (DirectColorModel)ColorModel.getRGBdefault() ;
int alpha = cm.getAlpha(rgb) ;
int red = cm.getRed(rgb) ;
int green = cm.getGreen(rgb) ;
int blue = cm.getBlue(rgb) ;
alpha = 255 * y / height ;
return alpha