Parsi Coders
سورس کد تغییر سایز عکس - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: Visual Basic Programming (http://parsicoders.com/forumdisplay.php?fid=39)
+---- انجمن: Visual Basic.Net (http://parsicoders.com/forumdisplay.php?fid=43)
+---- موضوع: سورس کد تغییر سایز عکس (/showthread.php?tid=1560)



سورس کد تغییر سایز عکس - Amin_Mansouri - 01-20-2012

Resize Image
Resizes Image to desired size

با سورس میتونید سایز عکس رو تغییر بدید ( سورس زیر با ویژوال بیسیک دات نوشته شده است)
کد:
'following code resizes picture to fit

        Dim bm As New Bitmap(PictureBox1.Image)
        Dim x As Int32 'variable for new width size
        Dim y As Int32 'variable for new height size

        Dim width As Integer = Val(x) 'image width.

        Dim height As Integer = Val(y) 'image height

        Dim thumb As New Bitmap(width, height)

        Dim g As Graphics = Graphics.FromImage(thumb)

        g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic

        g.DrawImage(bm, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bm.Width, _
bm.Height), GraphicsUnit.Pixel)

        g.Dispose()


      'image path. better to make this dynamic. I am hardcoding a path just for example sake
        thumb.Save("C:\newimage.bmp", _
System.Drawing.Imaging.ImageFormat.Bmp) 'can use any image format

        bm.Dispose()

        thumb.Dispose()

        Me.Close()  'exit app