Link to home
Start Free TrialLog in
Avatar of Millkind
MillkindFlag for Afghanistan

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(Files(FILENUMBER)), Bitmap)
            '' pbdigitalphotos.SizeMode = PictureBoxSizeMode.AutoSize
            pbdigitalphotos.Image = bitmapimage
        Catch ex As System.IO.FileNotFoundException
            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(bitmapimage)
        'Clean up the image
        converted.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
        converted.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor
        converted.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half
        converted.DrawImage(bitmapimage, 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.PaintEventArgs) 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(pbimagetosave.Image.GetBounds(GraphicsUnit.Pixel))
            Dim wid As Integer = pbimagetosave.Image.Width
            Dim hgt As Integer = pbimagetosave.Image.Height

            image_attr.SetColorMatrix(cm)
            e.Graphics.DrawImage(pbimagetosave.Image, 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.
ASKER CERTIFIED SOLUTION
Avatar of Ark
Ark
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Millkind

ASKER

Wow that zoom and brightness are great.  Any idea how to get a viewfinder to always stay on top of the original image?
Or is there a way to make it so that the veiwfinder could be dragged around the original image with the mouse?
okay got the viewfinder done with staying on top and transparency am working on getting it to move around now.
viewfinder movement is done.