This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes combining 2 buffered images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "combining 2 buffered images" Watch "combining 2 buffered images" New topic
Author

combining 2 buffered images

manoswa kapoor
Greenhorn

Joined: Oct 10, 2008
Posts: 12
i have created 1 buffered image in "Class A"..."Class B" calls this 'BufferedImage 1' and in "Class B" 'Buffered Image 2' is present....now i want to combine these two images to create one image....please note these images are not loaded these are created in applet using canvas and converted to image object.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

How do you want to combine them? Paste one over the other? Or below / next to each other?

If the latter, create yet another BufferedImage, use its Graphics2D object to paint the images on, dispose the Graphics2D object and you're done.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41134
    
  45
Assuming both images have the same dimensions, you can blend them using the technique outlined in this article, particularly in the paragraph titled "A Better Technique for Blending Images". You only need to determine the weight factor (which would be 0.5 if both images should have the same weight).


Ping & DNS - my free Android networking tools app
manoswa kapoor
Greenhorn

Joined: Oct 10, 2008
Posts: 12
actually i was new to this site so by mistake same question goes to many area....lets continue here

can you tell where to download jai api and hw to work on it??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41134
    
  45
I think JAI lives at jai.dev.java.net; you should be able to find sample code there as well.

You haven't said what you mean by "combine", though - depending on that, it may not be necessary to use JAI, as I said in my previous post.
manoswa kapoor
Greenhorn

Joined: Oct 10, 2008
Posts: 12
here by combine i mean 1 image over another
and i am not getting how to use jai in netbeans
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41134
    
  45
Did you read the article I linked to? It explains how to overlay one image over another without the use of any libraries.
 
Don't get me started about those stupid light bulbs.
 
subject: combining 2 buffered images
 
Similar Threads
Imagej Question
Why isn't my image showing up?
combinine 2 buffered images
Need help with my game.
Combine Buffered Images