views:

120

answers:

2
+1  Q: 

image processing

hi folks, i have some images..if these images are selected then it should generate another image which is the combination of all the selected images.. can anyone suggest as how to start with? thanks

+3  A: 

Use someting like that:

public void MergeImages(string FirstFileName, string SecondFileName)
{
    Image firstImg = Image.FromFile(@"C:\temp\pic1.jpg");
    Image secondImg = Image.FromFile(@"C:\temp\pic2.jpg");
    Bitmap im1 = new Bitmap(firstImg);
    Bitmap im2 = new Bitmap(secondImg);
    Bitmap result = new Bitmap(im1.Width + im2.Width, (im1.Height > im2.Height) ? im1.Height : im2.Height);
    Graphics gr = Graphics.FromImage(result);
    gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
    gr.DrawImage(firstImg, 0, 0);
    gr.DrawImage(secondImg, im1.Width + 1, 0);
    gr.Save();
    result.Save(@"C:\test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}

this code merges two images in one, systeming them into line.

Stremlenye
Sam, the answer above is a good start... I would suggest you spend a little time reading up on picture handling using the supplied help ... http://msdn.microsoft.com/en-us/library/ms748873.aspxseems a good starting place,thanks, Neil
Neil
I think, using low-width rectangles. You can easely write a function for it. If its hard, write hear- i can help.
Stremlenye
A: 

Hi,

i used ImageMagick to do these kind of things (http://www.imagemagick.org/Usage/layers/)

It is however a little bit different then using gdi to create images, but it is a very fast (and when you get used to the imagemagick syntax) and powerful way to edit images.

Normally you use gdi to edit images in memory; imagemagick uses a commandline utility to create images.

So for example you want to layer two images on top, you start a new process in your code in which you fire up a imagemagick proces with the right parameters and then the image is created ON DISK. Then you can server the created image with a response.writebinary.

Michel