Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try To Fill RectangleShape with image but when I try to fill İmage than it is not fit into the Drawed Shape. Not Stretched Mode.

What I have tried:

VB
Public Sub FillRectangle(ByVal g As Graphics, ByVal brush As Brush, ByVal x As Decimal, ByVal y As Decimal, ByVal width As Decimal, ByVal height As Decimal, ByVal radius As Decimal)
        Dim area As Rectangle = New Rectangle(x, y, width, height)
        Dim path As New Drawing2D.GraphicsPath

        'Add the corners
        path.AddArc(area.Left, area.Top, radius * 2, radius * 2, 180, 90) 'Upper-Left
        path.AddArc(area.Right - (radius * 2), area.Top, radius * 2, radius * 2, 270, 90) 'Upper-Right
        path.AddArc(area.Right - (radius * 2), area.Bottom - (radius * 2), radius * 2, radius * 2, 0, 90) 'Lower-Right
        path.AddArc(area.Left, area.Bottom - (radius * 2), radius * 2, radius * 2, 90, 90) 'Lower-Left

        'Fill the rounded rectangle
        g.FillPath(brush, path)
    End Sub


VB
Private Sub PrintDocument2_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument2.PrintPage
        e.Graphics.PageUnit = GraphicsUnit.Millimeter
        e.Graphics.ResetTransform()
        PrintDocument2.OriginAtMargins = True
        Dim grpX As Graphics = e.Graphics

        Dim newImage As Image = Drawing.Image.FromFile("C:\Users\Yaman\Desktop\Frames\243.png")
        Dim brsh As New TextureBrush(newImage)

        FillRectangle(grpX, brsh, CDec(4.65), CDec(12.9), CDec(99.1), CDec(33.9), 5)

    End Sub
Posted
Comments
evry1falls 6-May-20 16:15pm    
Do you mean, it did not work in Stretch Mode, only? or it did not work at all ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900