Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Code off

Name: Anonymous 2009-07-28 13:59

Welcome to the first annual /prog/ Code off !

The language will be C.

Compeptitors include (in no particular order):

Mr. Ribs
Xarn
FV
Anonymous
W. T. Snacks

Rumor has it, that there may be a special guest appearance from either The Sussman or
Leah Culver.

What's the point of this, you ask?

It's to determine who is an EXPERT PROGRAMMER.

Marking criteria:

Optimization
Elegance

Bonus marks:
indentation

Good luck!

Name: !Double-Shot-Of-Java 2009-07-28 21:38

Did someone say Image Processing?
Eclipse + Java wins again!
Now where do I go to claim my prize? I hope its an ENTER-prize! <3


import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;
import java.awt.image.RGBImageFilter;
import java.awt.*;

import javax.swing.JOptionPane;


public class app extends java.applet.Applet  {

     private static final long serialVersionUID = 1L;
     Image PWNAGE;
     Image one;
     Image two;
     Graphics bg;
     Image screen;
     Dimension dim;

     Font goodFont = new Font("Helvetica", Font.PLAIN,  22);
   
     public void init() {
          setBackground(new Color(0).white); 
          setSize(1280, 1024);
          dim = getSize();
          screen = createImage(dim.width, dim.height);
          bg = screen.getGraphics();
          addMouseListener(this);
       
       
          one = getImage(getDocumentBase(),JOptionPane.showInputDialog(null, "Type in first image file name."));
          two = getImage(getDocumentBase(),JOptionPane.showInputDialog(null, "Type in second image file name."));
       
       
       
          try {
       
               PWNAGE = makeColorTransparent(two, new Color(0).blue);
          }
          catch(Exception e) {}
     }
   
     public void paint(Graphics g) {     
          bg.clearRect(0, 0, dim.width, dim.height);
          bg.drawImage(one, 0, 0,this);
          bg.drawImage(PWNAGE, 0, 0,this);
          g.drawImage(screen, 0, 0, this);
     }
     
     public void update(Graphics g){
          paint(g);
     }
   
     public static Image makeColorTransparent(Image im, final Color color) {
          ImageFilter filter = new RGBImageFilter() {
               public final int filterRGB(int x, int y, int rgb) {
                    return 0xBDFFFFFF & rgb;
               }
          };
          ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
          return Toolkit.getDefaultToolkit().createImage(ip);
     }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List