import java.awt.image.*; import java.awt.geom.*; import java.awt.*; import java.applet.*; public class Pildivarvimuutus2 extends Applet{ BufferedImage pilt1=new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); BufferedImage pilt2=new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); public Pildivarvimuutus2(){ Graphics g=pilt1.createGraphics(); g.setColor(Color.green); g.fillOval(10, 10, 80, 80); g.setColor(Color.blue); g.fillOval(10, 10, 20, 20); g.setColor(Color.red); g.fillOval(70, 70, 20, 20); float andmed[][]=new float[][]{ {0, 0, 1}, //punane ja sinine vahetatakse {0, 1, 0}, {1, 0, 0} }; BandCombineOp bco=new BandCombineOp( andmed, null ); bco.filter(pilt1.getData(), pilt2.getRaster()); } public void paint(Graphics g){ g.drawImage(pilt1, 25, 50, this); g.drawImage(pilt2, 175, 50, this); } public static void main(String argumendid[]){ Frame f=new Frame("Pildi värvide muutmine"); f.add(new Pildivarvimuutus2()); f.setSize(300, 200); f.setVisible(true); } }