Problem with image flickering

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ranjith kumar devuniri
    New Member
    • Aug 2007
    • 1

    Problem with image flickering

    Hi everyone!
    coming to point directly
    I am developing an application in VB using visual studio 6.0. In my application, I have a form with 9 image controls and one picture box control. Those images should be visible all at a time based on combo click event conditions.
    so the problem is whenever I click on the combo box only one image will be changed in this case the image flickering very much.
    I want to reduce this in my form. Could you please give your solution on this issue

    Thanks in advance
  • kinnu
    New Member
    • Nov 2006
    • 30

    #2
    You will find the difference if you use .bmp image file format instead of JPEG file format in image control.

    Also check your combo click event if you have provided any refreshing picturebox or used the timers to display the images in picture box. Using the timers gives the flickering.

    If problem still did not solved provide your event coding here so that can be modified and provided to you.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Yes, I think it would help if you post some of your code here.

      Comment

      • Robbie
        New Member
        • Mar 2007
        • 180

        #4
        I think the problem is that if a picture needs to be changing a lot and you don't want it to flicker, you need to use double-buffering.

        The idea of double-buffering is that everything is drawn on an 'invisible' (or off-screen) picturebox. When everything has been drawn, you then copy the contents of that picturebox in one go into a visible place.
        So the picture only changes when VB has finished drawing it, and you don't see it gradually appearing as it draws it.

        So you need a picturebox with Visible set to False. You can put it anywhere since it's going to be invisible anyway, but make sure it's the same size as the picturebox which is currently flickering for you (so that it's wide and high enough to hold the whole picture). In this example I'll give it the name 'picDB'. You must also set picDB's AutoRedraw to True. You also need to set AutoRedraw to True on the picturebox which you say flickers (which I'll call picFlicker in this example). Also, set both the pictureboxes' ScaleMode to 3 - Pixel (important).

        Then, instead of drawing to the picFlicker picturebox, change it so it draws to picDB instead. When you've finished all code which could possibly draw to the picturebox, copy what you've just drawn in picDB into the visible picturebox, picFlicker. To do this, you need this module:
        Code:
        Public Declare Function BitBlt Lib "gdi32" _
        (ByVal hDestDC As Long, _
        ByVal X As Long, ByVal y As Long, _
        ByVal nWidth As Long, ByVal nHeight As Long, _
        ByVal hSrcDC As Long, _
        ByVal xSrc As Long, ByVal ySrc As Long, _
        ByVal dwRop As Long) As Long
        This is called a Bit-Block Transfer, or just 'blitting' for short.

        Now the code to copy from picDB to picFlicker:
        Code:
                BitBlt picFlicker.hdc, 0, 0, _
                picDB.scalewidth, picDB.scaleheight, _
                picDB.hdc, _
                0, 0, _
                vbSrcCopy
                
                picFlicker.Refresh
        From the start of the arguments, this tells it to put what it copies into picFlicker at position (0,0) in it. It tells it to copy a section which is scalewidth pixels wide and scaleheight pixels high, from picDB, and the section starts at (0,0) in it.
        Last edited by Robbie; Aug 20 '07, 11:47 AM. Reason: Fixed typo of a property

        Comment

        Working...