El PictureBox esta en modo Zoom.
CODIGO:
Imports System.Drawing.Imaging
Public Class Form1
Dim BM As Bitmap
Dim BM2 As Bitmap
Dim DIBUJO As Graphics
Dim REDUCCION As Single
Dim AUMENTO As Single
Private Sub ButtonIMPORTAR_Click(sender As System.Object, e As System.EventArgs) Handles ButtonIMPORTAR.Click
OpenFileDialog1.ShowDialog()
BM = System.Drawing.Bitmap.FromFile(OpenFileDialog1.FileName)
PictureBox1.Image = BM
End Sub
Private Sub ButtonREDUCIR_Click(sender As System.Object, e As System.EventArgs) Handles ButtonREDUCIR.Click
BM2 = New Bitmap(Convert.ToInt32(BM.Width * REDUCCION), Convert.ToInt32(BM.Height * REDUCCION))
DIBUJO = Graphics.FromImage(BM2)
DIBUJO.DrawImage(BM, 0, 0, BM2.Width, BM2.Height)
MsgBox("SE HA CREADO LA IMAGEN CON UNA REDUCCION DEL: " & ((1 - REDUCCION) * 100) & "%")
End Sub
Private Sub ButtonGUARDAR2_Click(sender As System.Object, e As System.EventArgs) Handles ButtonGUARDAR2.Click
SaveFileDialog1.Filter = "BMP|*.bmp|JPG|*.jpg|PNG|*.png"
If (SaveFileDialog1.ShowDialog() = DialogResult.OK) Then
If SaveFileDialog1.FileName.Contains(".bmp") Then
BM2.Save(SaveFileDialog1.FileName, ImageFormat.Bmp)
End If
If SaveFileDialog1.FileName.Contains(".jpg") Then
BM2.Save(SaveFileDialog1.FileName, ImageFormat.Jpeg)
End If
If SaveFileDialog1.FileName.Contains(".png") Then
BM2.Save(SaveFileDialog1.FileName, ImageFormat.Png)
End If
End If
End Sub
Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
REDUCCION = 0.75
End Sub
Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged
REDUCCION = 0.5
End Sub
Private Sub RadioButton3_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton3.CheckedChanged
REDUCCION = 0.25
End Sub
Private Sub RadioButton6_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton6.CheckedChanged
AUMENTO = 1.25
End Sub
Private Sub RadioButton5_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton5.CheckedChanged
AUMENTO = 1.5
End Sub
Private Sub RadioButton4_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton4.CheckedChanged
AUMENTO = 1.75
End Sub
Private Sub ButtonAUMENTAR_Click(sender As System.Object, e As System.EventArgs) Handles ButtonAUMENTAR.Click
BM2 = New Bitmap(Convert.ToInt32(BM.Width * AUMENTO), Convert.ToInt32(BM.Height * AUMENTO))
DIBUJO = Graphics.FromImage(BM2)
DIBUJO.DrawImage(BM, 0, 0, BM2.Width, BM2.Height)
MsgBox("SE HA CREADO LA IMAGEN CON UN AUMENTO DEL: " & ((AUMENTO - 1) * 100) & "%")
End Sub
Private Sub ButtonGUARDAR_Click(sender As System.Object, e As System.EventArgs) Handles ButtonGUARDAR.Click
SaveFileDialog1.Filter = "BMP|*.bmp|JPG|*.jpg|PNG|*.png"
If (SaveFileDialog1.ShowDialog() = DialogResult.OK) Then
If SaveFileDialog1.FileName.Contains(".bmp") Then
BM2.Save(SaveFileDialog1.FileName, ImageFormat.Bmp)
End If
If SaveFileDialog1.FileName.Contains(".jpg") Then
BM2.Save(SaveFileDialog1.FileName, ImageFormat.Jpeg)
End If
If SaveFileDialog1.FileName.Contains(".png") Then
BM2.Save(SaveFileDialog1.FileName, ImageFormat.Png)
End If
End If
End Sub
End Class
No hay comentarios:
Publicar un comentario