title: How to avoid half of the picture when making a live screenshot feed?
body: <p>I have created a Visual Basic .NET application that takes a screenshot every second and saves it to a file <code>screenshot.jpg</code> And I also created a server that serves the <code>screenshot.jpg</code> file every second. But the problem is that sometimes I see half of the picture (probably because it hasn't finished drawing yet). Is there a way around this problem? I wonder how webcams offer that smooth stream. Does it mean my screenshot capture program is too slow?</p>
  
  <p><a href="https://i.stack.imgur.com/hCFj7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hCFj7.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Here is my application</strong></p>
  
  <pre><code>' Take screenshot every second
  Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
      Dim bmp As Bitmap = ScreenCap()
  
      bmp.Save(Application.StartupPath &amp; "\screenshot.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
      bmp.Dispose()
  End Sub
  </code></pre>
  
  <p><em>You can see the full project on Github: <a href="https://git.io/Jv4TL" rel="nofollow noreferrer">https://git.io/Jv4TL</a></em></p>
  
  <p><strong>And here is the front end code</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
      &lt;img class="screenshot" src="screenshot.jpg"&gt;
  
      &lt;script&gt;
          setInterval(() =&gt; {
              document.querySelector('.screenshot').src =
                  'screenshot.jpg?id=' + Math.random(0, 1000)
          }, 1000)
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>