Visual Basic 中学校 掲示板 投稿の管理
タグのない投稿を抽出
統計
RSS
Visual Basic 中学校
投稿一覧
SelectActiveFrameについて
この投稿へのリンク
https://keijiban.umayadia.com/ThreadDetail.aspx?ThreadId=30487#CommentId83947
この投稿の削除
削除パスワード
削除する
コメント本文
投稿者
葉月
 (社会人)
投稿日時
2020/5/1 22:05:01
Public Class Form1
Private STR_FILE_PATH = "画像パス"
Private listImgs As List(Of Image)
Public Sub New()
InitializeComponent()
listImgs = New List(Of Image)()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
ShowImage(STR_FILE_PATH)
End Sub
Private Sub ShowImage(ByVal fileName As String)
Dim canvas As Bitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
Dim g As Graphics = Graphics.FromImage(canvas)
Dim img As Image = Image.FromFile(STR_FILE_PATH)
Dim fd As System.Drawing.Imaging.FrameDimension = New System.Drawing.Imaging.FrameDimension(img.FrameDimensionsList(0))
Dim frameCount As Integer = img.GetFrameCount(fd)
Dim y As Integer = 0
For i As Integer = 0 To frameCount - 1
img.SelectActiveFrame(fd, i)
Dim imgClone As Image = CType(img.Clone(), Image)
listImgs.Add(imgClone)
'imgClone.Dispose()
Next
img.Dispose()
g.Dispose()
PictureBox1.Image = canvas
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim canvas As Bitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
Dim g As Graphics = Graphics.FromImage(canvas)
Dim x As Integer = 0, y As Integer = 0
For Each img As Image In listImgs
g.DrawImage(img, x, y, img.Width, img.Height)
If x < PictureBox1.Width Then
x += img.Width
Else
y += img.Height
x = 0
End If
Next
g.Dispose()
PictureBox1.Image = canvas
End Sub
End Class