Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

On the fly graphic text

I am sure I once used a program that took text an transformed it to a graphic.

It was a rectangle o a certain color with the text of a certain font.

The rectangle, font and color where the parameters. It was simple and did the job

I need it but cannot find any

0
robrodp
Asked:
robrodp
2 Solutions
 
objectsCommented:
can you explain a little more exactly what you are after?

Heres some examples of transforing text if that helps
http://java.sun.com/docs/books/tutorial/2d/display/transforming.html
0
 
petmagdyCommented:
Hi robrodp,

not sure but this may be what u want:

http://www.programurl.com/fly-animator-free-java-animation-maker.htm


Cheers!
0
 
petmagdyCommented:
also check this one, I think this is what u need:

http://www.javalobby.org/java/forums/t17096.html
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
robrodpAuthor Commented:
The idea is you pass through asp code some text a word for example: Mexico (or whatever) and you give a program ( I remember it was .class java) the characteristics you need, size, colors, and font ant the html displays the text as a graphic
0
 
petmagdyCommented:
robrodp,

check the last url I think this is what u need
0
 
bloodredsunCommented:
Here's an example of a servlet that does just that, as the servlet checks the request parameters for String to write into the image.

----------------
package com.bloodredsun.servlet;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/*
 * @author bloodredsun
 * @return
 */

public class ImageServlet extends HttpServlet {

     public void doGet(HttpServletRequest req, HttpServletResponse resp)
          throws ServletException, IOException {

          ServletOutputStream sos = resp.getOutputStream();
          resp.setContentType("image/jpg");
         
          String imgString = req.getParameter("str")!=null ? req.getParameter("str") : "Test Me" ;

          // Create an image to output
          RenderedImage rendImage = myCreateImage( imgString );

          try {
               ImageIO.write(rendImage, "jpg", sos);
          } catch (IOException e) {
               System.out.println("Error:" + e.getMessage());
          }
     }

     public void doPost(HttpServletRequest req, HttpServletResponse resp)
          throws ServletException, IOException {
          doGet(req, resp);
     }

     /**
      * @return RenderedImage
      */
     private RenderedImage myCreateImage( final String pString ) {
          int width = 100;
          int height = 50;

          // Create a buffered image in which to draw
          BufferedImage bufferedImage =
               new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

          // Create a graphics contents on the buffered image
          Graphics2D g2d = bufferedImage.createGraphics();

          // Draw graphics
          g2d.setColor(Color.pink);
          g2d.fillRect(0, 0, width, height);
          g2d.setColor(Color.black);
          g2d.drawString(pString, 50, 25);

          // Graphics context no longer needed so dispose it
          g2d.dispose();

          return bufferedImage;
     }
}
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now