本文介绍了如何获得矩形内部的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。



我画了一张矩形画在画面上。我的矩形旋转了。我想得到矩形中的确切内容,但是当我尝试时,我得到另一个内容,我的矩形边框的某些部分可见。你能帮助我吗?



这是我的系数。你能告诉我它出了什么问题吗?谢谢。



Hi here.

I have a rectangle that i draw on a picture. My rectangle is rotated. I want to get exactly what is in the rectangle but when i try, i get another content with some parts of of my rectangle's borders visible. Can you help me ?

Here is my coee. Could you please tell me what is going wrong with it ? Thank you.

            Dim pt1 As PointF = New Point(x, y)                         '' Point de départ du rectangle
            Dim pt2 As PointF = New Point(x + width, y)                 '' Point de coordonnées X + largeur, Y
            Dim pt3 As PointF = New Point(x, y + height)                '' Point de coordonnées X , Y + hauteur
            Dim pt4 As PointF = New Point(x + width, y + height)        '' Point de coordonnées X + largeur , Y + hauteur

<pre lang="vb">' RRotatePoint is the function i use to rotate points

            pt1 = RRotatePoint(pt1, angle_r, origine)
            pt2 = RRotatePoint(pt2, angle_r, origine)
            pt3 = RRotatePoint(pt3, angle_r, origine)
            pt4 = RRotatePoint(pt4, angle_r, origine)

            draw = True
            Dim g As Graphics = Graphics.FromImage(Pic_Pic.Image)
            Dim pen1 As Pen = New Pen(couleur, 2)
            
            g.DrawLines(pen1, New Point() {Point.Round(pt1), Point.Round(pt2), Point.Round(pt4), Point.Round(pt3), Point.Round(pt1)})

            g.Save()

                <pre lang="vb">' get the part captured in the rectangle in color en display it in a picturebox
                Dim imh As Bitmap = New Bitmap(Pic_Pic.Image)
                Dim imi As Bitmap = Nothing
                Dim imig As Graphics = Nothing

                imi = New Bitmap(CInt(width), CInt(height))
                imig = Graphics.FromImage(imi)
                imig.DrawImage(imh, 0, 0, New System.Drawing.Rectangle(posX, posY, widX, heiY), GraphicsUnit.Pixel)</pre>

推荐答案

这篇关于如何获得矩形内部的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 06:53