|
■No77044 (Hongliang さん) に返信 > g.DrawImage等を使います。
ありがとうございます。 早速、コードに取り込んでみました。
Imports System.Drawing.Drawing2D
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim canvas As New Bitmap(PictureBox1.Width, PictureBox1.Height) Dim g As Graphics = Graphics.FromImage(canvas)
Dim bmp As New Bitmap("e:\~01_VisualBasicサンプルPG作成\20150907_vb2010_画像Clip\clip_Bmp.bmp") g.DrawImage(bmp, 0, 0, bmp.Width, bmp.Height) bmp.Dispose()
Dim gpath As New GraphicsPath() Dim points As Point() = {New Point(97, 82), _ New Point(219, 62), _ New Point(236, 202), _ New Point(115, 188)} gpath.AddLine(points(0), points(1)) gpath.AddLine(points(1), points(2)) gpath.AddLine(points(2), points(3)) gpath.AddLine(points(3), points(0))
Dim rgn As New Region(gpath)
' ----- 描画先 Dim cut_canvas As New Bitmap(PictureBox2.Width, PictureBox2.Height) Dim cut_g As Graphics = Graphics.FromImage(cut_canvas)
cut_g.Clip = rgn cut_g.DrawImage(canvas, 0, 0)
PictureBox2.Image = cut_canvas cut_g.Dispose() rgn.Dispose()
End Sub End Class
無事に想定した内容で表示されました。
魔界の仮面弁士さん、shuさん、Hongliangさん、ありがとうございました。
|