------------------------------------------------------------------------------- Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load PictureBox1.ImageLocation = "s1.png" TrackBar1_Scroll(Nothing, Nothing) End Sub
Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll TextBox1.Text = TrackBar1.Value End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged If TextBox1.Text <> "" Then If (0 <= TextBox1.Text AndAlso TextBox1.Text <= 359) Then TrackBar1.Value = TextBox1.Text ElseIf TextBox1.Text > 359 Then TextBox1.Text = 359 TrackBar1.Value = TextBox1.Text Else TextBox1.Text = 0 TrackBar1.Value = TextBox1.Text End If End If rotateImage1() rotateImage2() End Sub
Private Sub rotateImage1() Dim g As Graphics Dim Img As Image = Image.FromFile("s1.png") Dim backImg As New Bitmap("Blank.jpg")
'描画先とするImageオブジェクトを作成する Dim bmp As New Bitmap(Img.Width, Img.Height) 'ImageオブジェクトのGraphicsオブジェクトを作成する g = Graphics.FromImage(bmp)
'ラジアン単位に変換 Dim d As Double = Single.Parse(TextBox1.Text / (180 / Math.PI)) '新しい座標位置を計算する Dim x As Single = Img.Width / 2.0F Dim y As Single = Img.Height / 2.0F Dim x1 As Single = x + Img.Width / 3.0F * CType(Math.Cos(d), Single) Dim y1 As Single = y + Img.Width / 3.0F * CType(Math.Sin(d), Single) Dim x2 As Single = x - Img.Height / 3.0F * CType(Math.Sin(d), Single) Dim y2 As Single = y + Img.Height / 3.0F * CType(Math.Cos(d), Single) 'PointF配列を作成 Dim destinationPoints() As PointF = {New PointF(Img.Width - x, Img.Height - y), New PointF(x1, y1), New PointF(x2, y2)} 'Dim destinationPoints() As PointF = {New PointF(x, y), New PointF(x1, y1), New PointF(x2, y2)}
------------------------------------------------------------------------------- Private Sub rotateImage2() Dim g As Graphics Dim Img As Image = Image.FromFile("s1.png") Dim backImg As New Bitmap("Blank.jpg")
'描画先とするImageオブジェクトを作成する Dim bmp As New Bitmap(Img.Width, Img.Height) 'ImageオブジェクトのGraphicsオブジェクトを作成する g = Graphics.FromImage(bmp)
PictureBox3.Image = backImg End Sub ------------------------------------------------------------------------------- ワールド変換により画像を平行移動、拡大、縮小、回転して表示する https://dobon.net/vb/dotnet/graphics/transform.html#section1