• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OT: Avoid automatic registration with Image Code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OT: Avoid automatic registration with Image Code


  • Subject: Re: OT: Avoid automatic registration with Image Code
  • From: Gino Pacitti <email@hidden>
  • Date: Fri, 8 Jun 2007 12:13:14 +0100

Hi Daniele

Try this.. if I read you right..

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.util.*;
import com.sun.image.codec.jpeg.*;
import java.awt.Toolkit;

public class TextInImage {



    public TextInImage(){
    }



public static void createLoginImage(String inFile, String outFile, String text){
try{
Image img = Toolkit.getDefaultToolkit().getImage(inFile);
MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(img, 0);
mediaTracker.waitForID(0);
int width = img.getWidth(null);
int height = img.getHeight(null);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphic = image.createGraphics();
graphic.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphic.drawImage(img, 0, 0, width, height, null);


        // parse coordinates for text origin
        int x = Integer.parseInt("5");
        int y = Integer.parseInt("30");

        // parse color and transparency information
        int red = Integer.parseInt("0");
        int green = Integer.parseInt("0");
        int blue = Integer.parseInt("0");
        int transparency = Integer.parseInt("100");

// do the text
String string = text;
Font font = new Font(null,Font.BOLD, 18);
// Font font = new Font(null, Font.BOLD, 24);
Color color = new Color(red, green, blue, 255 * transparency / 100);
graphic.setFont(font);
graphic.setColor(color);
graphic.drawString(string, x, y);


// save new image
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outFile));
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam (image);
param.setQuality(40.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(image);
}catch(Exception e){


        e.printStackTrace();
    }

    }
}

On 8 Jun 2007, at 12:07, Daniele Corti wrote:

Hi all,
I know it's a little off-topic, but since I'll use it in WO, I would ask for some advice in this:


I looked for tutorial or howto for create a registration panel that ask for an authentication code, passed to the client by an image to avoid the spam registrations.

For the first time in memories Google betrays me, and I wasn't able to find out almost anything...

So please, have anybody any ideas? I really can't think anything more than create 10 images and serve then at random, or using an applet... but I think there must be some other way to do this...

thanks in advance!

--
Daniele Corti
AIM: S0CR4TE5
Messenger: email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >OT: Avoid automatic registration with Image Code (From: "Daniele Corti" <email@hidden>)

  • Prev by Date: Re: [Wonder-disc] OT: Avoid automatic registration with Image Code
  • Next by Date: Re: Type casting in WOComponents
  • Previous by thread: Re: [Wonder-disc] OT: Avoid automatic registration with Image Code
  • Next by thread: Cascading Deletes in WO and DB
  • Index(es):
    • Date
    • Thread