开发者

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 star开发者_StackOverflow社区t 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜