Results 1 to 2 of 2
  1. #1
    spike72 is offline Member
    Join Date
    Aug 2009
    Posts
    1
    Rep Power
    0

    Default Image manipulation

    Guys,

    I am working with a signature capture... After getting the array of points from the signature I want to display(Reconstruct the signature) them in the rectangle which I draw when the form loads. Displaying them in pixels.

    Anyone can help me?

    Thanks in advance.
    Last edited by spike72; 08-28-2009 at 08:52 AM.

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    5

    Default

    i wrote a custom captcha awhile back that generated an image. I use that image on a jsp page. It's not particularly good, but perhaps it will be useful?

    Java Code:
    import java.awt.image.BufferedImage;
    import java.awt.Graphics2D;
    import java.awt.Color;
    import java.awt.Font;
    
    public class Captcha2 {
    
        private static char[] elegibleChars =  "ABCDEFGHJKLMPQRSTUVWXY23456789".toCharArray();
        private int numChars = 6;
        private String randString = "";
    
        private Color backColor = Color.BLACK;
        private Color foreColor = Color.WHITE;
    
        public BufferedImage genImage()
        {
            randString = generateRandomStr();
    
            BufferedImage image = new BufferedImage(200, 50, BufferedImage.TYPE_INT_ARGB);
    
            Graphics2D g2d = (Graphics2D)image.createGraphics();
    
            g2d.setColor(backColor);
            g2d.fillRect(0, 0, 200, 50);
            
            char[] arr = randString.toCharArray();
    
            int xpos = -15;
    
            
            for(int j = 0; j < 200; j++)
            {
                int s = randInt(2)+1;
                g2d.setColor(foreColor);
                g2d.fillOval(randInt(200), randInt(50), s, s);
            }
    
            for(int j = 0; j < randString.length(); j++)
            {
                int fsize = 22+randInt(10);
                Font f = null;
                switch(randInt(2))
                {
                    case 0: f = new Font("Arial",Font.BOLD, fsize);
                    case 1: f = new Font("Arial",Font.BOLD, fsize);
                    case 2: f = new Font("Arial",Font.BOLD, fsize);
                }
                
    
                int r = randInt(15);
                int x = j*(20+r) + 10;
    
                xpos += 20 + randInt(17);
                int ypos = randInt(20);
    
                BufferedImage c_image = new BufferedImage(26, 26, BufferedImage.TYPE_4BYTE_ABGR);
                Graphics2D c_g2d = (Graphics2D)c_image.getGraphics();
    
                c_g2d.setColor(new Color(0,0,0,0));
                c_g2d.fillRect(0, 0, 50, 50);
    
                double angle = Math.random() * (randInt(1)==0?-1:1) +.25;
                //
                c_g2d.translate(13, 13);            
                c_g2d.rotate(angle);
                c_g2d.translate(-(int)Math.round(fsize/2.5), +fsize/3);
                c_g2d.setColor(Color.WHITE);
                c_g2d.setFont(f);
                c_g2d.drawString(""+arr[j], 0, 0);
    
                g2d.drawImage(c_image, xpos,ypos, null);
            }
    
            return image;
        }
    
        public static int randInt(int upper)
        {
            return (int)(Math.random() * (upper+1));
        }
    
        public String getRandomStr()
        {
            return randString;
        }
    
        private String generateRandomStr()
        {
            String str = "";
    
            for(int j = 0; j < numChars; j++)
            {
                str += elegibleChars[ randInt(elegibleChars.length-1) ];
            }
    
            return str;
        }
    }
    My Hobby Project: LegacyClone

Similar Threads

  1. Linked List Manipulation
    By chrisdb89 in forum New To Java
    Replies: 3
    Last Post: 11-21-2008, 06:07 PM
  2. Image manipulation.
    By ambikark in forum Advanced Java
    Replies: 0
    Last Post: 10-15-2008, 01:37 PM
  3. POI - excel macros manipulation
    By Jay in forum Advanced Java
    Replies: 0
    Last Post: 07-31-2008, 10:04 AM
  4. Array manipulation
    By Ms.Ranjan in forum New To Java
    Replies: 9
    Last Post: 07-18-2008, 09:10 PM
  5. String Manipulation Task
    By hiranya in forum New To Java
    Replies: 1
    Last Post: 11-19-2007, 11:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •