Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

    Smile [SOLVED] How can i merge 2 images?

    I want to join 2 images. Can i create a tiled image with 2 tiles and add these 2 images to the tiles of the tiled image? Is this possible? Is there any other way of joining images?

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Sounds like you have the right idea.
    Java Code:
    BufferedImage image1 has size[100, 200]
    BufferedImage image2 has size[150, 150]
    int w = image1.width + image2.width;
    int h = Math.max(image1.height, image2.height);
    BufferedImage image = new BufferedImage(w, h, yourType);
    Graphics2D g2 = image.createGraphics();
    g2.drawImage(image1, 0, 0, imageObserver);
    g2.drawImage(image2, 100, 25, imageObserver);
    g2.dispose();

  3. #3
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

    Default

    thank you. That solved the problem.

    angeline

  4. #4
    forumgopi is offline Member
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default How to set the x,y coordinates?

    g2.drawImage(image1, 0, 0, imageObserver);
    g2.drawImage(image2, 100, 25, imageObserver);
    What is the value 25 refers to if 100 is the width of the first image?

    Help me to set the coordinate values.

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

    Default

    Please start a new thread for your question and don't revive old dead threads or hijack another poster's thread.

    db

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

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Please start a new thread for your question and don't revive old dead threads or hijack another poster's thread.

    db
    Agree. Locking thread.

Similar Threads

  1. Merge Two Xml files ????
    By alwz_nikhil in forum XML
    Replies: 5
    Last Post: 01-18-2011, 09:18 AM
  2. Merge XML using XSL
    By palanikumark in forum XML
    Replies: 1
    Last Post: 08-16-2008, 12:14 AM
  3. Replies: 1
    Last Post: 03-27-2008, 05:06 PM
  4. Merge 2 button become one
    By banie in forum AWT / Swing
    Replies: 1
    Last Post: 02-17-2008, 05:26 PM
  5. Merge Sort Help
    By Hollywood in forum New To Java
    Replies: 5
    Last Post: 01-30-2008, 03:26 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
  •