掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
画像を縮小するには? (ID:145975)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
この手は得意じゃ〜ないのですが・・・ Imports System.Drawing Public Class Form1 Private orgBmp As Bitmap Private dstBmp As Bitmap Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load orgBmp = Nothing dstBmp = Nothing End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim szBmp As String If orgBmp IsNot Nothing Then orgBmp.Dispose() orgBmp = Nothing End If If dstBmp IsNot Nothing Then dstBmp.Dispose() dstBmp = Nothing End If szBmp = Application.StartupPath + "\file_icon.bmp" orgBmp = New Bitmap(szBmp) dstBmp = ConvertBMP(orgBmp, 50.0) dstBmp.Save(Application.StartupPath + "\conv.bmp") Using g As Graphics = PictureBox1.CreateGraphics g.DrawImage(orgBmp, 0, 0, orgBmp.Width, orgBmp.Height) End Using Using g As Graphics = PictureBox2.CreateGraphics g.DrawImage(dstBmp, 0, 0, dstBmp.Width, dstBmp.Height) End Using End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Close() End Sub Private Function ConvertBMP(ByVal org As Bitmap, ByVal p As Single) As Bitmap Using dst As Bitmap = New Bitmap(CInt(CSng(org.Width * p / 100.0)), CInt(CSng(org.Height * p / 100.0))) Using g As Graphics = Graphics.FromImage(dst) g.DrawImage(org, 0, 0, dst.Width, dst.Height) End Using ConvertBMP = dst.Clone End Using GC.Collect() End Function End Class こんなんで如何? 以上。参考まで・・・
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.