简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM