Ver Mensaje Individual
  #4 (permalink)  
Antiguo 22/06/2010, 11:02
oscar24
 
Fecha de Ingreso: junio-2010
Mensajes: 1
Antigüedad: 13 años, 10 meses
Puntos: 0
Respuesta: Convertir un control WebBrowser y su contenido en BMP

Hola, interesante el codigo pero estaba intentando guardar el bitmap en la propiedad Image del picture box yno lo logro conseguir, soy nuevo en vb.net, aqui les paso el codigo, espero me puedan ayudar.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImprimir.Click, btnCapturar.Click
Dim srcGraphics As Graphics = WebBrowser1.CreateGraphics
Try
Dim destGraphics As Graphics = PictureBox1.CreateGraphics
Dim bmpSource As New Bitmap(PictureBox1.Width, PictureBox1.Height, destGraphics)
bmpSource.Save("Image.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
Try
Dim hdcDest As IntPtr = destGraphics.GetHdc
Dim hdcSrc As IntPtr = srcGraphics.GetHdc
BitBlt(hdcDest, 0, 0, WebBrowser1.ClientRectangle.Width, WebBrowser1.ClientRectangle.Height, hdcSrc, 0, 0, CType(TernaryRasterOperations.SRCCOPY, Integer))
srcGraphics.ReleaseHdc(hdcSrc)
destGraphics.ReleaseHdc(hdcDest)
PictureBox1.Image = bmpSource.Clone()
Finally
CType(destGraphics, IDisposable).Dispose()
End Try
Finally
CType(srcGraphics, IDisposable).Dispose()
End Try
End Sub