且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将矩形图像转换为圆形图像

更新时间:2023-11-09 22:29:10

我认为您需要提供有关您尝试执行的操作的更多信息.例如....

您正在处理哪种图像?
您想实现哪种转换,即裁剪,拉伸等?
I think you need to provide more information about what you are trying to do. For example ....

What sort of images are you dealing with?
What sort of conversion do you want to achieve ie crop, stretch etc?


我明白了.这段代码已经实现了

I got it.this code has done it

Private Sub btnExport0_Click()
        Try
            Dim path As String = Server.MapPath(Request.QueryString("imgpath"))
            Dim imgin As System.Drawing.Image = System.Drawing.Image.FromFile(path)
            Dim bitmap As New System.Drawing.Bitmap(imgin.Width, imgin.Height)
            Dim g As Graphics = Graphics.FromImage(bitmap)

            g.Clear(Color.Black)

            Dim brush As New System.Drawing.TextureBrush(imgin)


            g.FillEllipse(brush, New Rectangle(0, 0, imgin.Width, imgin.Height))

            g.Dispose()

            Response.Clear()
            Response.ContentType = "image/pjpeg"
            bitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
            Response.End()
            bitmap.Dispose()

        Catch ex As Exception

        End Try
    End Sub