import java.awt.*; import java.awt.image.*; import java.awt.event.*; public class Pildimuutus4 extends Frame implements MouseListener{ Image pilt2; BufferedImage pilt; int laius=400, korgus=300; int hx, hy; public Pildimuutus4(){ try{ pilt=new BufferedImage(laius, korgus, BufferedImage.TYPE_INT_RGB); Graphics g=pilt.createGraphics(); g.setColor(Color.white); g.fillRect(0, 0, laius/2, korgus); g.setColor(Color.blue); g.fillOval(laius/2-20, korgus/2-20, 40, 40); muudaPilt(); setSize(800, 200); setLocation(200, 100); setVisible(true); addMouseListener(this); }catch(Exception e){} } public void muudaPilt(){ try{ int punktid[]=new int[laius*korgus]; PixelGrabber pg=new PixelGrabber( pilt, 0, 0, laius, korgus, punktid, 0, laius); pg.grabPixels(); int y=hy; int x=hx; int vx=x; int algpunkt=punktid[y*laius+x]; while(y>16 & 0xFF; int roheline=p>>8 & 0xFF; int sinine=p & 0xFF; punane=0; roheline=255; sinine=0; punktid[y*laius+x]=(255<<24) | (punane<<16) | (roheline<<8) | (sinine<<0); x++; } y++; } pilt2=Toolkit.getDefaultToolkit().createImage( new MemoryImageSource(laius, korgus, punktid, 0, laius)); }catch(Exception e){e.printStackTrace();} } public void mousePressed(MouseEvent e){ hx=e.getX(); hy=e.getY()-50; muudaPilt(); repaint(); } public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void paint(Graphics g){ g.drawImage(pilt, 0, 50, this); g.drawImage(pilt2, laius, 50, this); } public static void main(String argumendid[]){ new Pildimuutus4(); } }