Resizing Images in VB.NET

前端 未结 6 1075
忘掉有多难
忘掉有多难 2020-12-15 23:40

I\'d like to make a simple VB utility to resize images using vb.net. I am having trouble figuring out what vb class to use to actually manipulate the images. The Image class

6条回答
  •  悲&欢浪女
    2020-12-16 00:09

    Here is an article with full details on how to do this.

    Private Sub btnScale_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnScale.Click
        ' Get the scale factor.
        Dim scale_factor As Single = Single.Parse(txtScale.Text)
    
        ' Get the source bitmap.
        Dim bm_source As New Bitmap(picSource.Image)
    
        ' Make a bitmap for the result.
        Dim bm_dest As New Bitmap( _
            CInt(bm_source.Width * scale_factor), _
            CInt(bm_source.Height * scale_factor))
    
        ' Make a Graphics object for the result Bitmap.
        Dim gr_dest As Graphics = Graphics.FromImage(bm_dest)
    
        ' Copy the source image into the destination bitmap.
        gr_dest.DrawImage(bm_source, 0, 0, _
            bm_dest.Width + 1, _
            bm_dest.Height + 1)
    
        ' Display the result.
        picDest.Image = bm_dest
    End Sub
    

    [Edit]
    One more on the similar lines.

提交回复
热议问题