i tried this method. one problem with my for loop. it goes by twos and stops at 69990 but never breaks and continues. here's my code.
thanx in advanced for the help.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.net.*;
import images.*;
import java2d.*;
import javax.imageio.*;
import java.awt.geom.*;
import java.awt.image.*;
public class paint extends JFrame implements ActionListener
{
private int pointCount = 0;
private Point points[] = new Point[1000];
private JButton btn = new JButton("Done Signing");
public String name = "";
private File file;
private UIManager.LookAndFeelInfo looks[];
private Image one;
private Image two;
public Toolkit tool;
private PixelGrabber pg;
private JButton compare = new JButton("Compare");
private Graphics2D g2d;
private JButton clear = new JButton("Clear Area");
public paint()
{
super("Painter");
try{
looks = UIManager.getInstalledLookAndFeels();
UIManager.setLookAndFeel(looks[2].getClassName());
SwingUtilities.updateComponentTreeUI(this);
}
catch(Exception e)
{
}
Panel p1 = new Panel();
p1.add(clear);
clear.addActionListener(this);
p1.add(btn);
p1.add(compare);
compare.addActionListener(this);
getContentPane().add(p1,
BorderLayout.SOUTH);
btn.addActionListener(this);
addMouseMotionListener(
new MouseMotionAdapter() {
public void mouseDragged(MouseEvent event)
{
if(pointCount < points.length)
{
points[pointCount] = event.getPoint();
++pointCount;
repaint();
}
}
}
);
setSize(500,150);
setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource() == clear)
{
new paint();
setVisible(false);
}
if(ae.getSource() == btn)
{
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = fileChooser.showSaveDialog(this);
file = fileChooser.getSelectedFile();
if(file == null || file.getName().equals(""))
JOptionPane.showMessageDialog(null,
"Invalid File Name Selected",
"Invalid File Name",
JOptionPane.ERROR_MESSAGE);
intoPic();
}
if(ae.getSource() == compare)
{
JOptionPane.showMessageDialog(null,
"Choose the file path of the original signature.",
"Enter File Path",
JOptionPane.INFORMATION_MESSAGE);
JFileChooser fileChooser2 = new JFileChooser();
fileChooser2.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result2 = fileChooser2.showOpenDialog(this);
File newF1 = fileChooser2.getSelectedFile();
String orig = "";
if(newF1 == null || newF1.equals(""))
JOptionPane.showMessageDialog(null,
"Invalid File Name Selected",
"Invalid File Name",
JOptionPane.ERROR_MESSAGE);
else
orig = newF1.toString();
JOptionPane.showMessageDialog(null,
"Choose the file path of the original signature that should be compared to the original.",
"Enter File Path",
JOptionPane.INFORMATION_MESSAGE);
JFileChooser fileChooser3 = new JFileChooser();
fileChooser3.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result3 = fileChooser3.showOpenDialog(this);
File newF2 = fileChooser3.getSelectedFile();
String comp = "";
if (newF2 == null || newF2.equals(""))
JOptionPane.showMessageDialog(null,
"Invalid File Name Selected",
"Invalid File Name",
JOptionPane.ERROR_MESSAGE);
else
comp = newF1.toString();
try{
tool = Toolkit.getDefaultToolkit();
one = tool.getImage(orig);
two = tool.getImage(comp);
int pixelsOne [] = new int[500*140];
PixelGrabber pg=new PixelGrabber(one,0,0,500,140,pixelsOne,0,500);
pg.grabPixels();
int pixelsTwo [] = new int[500*140];
PixelGrabber pg2=new PixelGrabber(two,0,0,500,140,pixelsTwo,0,500);
pg2.grabPixels();
boolean same = false;
/*********************************\
|* PROBLEM FOR LOOP: *|
\*********************************/
for(int i = 0; i < 70000; i++)
{
int up [] = {i+1,i+2,i+3,i+4,i+5,i+6,i+7,i+8,i+9,i+10};
int down [] = {i+1,i+2,i+3,i+4,i+5,i+6,i+7,i+8,i+9,i+10};
System.out.println(i);
if(pixelsOne[i++]==pixelsTwo[up[9]]||
pixelsOne[i]==pixelsTwo[up[0]]||
pixelsOne[i]==pixelsTwo[up[1]]||
pixelsOne[i]==pixelsTwo[up[2]]||
pixelsOne[i]==pixelsTwo[up[3]]||
pixelsOne[i]==pixelsTwo[up[4]]||
pixelsOne[i]==pixelsTwo[up[5]]||
pixelsOne[i]==pixelsTwo[up[6]]||
pixelsOne[i]==pixelsTwo[up[7]]||
pixelsOne[i]==pixelsTwo[up[8]]||
pixelsOne[i]==pixelsTwo[down[0]]||
pixelsOne[i]==pixelsTwo[down[1]]||
pixelsOne[i]==pixelsTwo[down[2]]||
pixelsOne[i]==pixelsTwo[down[3]]||
pixelsOne[i]==pixelsTwo[down[4]]||
pixelsOne[i]==pixelsTwo[down[5]]||
pixelsOne[i]==pixelsTwo[down[6]]||
pixelsOne[i]==pixelsTwo[down[7]]||
pixelsOne[i]==pixelsTwo[down[8]]||
pixelsOne[i]==pixelsTwo[down[9]])
{
same = true;
}
else
{
same = false;
}
if(i>=69990)
{
break;
}
}
if(same)
{
System.err.println("SAME!");
}
else
{
System.err.println("DIFFERENT");
}
}
catch(Exception e3)
{
}
}
}
private void intoPic()
{
RenderedImage rendImage = myCreateImage();
try
{
ImageIO.write(rendImage, "png", file);
}
catch(Exception e1)
{
}
}
private RenderedImage myCreateImage() {
int width = 500;
int height = 140;
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
g2d = bufferedImage.createGraphics();
g2d.setColor(Color.white);
g2d.fillRect(0, 0, width, height);
g2d.setColor(Color.black);
for(int i=0; i < points.length && points[i] != null; i++)
{
g2d.fillRect(points[i].x, points[i].y, 4, 4);
g2d.fillOval(points[i].x, points[i].y, 5, 5);
}
g2d.dispose();
return bufferedImage;
}
public void paint(Graphics g)
{
super.paint(g);
for(int i=0; i < points.length && points[i] != null; i++)
{
g.fillRect(points[i].x, points[i].y, 4, 4);
g.fillOval(points[i].x, points[i].y, 5, 5);
}
}
public static void main(String [] args)
{
paint app = new paint();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}