tengo el fragmento de este code el cual toma una captura de la pantalla y todo bien lo toma sin problemas, el problema es el siguiente
Public Sub New()
'escritorio = rectangle
B_rectangle = Windows.Forms.Screen.PrimaryScreen.Bounds
'encapsulamos mapas de bits a partir del B_rectangle.
B_image = New Drawing.Bitmap(B_rectangle.Width, B_rectangle.Height, Drawing.Imaging.PixelFormat.Format32bppArgb)
'crea la imagen a partir de b_image
B_graphics = Drawing.Graphics.FromImage(B_image)
End Sub
Public Function GetSnapshot() As IntPtr Implements Icaptura.GetSnapshot
If B_bitmapData IsNot Nothing Then
Throw New InvalidOperationException("Hay que liberar la instantánea actual antes de obtener una nueva.")
End If
B_graphics.CopyFromScreen(0, 0, 0, 0, B_rectangle.Size)
B_bitmapData = B_image.LockBits(B_rectangle, Drawing.Imaging.ImageLockMode.ReadOnly, Drawing.Imaging.PixelFormat.Format32bppArgb)
Return B_bitmapData.Scan0
End Function
Public Sub New(ByRef target As Windows.Forms.Control, ByVal width As Integer, ByVal height As Integer, ByVal pixelformat As Drawing.Imaging.PixelFormat)
o_target = target
o_graphics = o_target.CreateGraphics
b_rectangle = New Drawing.Rectangle(0, 0, width, height)
b_format = pixelformat
Dim stride As Integer
stride = 0
Select Case b_format
Case Drawing.Imaging.PixelFormat.Format16bppArgb1555, Drawing.Imaging.PixelFormat.Format16bppRgb555, Drawing.Imaging.PixelFormat.Format16bppRgb565
stride = (width * 2)
Case Drawing.Imaging.PixelFormat.Format24bppRgb
stride = (width * 3)
Case Drawing.Imaging.PixelFormat.Format32bppArgb, Drawing.Imaging.PixelFormat.Format32bppPArgb, Drawing.Imaging.PixelFormat.Format32bppRgb
stride = (width * 4)
End Select
b_length = height * stride
buffer = Runtime.InteropServices.Marshal.AllocHGlobal(b_length)
b_image = New Drawing.Bitmap(b_rectangle.Width, b_rectangle.Height, stride, b_format, buffer)
o_graphics.DrawImage(b_image, o_target.ClientRectangle)
End Sub
Public Sub DrawUpdate(ByVal intIndex As Integer, ByRef aryData() As Byte, ByVal intIndex_Data As Integer, ByVal intLength As Integer) Implements Idibujar.DrawUpdate
Runtime.InteropServices.Marshal.Copy(aryData, intIndex_Data, CInt(buffer) + intIndex, intLength)
End Sub
esta segunda part es fragmento de un code el cual no logro hacer que dibuje donde le designo....
o si hay alguna otra forma me seria de utilidad, y si desean las declaraciones de las variables las subo o algo mas.
Pero qué es lo que quieres hacer?
Porque según veo estás dibujando NADA. :S
la idea es dibujar la captura de pantalla que realizo :S
Pero la estas sacando de otro control verdad? es decir de: o_graphics = o_target.CreateGraphics
luego:
//buffer en este caso es un pointer a un array de bytes que contengan
//la data de la imagen como tal.
b_length = height * stride
buffer = Runtime.InteropServices.Marshal.AllocHGlobal(b_length)
//la pregunta es: Donde está la data? buffer tiene que apuntar a un array con la imagen
b_image = New Drawing.Bitmap(b_rectangle.Width, b_rectangle.Height, stride, b_format, buffer)
//Acá está bien, pero b_image creo que esta en blanco.
o_graphics.DrawImage(b_image, o_target.ClientRectangle)
tenes razon b_image esta vacio,tengo q rellenar el espacioo q queda o algo asi
modifique la primera linea de codigo,,sera logico asi ¿?
Public Sub New(ByRef target As Windows.Forms.Control, ByVal width As Integer, ByVal height As Integer, ByVal pixelformat As Drawing.Imaging.PixelFormat,ByVal Buffer as intPtr)
o_target = target
o_graphics = o_target.CreateGraphics
b_rectangle = New Drawing.Rectangle(0, 0, width, height)
b_format = pixelformat
Dim stride As Integer
stride = 0
Select Case b_format
Case Drawing.Imaging.PixelFormat.Format16bppArgb1555, Drawing.Imaging.PixelFormat.Format16bppRgb555, Drawing.Imaging.PixelFormat.Format16bppRgb565
stride = (width * 2)
Case Drawing.Imaging.PixelFormat.Format24bppRgb
stride = (width * 3)
Case Drawing.Imaging.PixelFormat.Format32bppArgb, Drawing.Imaging.PixelFormat.Format32bppPArgb, Drawing.Imaging.PixelFormat.Format32bppRgb
stride = (width * 4)
End Select
b_length = height * stride
buffer = Runtime.InteropServices.Marshal.AllocHGlobal(b_length)
b_image = New Drawing.Bitmap(b_rectangle.Width, b_rectangle.Height, stride, b_format, buffer)
o_graphics.DrawImage(b_image, o_target.ClientRectangle)
End Sub
Public Sub DrawUpdate(ByVal intIndex As Integer, ByRef aryData() As Byte, ByVal intIndex_Data As Integer, ByVal intLength As Integer) Implements Idibujar.DrawUpdate
Runtime.InteropServices.Marshal.Copy(aryData, intIndex_Data, CInt(buffer) + intIndex, intLength)
End Sub
ya tengo los modulos funcionando y por modificar un par de cosas...ahora podre comensar el escritorio remoto...si tienen ideas o algo en mente me dicen :P
no te quiero desanimar, pero mira que el escritorio remoto es un poquito mas dificil que capturar la pantalla, no es solo capturar la pantalla a cada rato y listo, debes mandar por partes las imagenes y solo las que realmente cambiaron, tiene todo una logica esto, pero bueno adelante con tu proyecto !!!
saludos.
si seba estoy viendo eso y estoy poniendome al dia para empesarlo...si tienes algo de teoria estaria bien.gracias