Results 1 to 2 of 2

Thread: Why are my pictures that i load into a picture box blurry?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    14

    Question Why are my pictures that i load into a picture box blurry?

    Ok so here's the thing. I got a great response from my last thread and you all were such a big help, so I'm back for more.

    My new problem is this. Keeping this simple, say i have 2 forms.

    on form1 I have a picturebox and a button. when you click on the picturebox, an openfiledialog opens and the user selects a picture from their computer which then loads into the picturebox. when you click on the button, a savefiledialog opens allowing the user to name and save the picture.

    Code:
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            SaveFileDialog1.ShowDialog()
        End Sub
    
        Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
            OpenFileDialog1.ShowDialog()
        End Sub
    
        Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
            PictureBox1.ImageLocation = OpenFileDialog1.FileName
        End Sub
    
        Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
            PictureBox1.Image.Save(SaveFileDialog1.FileName + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
            form2.ImageList1.Images.Add(Me.PicBox1.Image)
        End Sub
    
    End Class
    on form2 there is another picturebox, another button and an imagelist. when the user saves the picture from form1, the image is automatically loaded into the image list on form2. Now the user is supposed to click the button and the image from the imagelist is supposed to load into the picturebox. which it does.

    Code:
    Public Class form2
    
        Dim count As Integer = 0
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        
            PictureBox1.Image = ImageList1.Images.Item(count)
        End Sub
    
    End Class
    now here's the problem: When i click on the button on form2 to load the image, it's REALLY blurry. the size and image are correct but its just really blurry.

    eventually i want to create a "windows picture gallery" type thing. where the user clicks on the button and the first image loads from the image list. i will also have 2 more buttons to allow the user to go from 1 picture to the next. And the image list I'm using, i have the visible property set to false (i want it all done with buttons) but thats for another day (unless you want to help).

    So can anyone tell my why my image is loading blurry? Should I not use the imagelist component to accomplish my goals? Any help is appriciated. thanks everyone!!

    Brian

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Why are my pictures that i load into a picture box blurry?

    The ImageList is designed for small images like icons so it is unsuitable for an image browser. The default ImageList image size is 16x16 pixels and the maximum is 256x256. If you put a very small image in a PictureBox with the SizeMode set to Zoom or Stretch, it will be expanded to fit with blurry results. Instead, you could consider a generic List(Of Image). You may also find the Image.GetThumbNailImage method useful, since digital photos contain decent thumbnail images which will be much faster to load than the full image. It's way past my bedtime now, so if you need more help I'll look in tomorrow. BB

    BB

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width