Uploading picture on a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MarcosGalarza
    New Member
    • May 2010
    • 6

    #1

    Uploading picture on a form

    Hello,

    When i upload a picture onto my form my mouse starts lagging, everything starts lagging as a matter of fact. I think some settings have to be changed. What is happening to me right now is that i am moving a picture box around the screen and it lags when i move it with the uploading picture on the background. But when there is no picture on the background form there is no lag...! The picture box i am using is transparent is its suppose to show the form. Someone please help!

    Thank you
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    When you say "uploading" do you mean you are in the active process of uploading a file, or do you mean it starts lagging after you have set a picture in the box?

    You mentioned transparency... in my experience that can definitely increase your slow-down. Try turning the transparency off and testing again.

    Comment

    • ThatThatGuy
      Recognized Expert Contributor
      • Jul 2009
      • 453

      #3
      Originally posted by MarcosGalarza
      Hello,

      When i upload a picture onto my form my mouse starts lagging, everything starts lagging as a matter of fact. I think some settings have to be changed. What is happening to me right now is that i am moving a picture box around the screen and it lags when i move it with the uploading picture on the background. But when there is no picture on the background form there is no lag...! The picture box i am using is transparent is its suppose to show the form. Someone please help!

      Thank you
      What do you mean by "Lagging" ? did you meant flickering.....

      Comment

      • MarcosGalarza
        New Member
        • May 2010
        • 6

        #4
        Originally posted by ThatThatGuy
        What do you mean by "Lagging" ? did you meant flickering.....
        yes it flickers

        Comment

        • ThatThatGuy
          Recognized Expert Contributor
          • Jul 2009
          • 453

          #5
          Originally posted by MarcosGalarza
          Hello,

          When i upload a picture onto my form my mouse starts lagging, everything starts lagging as a matter of fact. I think some settings have to be changed. What is happening to me right now is that i am moving a picture box around the screen and it lags when i move it with the uploading picture on the background. But when there is no picture on the background form there is no lag...! The picture box i am using is transparent is its suppose to show the form. Someone please help!

          Thank you
          Im not understanding what did you say in your first post...

          But let me get it... you are moving a picture via the mouse on a transparent form... or vice-versa... if its something like that then...

          set the DoubleBuffered property of he form to true.... this will reduce flickering to much extent

          Comment

          • medicinesoup
            New Member
            • May 2010
            • 5

            #6
            Ok this is what I am understanding:
            you have a form with a large background picture (form.backgroun dimage) and you have a picture box on top of that with a smaller picture loaded (picturebox.ima ge)

            your goal is to move the picturebox around the form when the user moves the mouse, like an oversized specialized mouse cursor, correct? So you are using an image and picturebox with transparency because you don't want the user to see the borders of the picturebox, just the image floating around the background scene, right?

            let me know. Is that what you are trying to do?
            If so, that method is pretty processor intense, and it may be pretty difficult to get rid of the flickering. However, I think I have an alternative that accomplishes the same goal with no fliker (or a little bit of flicker if your background image is larger than 8192 x 8192 pixles)

            If not, then nevermind. I misunderstood.

            P.S. What version of vb.net are you using? [CODE=vbnet]Public Class Form1
            Private f_bmpButterfly As Bitmap

            'THIS CODE ASSUMES YOU HAVE A FORM (NAMED Form1) CONTAINING A PICTUREBOX (NAMED PictureBox1)
            Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

            ' Load the background image
            PictureBox1.Bac kgroundImage = New Bitmap("C:\your _background.jpg ")
            PictureBox1.Doc k = DockStyle.Fill
            PictureBox1.Bac kgroundImageLay out = ImageLayout.Str etch

            ' load the foreground image
            f_bmpButterfly = New Bitmap("C:\your _foreground.png ")

            'Do not load any image into the foreground (PictureBox1.Im age) yet.
            'the MouseMove event will do that as soon as the user moves the cursor
            'over the picturebox
            End Sub

            Private Sub PictureBox1_Mou seMove(ByVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles PictureBox1.Mou seMove
            'get rid of the previous foreground image
            If Not IsNothing(Pictu reBox1.Image) Then
            PictureBox1.Ima ge.Dispose()
            PictureBox1.Ima ge = Nothing
            End If

            'Prepare a new, blank foreground image.
            ' By making the foreground image as small as possible (no larger than the butterfly + it's position
            ' the program doesn't have to think about any unneccessary areas of the image when displaying it.
            Dim newBitmap As New Bitmap(e.X + f_bmpButterfly. Width, e.Y + f_bmpButterfly. Height, Imaging.PixelFo rmat.Format32bp pArgb)

            'position the butterfly in the foreground
            ' The graphics class is awesome! But don't forget to dispose of it when you're done.
            Dim gr As Graphics

            ' Tell the grphics class which image you want to mess with.
            gr = Graphics.FromIm age(newBitmap)

            ' Paint the butterfly onto the blank foreground
            gr.DrawImage(f_ bmpButterfly, e.X, e.Y)

            'Display the new foreground image. no need to change the background image
            PictureBox1.Ima ge = newBitmap

            'Dispose ummanaged resources
            gr.Dispose()
            gr = Nothing
            End Sub
            End Class[/CODE]

            Comment

            Working...