Millkind
asked on
VB.net Photo Manipulation Software
I need to write some custom photo software. We are getting digital pictures of students in and need to save them to our ID production software. The students are having a difficult time getting the sizing and proportions down so we need the software to do certain things.
Open the picture from different extensions.
Rotate the picture.
Zoom in/out
Lighten/Darken.
Move the part of the picture into a viewfinder.
Save the part of the photo inside the viewfinder as a .jpg
I started by converting the incoming photo to a bitmap then wrote my controls.
Private Sub InitializeImage()
Try
bitmapimage = CType(Bitmap.FromFile(File s(FILENUMB ER)), Bitmap)
'' pbdigitalphotos.SizeMode = PictureBoxSizeMode.AutoSiz e
pbdigitalphotos.Image = bitmapimage
Catch ex As System.IO.FileNotFoundExce ption
MessageBox.Show("There was an error. Check the path to the bitmap.")
End Try
End Sub
The zoom seems to distort the image when i go in and out.
Public Sub ZoomImage(ByRef ZoomValue As Double)
bitmapimage = New Bitmap(bitmapimage, (bitmapimage.Width / ZoomValue), (bitmapimage.Height / ZoomValue))
'Create a new graphics object based on the new image
Dim converted As Graphics = Graphics.FromImage(bitmapi mage)
'Clean up the image
converted.InterpolationMod e = Drawing2D.InterpolationMod e.HighQual ityBicubic
converted.InterpolationMod e = System.Drawing.Drawing2D.I nterpolati onMode.Nea restNeighb or
converted.PixelOffsetMode = System.Drawing.Drawing2D.P ixelOffset Mode.Half
converted.DrawImage(bitmap image, 0, 0)
pbdigitalphotos.Image = bitmapimage
End Sub
the Lighten/Darken just goes black or white.
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.Paint EventArgs) Handles pbimagetosave.Paint
Try
Dim brt As Single = sbbrightness.Value / 100
Dim image_attr As New Imaging.ImageAttributes
Dim cm As Imaging.ColorMatrix = New Imaging.ColorMatrix(New Single()() _
{ _
New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 1.0, 0.0}, _
New Single() {brt, brt, brt, 1.0, 1.0}})
Dim rect As Rectangle = _
Rectangle.Round(pbimagetos ave.Image. GetBounds( GraphicsUn it.Pixel))
Dim wid As Integer = pbimagetosave.Image.Width
Dim hgt As Integer = pbimagetosave.Image.Height
image_attr.SetColorMatrix( cm)
e.Graphics.DrawImage(pbima getosave.I mage, rect, 0, 0, wid, _
hgt, GraphicsUnit.Pixel, image_attr)
Catch
End Try
End Sub
I can't get the viewfinder to stay ontop of the picture. Using the rectangle draw.
Am i going about this the wrong way? Is there a better way to do the picture changing subs? Just dont want to continue if the basic are not sound. Any help would be great.
Open the picture from different extensions.
Rotate the picture.
Zoom in/out
Lighten/Darken.
Move the part of the picture into a viewfinder.
Save the part of the photo inside the viewfinder as a .jpg
I started by converting the incoming photo to a bitmap then wrote my controls.
Private Sub InitializeImage()
Try
bitmapimage = CType(Bitmap.FromFile(File
'' pbdigitalphotos.SizeMode = PictureBoxSizeMode.AutoSiz
pbdigitalphotos.Image = bitmapimage
Catch ex As System.IO.FileNotFoundExce
MessageBox.Show("There was an error. Check the path to the bitmap.")
End Try
End Sub
The zoom seems to distort the image when i go in and out.
Public Sub ZoomImage(ByRef ZoomValue As Double)
bitmapimage = New Bitmap(bitmapimage, (bitmapimage.Width / ZoomValue), (bitmapimage.Height / ZoomValue))
'Create a new graphics object based on the new image
Dim converted As Graphics = Graphics.FromImage(bitmapi
'Clean up the image
converted.InterpolationMod
converted.InterpolationMod
converted.PixelOffsetMode = System.Drawing.Drawing2D.P
converted.DrawImage(bitmap
pbdigitalphotos.Image = bitmapimage
End Sub
the Lighten/Darken just goes black or white.
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.Paint
Try
Dim brt As Single = sbbrightness.Value / 100
Dim image_attr As New Imaging.ImageAttributes
Dim cm As Imaging.ColorMatrix = New Imaging.ColorMatrix(New Single()() _
{ _
New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 1.0, 0.0}, _
New Single() {brt, brt, brt, 1.0, 1.0}})
Dim rect As Rectangle = _
Rectangle.Round(pbimagetos
Dim wid As Integer = pbimagetosave.Image.Width
Dim hgt As Integer = pbimagetosave.Image.Height
image_attr.SetColorMatrix(
e.Graphics.DrawImage(pbima
hgt, GraphicsUnit.Pixel, image_attr)
Catch
End Try
End Sub
I can't get the viewfinder to stay ontop of the picture. Using the rectangle draw.
Am i going about this the wrong way? Is there a better way to do the picture changing subs? Just dont want to continue if the basic are not sound. Any help would be great.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Or is there a way to make it so that the veiwfinder could be dragged around the original image with the mouse?
ASKER
okay got the viewfinder done with staying on top and transparency am working on getting it to move around now.
ASKER
viewfinder movement is done.
ASKER