Results 1 to 7 of 7
  1. #1
    jeshmal4u is offline Member
    Join Date
    Mar 2010
    Posts
    5
    Rep Power
    0

    Default how to write text on an existing image

    how to write text on an existing image???

    Hi, i am doing a project.. I am not getting the code to write text on an image(doesn't mean stegnography).. can anyone please help me.. its very urgent..

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    jeshmal4u is offline Member
    Join Date
    Mar 2010
    Posts
    5
    Rep Power
    0

    Default

    Thanks for replying sir,
    Actually i dont know how to start with a code, i am thinking of using BufferedImage and tried of modifying the following code at Combine two images using Java - Open Source University Meetup .. but i am not getting the right output.. please give me guidance...

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default

    Construct a BufferedImage
    Obtain its Graphics context
    drawString the text

    If you want more help, ask a specific question. Not "i dont know how to start"

    If that's really your only problem, go through some tutorials. I find thwe ones on the Sun site good.

    db

  5. #5
    jeshmal4u is offline Member
    Join Date
    Mar 2010
    Posts
    5
    Rep Power
    0

    Default

    hi friend.. i have coded.. but its having a bug.. please help on that in my new thread Struggling with AlphaComposite .. please help me

  6. #6
    rochardgems is offline Member
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Default

    I found the watermarking concept for this but not having coding idea on it..

  7. #7
    rtc1 is offline Member
    Join Date
    May 2010
    Location
    northern california
    Posts
    7
    Rep Power
    0

    Default

    If I understand your question correctly, you just need to do something like this:

    BufferedImage bi = ...;
    Graphics2D g2d = ( Graphics2D ) bi.getGraphics();
    g2d.setColor( Color.BLACK );
    g2d.setFont( new Font( "arial", Font.PLAIN, 30 ) );
    g2d.drawString( "Hello World!", bi.getWidth()/2, bi.getHeight()/2 ); // You can use FontMetrics and other classes to get string bounds
    g2d.dispose(); // Don't forget to call dispose()!
    Last edited by rtc1; 05-07-2010 at 06:16 PM. Reason: omitted 2 arguments from drawString()

Similar Threads

  1. How to write text file into Array
    By venkat.ravala in forum New To Java
    Replies: 13
    Last Post: 11-19-2009, 04:59 PM
  2. Update existing buffered image
    By rosh72851 in forum New To Java
    Replies: 24
    Last Post: 12-04-2008, 03:43 AM
  3. Write a List into a Text file
    By tech2000 in forum New To Java
    Replies: 1
    Last Post: 11-13-2008, 05:09 AM
  4. need to add text field on existing dialog
    By SHAshank1 in forum SWT / JFace
    Replies: 0
    Last Post: 07-23-2008, 03:15 PM
  5. How to write an image of a given format
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-25-2008, 10:30 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
  •