Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click, tsSave.Click
- sfd1.FileName = "defaultFile"
- sfd1.Filter = "Jpg (*.jpg)|*.jpg|BMP (*.bmp)|*.bmp|All Files (*.*)|*.*"
- If sfd1.ShowDialog = Windows.Forms.DialogResult.OK Then
- Console.WriteLine(sfd1.FileName)
- End If
- End Sub
- #Region "Cropping"
- Dim cropX As Integer
- Dim cropY As Integer
- Dim cropWidth As Integer
- Dim cropHeight As Integer
- Dim oCropX As Integer
- Dim oCropY As Integer
- Dim cropBitmap As Bitmap
- Public cropPen As Pen
- Public cropPenSize As Integer = 2
- Public cropDashStyle As Drawing2D.DashStyle = Drawing2D.DashStyle.Solid
- Public cropPenColor As Color = Color.Red
- Private Sub pictureHold_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pictureHold.MouseDown
- Try
- If e.Button = Windows.Forms.MouseButtons.Left Then
- cropX = e.X
- cropY = e.Y
- cropPen = New Pen(cropPenColor, cropPenSize)
- cropPen.DashStyle = DashStyle.DashDotDot
- Cursor = Cursors.Hand
- End If
- pictureHold.Refresh()
- Catch exc As Exception
- End Try
- End Sub
- Dim tmppoint As Point
- Private Sub pictureHold_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pictureHold.MouseMove
- Try
- If pictureHold.Image Is Nothing Then Exit Sub
- If e.Button = Windows.Forms.MouseButtons.Left Then
- pictureHold.Refresh()
- cropWidth = e.X - cropX
- cropHeight = e.Y - cropY
- pictureHold.CreateGraphics.DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight)
- End If
- Catch exc As Exception
- If Err.Number = 5 Then Exit Sub
- End Try
- End Sub
- Private Sub pictureHold_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pictureHold.MouseUp
- Try
- Cursor = Cursors.Default
- Try
- If cropWidth < 1 Then
- Exit Sub
- End If
- Dim rect As Rectangle = New Rectangle(cropX, cropY, cropWidth, cropHeight)
- Dim bit As Bitmap = New Bitmap(pictureHold.Image, pictureHold.Width, pictureHold.Height)
- cropBitmap = New Bitmap(cropWidth, cropHeight)
- Dim g As Graphics = Graphics.FromImage(cropBitmap)
- g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
- g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
- g.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
- g.DrawImage(bit, 0, 0, rect, GraphicsUnit.Pixel)
- pbPrev.Image = cropBitmap
- Catch exc As Exception
- End Try
- Catch exc As Exception
- End Try
- End Sub
- Private Sub btnCrop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCrop.Click
- If tmrSlide.Enabled = True Then
- tmrSlide.Enabled = False
- End If
- pictureHold.Image = cropBitmap
- End Sub
- #End Region
- #Region "Brightness"
- Private Sub tsBright_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsBright.Click
- If btnBright.Visible = False Then
- MessageBox.Show("Click the Bright Button Again To Remove Preview", "Cropping")
- btnCrop.Visible = False
- btnUndo.Visible = True
- pbPrev.Visible = False
- btnBright.Visible = True
- pbBright.Visible = True
- brightScroll.Visible = True
- Else
- brightScroll.Visible = False
- btnCrop.Visible = False
- btnUndo.Visible = False
- pbBright.Visible = False
- btnBright.Visible = False
- End If
- pbBright.Image = pictureHold.Image
- Dim r, g, b, height, width As Integer
- Dim tempPicture As Bitmap = pbBright.Image
- Dim colorOfPixel As Color
- Dim brightness As Double
- brightness = 1 + (0.01 * brightScroll.Value)
- height = tempPicture.Height - 1
- width = tempPicture.Width - 1
- For x As Integer = 1 To width
- For y As Integer = 1 To height
- colorOfPixel = tempPicture.GetPixel(x, y)
- r = colorOfPixel.R * brightness
- g = colorOfPixel.G * brightness
- b = colorOfPixel.B * brightness
- validateRGB(r, g, b)
- tempPicture.SetPixel(x, y, Color.FromArgb(255, r, g, b))
- Next
- Next
- pbBright.Image = tempPicture
- End Sub
- Private Sub validateRGB(ByVal r As Integer, ByVal g As Integer, ByVal b As Integer)
- If r > 255 Or r < 0 Then
- MessageBox.Show("Out Of Range, Resetting", "Out of range exception")
- ElseIf g > 255 Or g < 0 Then
- MessageBox.Show("Out Of Range, Resetting", "Out of range exception")
- ElseIf b > 255 Or b < 0 Then
- MessageBox.Show("Out Of Range, Resetting", "Out of range exception")
- End If
- End Sub
- #End Region
Add Comment
Please, Sign In to add comment