advanced image conversion help

fisherboy998

New member
Joined
May 17, 2013
Messages
4
Programming Experience
Beginner
currently i have this piece of code,
but regardless of howmany attempts i do in modifying it, it doesn't work, and when it does: i get the same quality image over and over...

here is my piece of code: (it doesn't give errors, but im sure it is not good, and i can't seem to find the solution for it...)
can somebody please help me out with a little coding... :O


VB.NET:
        Dim imgTmp As System.Drawing.Image
            Dim w As Integer


            imgTmp = PictureBox1.Image
        Dim recDest As New Rectangle(0, 0, w, 1600)
        Dim gphCrop As Graphics = Graphics.FromImage(imgTmp)
        gphCrop.SmoothingMode = SmoothingMode.HighSpeed
        gphCrop.CompositingQuality = CompositingQuality.HighSpeed
        gphCrop.InterpolationMode = InterpolationMode.Default
            gphCrop.DrawImage(imgTmp, recDest, 0, 0, imgTmp.Width, imgTmp.Height, GraphicsUnit.Pixel)


            'Dim myImageCodecInfo As System.Drawing.Imaging.ImageCodecInfo  
            Dim myEncoder As System.Drawing.Imaging.Encoder
            Dim myEncoderParameter As System.Drawing.Imaging.EncoderParameter
            Dim myEncoderParameters As System.Drawing.Imaging.EncoderParameters


            Dim arrayICI() As System.Drawing.Imaging.ImageCodecInfo = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()
            Dim jpegICI As System.Drawing.Imaging.ImageCodecInfo = Nothing
            Dim x As Integer = 0
            For x = 0 To arrayICI.Length - 1
                If (arrayICI(x).FormatDescription.Equals("JPEG")) Then
                    jpegICI = arrayICI(x)
                    Exit For
                End If
            Next
            myEncoder = System.Drawing.Imaging.Encoder.Quality
            myEncoderParameters = New System.Drawing.Imaging.EncoderParameters(1)
            myEncoderParameter = New System.Drawing.Imaging.EncoderParameter(myEncoder, 60L)
        myEncoderParameters.Param(0) = myEncoderParameter
        imgTmp.Save(TextBox3.Text & "\" & "afbeelding2.jpeg", jpegICI, myEncoderParameters)
            imgTmp.Dispose()
 
Hi,
What is it you are wanting to do? If you are asking about the quality of the image you have to encode the image before saving like so
VB.NET:
 SmoothingMode = Drawing2D.SmoothingMode.HighQuality
            SmoothingMode = CompositingQuality.HighQuality
            SmoothingMode = SmoothingMode.HighSpeed
            SmoothingMode = SmoothingMode.HighQuality
            InterpolationMode = InterpolationMode.High
            PixelOffsetMode = PixelOffsetMode.HighQuality
Then you have to actually save the graphic in an encoded format such as
VB.NET:
System.Drawing.Imaging.ImageFormat.Bmp

Hope it helps
-Learnerguy
 

Latest posts

Back
Top