久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

圖像或位圖中的 C# 麥田圈

C# crop circle in a image or bitmap(圖像或位圖中的 C# 麥田圈)
本文介紹了圖像或位圖中的 C# 麥田圈的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我相信這很容易,但似乎找不到任何有答案的人.我有一個圖像,我需要從該圖像中剪出一個圓形甚至其他形狀.我需要將此代碼放在 .net c# 中.我在課堂上這樣做,所以它不是 wpf 或 winform.我需要傳遞 x 和 y pos 以及圓的大小.

I am sure its easy but can't seem to find anyone that has the answer. I have an image and I need to cut a circle or even other shapes out of that image. I need this code to be in .net c#. I am doing this in a class so its not wpf or a winform. I will need to pass x and y pos and the size of the circle.

其他選項是 AForge、ImageStatistics.我需要得到一個圓圈(圖像的一部分)并得到 StdDev.

Other option is AForge, ImageStatistics. I need to get a circle (part of the image) and get StdDev.

感謝您的幫助.安德魯

-- 更新到克里斯的帖子.

-- update to chris post.

這是克里斯在 c# 中的帖子.不像他的那么干凈,但這是一個開始.

Here is chris post in c#. Not as clean as his but its a start.

 public System.Drawing.Image x(string sourceFile, int circleUpperLeftX, int circleUpperLeftY, int circleDiameter)
    {
        Bitmap SourceImage = new Bitmap(System.Drawing.Image.FromFile(sourceFile));
        Rectangle CropRect = new Rectangle(circleUpperLeftX, circleUpperLeftY, circleDiameter, circleDiameter);
        Bitmap CroppedImage = SourceImage.Clone(CropRect, SourceImage.PixelFormat);
        TextureBrush TB = new TextureBrush(CroppedImage);
        Bitmap FinalImage = new Bitmap(circleDiameter, circleDiameter);
        Graphics G = Graphics.FromImage(FinalImage);
        G.FillEllipse(TB, 0, 0, circleDiameter, circleDiameter);
        return FinalImage;
    }

推薦答案

您可以使用 紋理刷.下面的代碼將圖像裁剪為正方形,然后將其加載到紋理畫筆中,最后使用該畫筆繪制橢圓/圓:

You can use a TextureBrush. The code below crops the image to a square, then loads that into a texture brush and finally draws an ellipse/circle using that brush:

Private Shared Function CropImageToCircle(ByVal sourceFile As String, ByVal circleUpperLeftX As Integer, ByVal circleUpperLeftY As Integer, ByVal circleDiameter As Integer) As Image
    ''//Load our source image
    Using SourceImage As New Bitmap(Image.FromFile(sourceFile))
        ''//Create a rectangle that crops a square of our image
        Dim CropRect As New Rectangle(circleUpperLeftX, circleUpperLeftY, circleDiameter, circleDiameter)
        ''//Crop the image to that square
        Using CroppedImage = SourceImage.Clone(CropRect, SourceImage.PixelFormat)
            ''//Create a texturebrush to draw our circle with
            Using TB As New TextureBrush(CroppedImage)
                ''//Create our output image
                Dim FinalImage As New Bitmap(circleDiameter, circleDiameter)
                ''//Create a graphics object to draw with
                Using G = Graphics.FromImage(FinalImage)
                    ''//Draw our cropped image onto the output image as an ellipse with the same width/height (circle)
                    G.FillEllipse(TB, 0, 0, circleDiameter, circleDiameter)
                    Return FinalImage
                End Using
            End Using
        End Using
    End Using
End Function

這篇關于圖像或位圖中的 C# 麥田圈的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Right-click on a Listbox in a Silverlight 4 app(右鍵單擊 Silverlight 4 應用程序中的列表框)
WPF c# webbrowser scrolls over top menu(WPF c# webbrowser 在頂部菜單上滾動)
C# Console app - How do I make an interactive menu?(C# 控制臺應用程序 - 如何制作交互式菜單?)
How to avoid duplicate form creation in .NET Windows Forms?(如何避免在 .NET Windows Forms 中創建重復的表單?)
UI Automation Control Desktop Application and Click on Menu Strip(UI自動化控制桌面應用程序并單擊菜單條)
Removing thin border around the menuitems(刪除菜單項周圍的細邊框)
主站蜘蛛池模板: 婷婷免费视频 | 皇色视频在线 | 国产伦精品一区二区三毛 | 日本在线一区二区三区 | 欧美黑人一区 | 国产精品美女久久久 | 中文字幕一区二区三区四区 | 自拍偷拍欧美 | 亚洲精品一区在线 | 99精品在线观看 | 中文一区二区 | 黄色片网此| 国产a视频 | 超碰97av | 亚洲视频在线一区 | 亚洲欧美精品国产一级在线 | 成人免费在线观看视频 | 天天综合久久网 | 亚洲精品v | 国产一级特黄视频 | 国产免费一区二区 | 91欧美激情一区二区三区成人 | 中文字幕国产精品 | 亚洲逼院| 成人亚洲片| 亚洲日韩中文字幕一区 | 日韩毛片 | 午夜午夜精品一区二区三区文 | 国产精品久久久久久久午夜片 | 日本免费在线 | 黄色骚片 | 久久亚洲天堂 | 国产精品激情小视频 | 国产午夜精品一区二区三区嫩草 | 日韩一区二区三区精品 | 亚洲a视频| 国产精品久久久久久久久久久免费看 | 亚洲五码在线 | 亚洲精品一区二区三区蜜桃久 | 精品国产乱码久久久久久丨区2区 | 日韩欧美不卡 |