<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1139862891621576766</id><updated>2012-01-24T03:04:46.518-08:00</updated><title type='text'>JAVA Hints,Tips and E Books</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javaexamebooks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1139862891621576766/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://javaexamebooks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sameera Dinusha</name><uri>http://www.blogger.com/profile/11036613699274347100</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://4.bp.blogspot.com/_B4c2KvEYAZ0/SMdwJBWqx-I/AAAAAAAAAFY/W6KGK2IxeR0/S220/DSC0061700.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1139862891621576766.post-4159489324524300654</id><published>2010-03-30T23:41:00.000-07:00</published><updated>2010-03-30T23:49:49.139-07:00</updated><title type='text'>Ant build.xml for a Simple web application....</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_B4c2KvEYAZ0/S7LwMqtjBJI/AAAAAAAAAOY/UiWolaeRK7g/s1600/Screenshot-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="236" src="http://2.bp.blogspot.com/_B4c2KvEYAZ0/S7LwMqtjBJI/AAAAAAAAAOY/UiWolaeRK7g/s400/Screenshot-1.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1139862891621576766-4159489324524300654?l=javaexamebooks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaexamebooks.blogspot.com/feeds/4159489324524300654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1139862891621576766&amp;postID=4159489324524300654' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1139862891621576766/posts/default/4159489324524300654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1139862891621576766/posts/default/4159489324524300654'/><link rel='alternate' type='text/html' href='http://javaexamebooks.blogspot.com/2010/03/ant-buildxml-for-simple-web-application.html' title='Ant build.xml for a Simple web application....'/><author><name>Sameera Dinusha</name><uri>http://www.blogger.com/profile/11036613699274347100</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://4.bp.blogspot.com/_B4c2KvEYAZ0/SMdwJBWqx-I/AAAAAAAAAFY/W6KGK2IxeR0/S220/DSC0061700.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_B4c2KvEYAZ0/S7LwMqtjBJI/AAAAAAAAAOY/UiWolaeRK7g/s72-c/Screenshot-1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1139862891621576766.post-2033211148375260342</id><published>2008-06-27T21:57:00.000-07:00</published><updated>2008-09-10T00:24:29.228-07:00</updated><title type='text'>Dynamically Generating jpg &amp; png   Images - JAVA</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;You can add graphics and even texts to a existing image or&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; generate a new one from this method.&lt;/span&gt;Just think that you need to add some text on some background,And generate it dynamically&lt;this style="color: rgb(51, 51, 255);"&gt;.this is the method for that.here it says how to give a picture and change it as we need &lt;span style="color: rgb(51, 51, 255);"&gt;(Adding some graphics) and generate it as a separate jpg or png,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; If you need to generate a completely new one,Just use&lt;/span&gt;&lt;br /&gt;&lt;/this&gt;&lt;/div&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: bold;"&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;                                 File file = new File();&lt;/span&gt;&lt;br /&gt;                                                         &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;insted of the URL as a parameter.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;import javax.imageio.*;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;import java.io.*;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;import java.awt.image.*;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;import java.awt.*;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;import java.lang.*;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;import java.net.*;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;public class Main {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    public static void main(String[] args) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        // TODO code application logic here&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;           // Create an image to save&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;       try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;       {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;           WriteImage();  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;       catch(IOException e)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;       {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;              System.out.println(e.toString());&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    public static void WriteImage() throws IOException&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    {           &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;       &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            RenderedImage rendImage = myCreateImage();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;           // Save as PNG&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;           File file = new File("C:/Program Files/&lt;br /&gt; netbeans-5.5.1/enterprise3/apache-tomcat-5.5.17/webapps/ROOT/FormattedPics/Background.png");&lt;/span&gt; //file path,can be any where elsein your pc, here it uses tomcat webapps folder for some other purpose.&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        ImageIO.write(rendImage, "png", file);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        System.out.println("New Png Created");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;       &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        // Returns a generated image.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    public static RenderedImage myCreateImage() throws IOException&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; //       int width = 100;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;  //      int height = 100;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;      //  Create a buffered image in which to draw&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;      //  BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;//location of the image to be modofied&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;          BufferedImage bufferedImage = ImageIO.read(new URL("http://localhost:8084/SourcePics/newimage.png"));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;       // Create a graphics contents on the buffered image&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;          Graphics2D g2d = bufferedImage.createGraphics();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;// Draw graphics&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;//        g2d.setColor(Color.BLUE);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;//        g2d.fillRect(0, 0, width, height);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;//        g2d.setColor(Color.GREEN);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;//        g2d.fillOval(0, 0, width, height);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;          g2d.drawString("text",40,80);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;          &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        // Graphics context no longer needed so dispose it&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;       g2d.dispose();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     return bufferedImage;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    catch(Exception e)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        System.out.println("Error" + e.toString());&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        return null;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;      &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Plz send your comments here&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1139862891621576766-2033211148375260342?l=javaexamebooks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaexamebooks.blogspot.com/feeds/2033211148375260342/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1139862891621576766&amp;postID=2033211148375260342' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1139862891621576766/posts/default/2033211148375260342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1139862891621576766/posts/default/2033211148375260342'/><link rel='alternate' type='text/html' href='http://javaexamebooks.blogspot.com/2008/06/dynamically-generating-images-of-jpg.html' title='Dynamically Generating jpg &amp; png   Images - JAVA'/><author><name>Sameera Dinusha</name><uri>http://www.blogger.com/profile/11036613699274347100</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://4.bp.blogspot.com/_B4c2KvEYAZ0/SMdwJBWqx-I/AAAAAAAAAFY/W6KGK2IxeR0/S220/DSC0061700.JPG'/></author><thr:total>0</thr:total></entry></feed>
