Total members 11895 |It is currently Sun Dec 22, 2024 12:19 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Image Files Generation in java
Code:
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.ImageIO;

public class GenerateImageType {
  static public void main(String args[]) throws Exception {
      int width = 200, height = 180;
      BufferedImage bufferedImage = new BufferedImage(width, height,
               BufferedImage.TYPE_INT_ARGB);
      Graphics2D g2d = bufferedImage.createGraphics();
    
    Font font 
= new Font("Arial", Font.BOLD, 24);
      g2d.setFont(font);
      String text = "Welcome!";
      FontMetrics fontMetrics = g2d.getFontMetrics();
      int stringWidth = fontMetrics.stringWidth(text);
      int stringHeight = fontMetrics.getAscent();
      g2d.setPaint(Color.black);
      g2d.drawString(text, (width - stringWidth) / 2, height / 2 + 
              stringHeight 
/ 4);
      
    ImageIO
.write(bufferedImage, "gif", new File("C:\\image.GIF"));
      ImageIO.write(bufferedImage, "JPEG", new File("C:\\image.JPG"));
      ImageIO.write(bufferedImage, "PNG", new File("C:\\image.PNG"));
      ImageIO.write(bufferedImage, "BMP", new File("C:\\image.BMP"));
      ImageIO.write(bufferedImage, "TIF", new File("C:\\image.TIF"));
   }
}
 




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Image Files Generation
 About Report Generation     -  
 dynamic crystal report generation     -  
 Basic daynamic page generation using CGIs programs     -  
 Image-Viewer-Image Processing-Filters-Noise-enhancements     -  
 Move image in front of a background image     -  
 different between cfa image and gray level image     -  
 Get all files in folder     -  
 moving files in php     -  
 Merging JAR files     -  
 jar files commands     -  



Topic Tags

Java Image
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com