Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you combine two images side by side into one?

Status
Not open for further replies.

joelwenzel

Programmer
Jun 28, 2002
448
Hi,

I need a way to combine two images into one. I need something that I can say

finalImage = image1 At (x1,y1) + Image2 at (x2,y2)

Basically, I want to paste two images side by side and get one final image as the result.

 
Also, while we are on the subject of images....what exactly is an image observer? I always just write "this" when I do a draw image command such as

g.drawImage(pic,x,y,this)

Is it ever something other than "this"?
 
I wrote a program to read in two BMP files and join them. I based it on code I found here:


The code reads the BMP files into a four-dimensional byte array containing row, column, and colors. It's simple to then copy both arrays into a third larger array and write it back out as a new BMP.
 
hey idarke,

you don't actually go to queen's do you?
 
I think you'd be a lot better off using the BufferedImage class or PlanarImage class from the JAI API rather than folling around with pixels yourself ...




Click here to learn Ways to help with Tsunami Relief
--------------------------------------------------
Free Database Connection Pooling Software
 
No, I don't go to queens. I go wherever google takes me.

I fool around on the pixel level because I'm also doing some manipulation of the images as well as sticking them together. It's necessary because I make drawings larger than my scanner.

The JAI api looks interesting, if complicated. The FAQ gives some solutions to changing color and contrast that involve bit-shifting on byte arrays, so it seems you can't escape pixel-fiddling...
 
I found this to work pretty good for my problem

Image Pic;
...
use Pic
...

Image tmpPic = createImage(width,height);
Graphics g = tmpPic .getGraphics();
g.drawImage(Pic,x1,y1,this);
g.drawImage(newAdditionPic,x2,y2,this);
Pic = tmpPic;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top