[英]image processing
我有一些圖像..如果選擇了這些圖像,那么它應該生成另一幅圖像,該圖像是所有選定圖像的組合..有人可以建議如何開始嗎? 謝謝
使用類似的東西:
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);
}
此代碼將兩個圖像合並為一個,將它們系統化為一行。
我使用ImageMagick來做這些事情( http://www.imagemagick.org/Usage/layers/ )
但是,與使用gdi創建圖像有些不同,但這是一種非常快速的方法(當您習慣了imagemagick語法時),並且是編輯圖像的強大方法。
通常,您使用gdi編輯內存中的圖像; imagemagick使用命令行實用程序來創建圖像。
因此,例如,您想在頂部放置兩個圖像,請在代碼中啟動一個新過程,在該過程中,使用正確的參數啟動imagemagick過程,然后在磁盤上創建圖像。 然后,您可以使用response.writebinary服務創建的圖像。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.