Results 1 to 5 of 5
- 03-09-2010, 12:18 PM #1
How to attach two BufferedImage to obtain 1 buffered image
I have a serious trouble to attach two bufferedimage and need to obatain one image from that.. Someone please sudjest me a method...
BuffereImage img1, img2;
Final output should be one image which contain addition of both images... So i should be able to see the both images...
Thank you in advance.....
- 03-09-2010, 10:01 PM #2
1) Create a new Buffered Image with size appropriate to fit the two images.
2) Get the graphics object from the new Buffered Image ('img3.createGraphics();')
3) Draw img1 and img2 to img3 via the graphics object.My Hobby Project: LegacyClone
- 03-10-2010, 02:36 AM #3
Alryt i think i get u... in my case size of the all the images are same..... they are stored in an array callled...
BufferedImage img[2] ;
then i m confuse with what u said about concatanation part.... How i can use your code line
img3.createGraphics(); part to usefully done my taks....
Please help me...
- 03-23-2010, 02:19 AM #4
Senior Member
- Join Date
- Mar 2010
- Posts
- 266
- Rep Power
- 4
Suppose we want to join the images horizontally, so I'm assuming their heights are the same.
Java Code:BufferedImage b1; // available to you already BufferedImage b2; // available to you already BufferedImage result; // if TYPE_INT_ARGB doesn't work for you, play with the other constants result = new BufferedImage (b1.getWidth()+b2.getWidth(), b1.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = result.getGraphics (); g.drawImage (b1, 0, 0, null); // drawing b2 where b1 ended g.drawImage (b2, b1.getWidth (), 0, null); g.dispose (); // at this point, "result" is ready to go.
- 03-23-2010, 03:46 PM #5
Member
- Join Date
- Jul 2009
- Posts
- 20
- Rep Power
- 0
This should place the images just next to eachother..
Java Code:public BufferedImage attachImages(BufferedImage img1, BufferedImage img2) { BufferedImage resultImage = new BufferedImage(img1.getWidth() + img2.getWidth(), img1.getHeight() + img2.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics g = resultImage.getGraphics(); g.drawImage(img1, 0, 0, null); g.drawImage(img2, img1.getWidth(), 0, null); return resultImage; }
Similar Threads
-
how can i attach a worg/image file
By sniffer139 in forum AWT / SwingReplies: 4Last Post: 03-12-2010, 06:49 AM -
Update existing buffered image
By rosh72851 in forum New To JavaReplies: 24Last Post: 12-04-2008, 03:43 AM -
Unable to draw buffered image
By pedjasmek in forum Java 2DReplies: 7Last Post: 08-08-2008, 03:49 PM -
How to convert between SWT Image and AWT BufferedImage
By Java Tip in forum SWTReplies: 0Last Post: 07-02-2008, 08:06 PM -
Struts, Some API to obtain wide and the high one of an image?
By Eric in forum Web FrameworksReplies: 1Last Post: 06-07-2007, 05:06 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks