Imports System.Drawing
Module MyModule
' ********************************************************
' 指定位置のデスクトップ画像をサムネイルとして保存する
' ********************************************************
Sub Main()
' 文字列の配列
Dim argv As String()
Dim save_path As String
Dim base_x As Integer
Dim base_y As Integer
Dim base_width As Integer
Dim base_height As Integer
Dim target_width As Integer
Dim target_height As Integer
' 引数
argv = System.Environment.GetCommandLineArgs()
' 引数がある場合
if System.Environment.GetCommandLineArgs.Length = 8 then
save_path = argv(1)
base_x = Integer.Parse(argv(2))
base_y = Integer.Parse(argv(3))
base_width = Integer.Parse(argv(4))
base_height = Integer.Parse(argv(5))
target_width = Integer.Parse(argv(6))
target_height = Integer.Parse(argv(7))
else
Console.WriteLine("引数 : 保存するパス 取得開始位置x 取得開始位置y 幅 高さ 保存幅 保存高さ")
Return
end if
Dim bmp As New Bitmap(base_width, base_height)
Dim gra As Graphics = Graphics.FromImage(bmp)
' 画面のキャプチャ
gra.CopyFromScreen(New Point(base_x, base_y), New Point(0, 0), bmp.Size)
' 縮小
Dim thumbnail As Bitmap = New Bitmap(bmp, target_width, target_height)
' 保存
thumbnail.Save(save_path+".jpg", Imaging.ImageFormat.Jpeg )
thumbnail.Dispose()
gra.Dispose()
bmp.Dispose()
End Sub
End Module