Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27087

VS 2010 Crop and save an image

$
0
0
i couldnt crop and save an image.Here is my codes.
Rect is my drawed rectangle.
Code:

Dim save As SaveFileDialog = New SaveFileDialog
        save.Filter = "Jpeg File(*.jpg)|*.jpg"
        If save.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim source As Bitmap = New Bitmap(PictureBox1.ImageLocation)
            Dim DestRect As New Rectangle(0, 0, Rect.Width, Rect.Height)
            Dim DestBmp As New Bitmap(Rect.Width, Rect.Height)
            Dim g As Graphics = Graphics.FromImage(DestBmp)
            g.DrawImage(source, DestRect, Rect, GraphicsUnit.Pixel)
            g.Dispose()
            DestBmp.Save(save.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
            DestBmp.Dispose()
        End If

any help please?

Viewing all articles
Browse latest Browse all 27087

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>