SAK
SAK

Reputation: 3898

image processing

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

Upvotes: 1

Views: 408

Answers (2)

Michel
Michel

Reputation: 23645

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.

Upvotes: 0

Stremlenye
Stremlenye

Reputation: 595

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.

Upvotes: 3

Related Questions