Results 1 to 3 of 3

Thread: Refresh Problem?

  1. #1

    Thread Starter
    Member leazfe's Avatar
    Join Date
    Mar 2004
    Location
    Spain
    Posts
    43

    Refresh Problem?

    I have the follow problem: The first time i draw the image I get a blank screen( The image stay only a half second) but the next time the image is good drawn. I have looked for a refresh method but i didn´t find it. Any help?

    By the way, i have to decide where i want the image to be drawn with the X and Y parameter and it is really stupid. Does anyone know another better way?

    The code is:
    Code:
    Dim gr As Graphics = Me.CreateGraphics
            Dim bmpUnten As New Bitmap("image.png")
    
            gr.DrawImage(bmpUnten, 50, 150)
    
            gr.Dispose()
            bmp.Dispose()
    Thanks,
    Alvaro
    Last edited by leazfe; Apr 30th, 2004 at 03:48 PM.

  2. #2
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    i dont think i understand your code...

    VB Code:
    1. gr.DrawImage(bmpUnten, 50, 150)
    2.  
    3. gr.Dispose()

    you just set it, then you disposed of it. Now I'm not very good with this drawing stuff with VB.NET, but by the sound of Dispose, it looks like you're getting rid of it.

    That would be a very good explination for why it only appears for a split second because its getting deleted as soon as it appears.

    I dunno if im right in saying that though, I don't know what this dispose thing does, but its name kinda gives me this impression.

    By the way, i have to decide where i want the image to be drawn with the X and Y parameter and it is really stupid. Does anyone know another better way?
    A better way? Hmm... not sure how you mean a better way... how else are you expecting to define the image location exactly?

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Refresh Problem?

    Originally posted by leazfe
    I have the follow problem: The first time i draw the image I get a blank screen( The image stay only a half second) but the next time the image is good drawn. I have looked for a refresh method but i didn´t find it. Any help?

    By the way, i have to decide where i want the image to be drawn with the X and Y parameter and it is really stupid. Does anyone know another better way?

    The code is:
    Code:
    Dim gr As Graphics = Me.CreateGraphics
            Dim bmpAs New Bitmap("image.png")
    
            gr.DrawImage(bmpUnten, 50, 150)
    
            gr.Dispose()
            bmp.Dispose()
    Thanks,
    Alvaro
    uhh, why do you declare the variable "bmp"? it seems like it's not used at all (maybe you meant to name it "bmpUnten" ?) and I dont think there is anything wrong with disposing it..... If you have this code in the Paint event of your form/picturebox, then I would call the Control.Invalidate method instead of the Refresh method
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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