原創|行業資訊|編輯:李顯亮|2020-07-01 09:40:49.200|閱讀 425 次
概述:如果要創建自己的繪圖實用程序或在Web或桌面應用程序中集成繪圖功能該怎么辦?對于此類情況,Aspose最新推出圖形處理控件
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
在工作中,可能會遇到各種繪圖應用程序(例如MS Paint),它們允許繪制圖形并生成圖像。但是,如果要創建自己的繪圖實用程序或在Web或桌面應用程序中集成繪圖功能該怎么辦?
對于此類情況,Aspose提供了.NET圖形API作為.NET的Aspose.Drawing,這是用于創建與GDI +相同的圖像和繪圖的輕量級解決方案。
無需依賴本機代碼和庫,Aspose.Drawing for .NET允許繪制各種圖形對象,例如直線,圓弧,矩形,多邊形,橢圓形等,以及使用鋼筆和畫筆使用C#或VB.NET創建2D圖形創建2D圖形。
Aspose.Drawing for .NET的概述
Aspose.Drawing for .NET支持以下圖像格式
Aspose.Drawing for .NET支持任何從2.0開始的.NET框架
以下是使用Aspose.Drawing for .NET創建圖像的步驟。
下面的代碼示例演示如何使用C#從頭開始創建圖像。
// Create Bitmap object Bitmap bitmap = new Bitmap(1000, 800, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); // Create and initialize Graphics Graphics graphics = Graphics.FromImage(bitmap); // Create Pen Pen pen = new Pen(Color.FromKnownColor(KnownColor.Blue), 2); // Draw arc graphics.DrawArc(pen, 0, 0, 700, 700, 0, 180); // Create another Pen Pen pen1 = new Pen(Color.FromKnownColor(KnownColor.Red), 2); // Draw ellipse graphics.DrawEllipse(pen1, 10, 10, 900, 700); // Save the drawing into desired image format bitmap.Save(@"drawing.png");
以下是執行此操作的步驟。
下面的代碼示例演示如何使用C#在現有圖像上繪制圖形。
// Initialize Bitmap with the input image Bitmap bitmap = new Bitmap("input.png"); // Initialize graphics Graphics graphics = Graphics.FromImage(bitmap); // Create a Pen Pen pen = new Pen(Color.FromKnownColor(KnownColor.Orange), 4); // Draw polygon graphics.DrawPolygon(pen, new Point[] { new Point(100, 100), new Point(500, 400), new Point(900, 100) }); // Save the drawing into desired image format bitmap.Save(@"drawing_updated.png");
輸出結果
還想要更多嗎?您可以點擊閱讀【2019 · Aspose最新資源整合】,查找需要的教程資源。可聯系快速了解!
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn