Oppure

Loading
02/09/09 15:31
kejan
Vorrei fare che appena clicco su un pulsante mi crea uno screenshot
con alcune scritte da me impostate....
sapete come posso fare....

Questo e il codice...
Public Class Form1

    Public Shared Function ScreenShot() As Bitmap
        SendKeys.SendWait("^{PRTSC}")
        Dim Obj As IDataObject = Clipboard.GetDataObject
        If (Obj.GetDataPresent(DataFormats.Bitmap)) Then
            Dim Img As Bitmap = New Bitmap(CType((Obj.GetData("System.Drawing.Bitmap")), Bitmap))
            Return Img
        End If
        Return Nothing
    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ScreenShot.Save("C:\prova.jpg")
    End Sub
End Class
aaa
03/09/09 8:32
secretfabios
Dai una occhiata a Graphics.Drawstring()
msdn.microsoft.com/it-it/library/…
Ultima modifica effettuata da secretfabios 03/09/09 8:32
aaa
03/09/09 12:26
kejan
lo già visto ma non ci ho capito molto....
sai darmi una mano....
aaa
03/09/09 13:47
secretfabios
Scusa se ci ho messo un po...ma ho dovuto capirlo ankio XD
Mettiamo ke lo screenshot si chiami oBackground (come nel mio caso)
Dim Instance As Graphics = Graphics.FromImage(oBackground)
        Dim s As String = "Screenshot di Fabio" 'Quello ke vuoi scrivere
        'Il font o meglio lo stile del carattere
        Dim font As Font = New Font("Arial", 12, FontStyle.Italic Or FontStyle.Bold)
        Dim brush As Brush = Brushes.Red'Colore
        Dim pointX As String = 300 'Coordinate dove vuoi scrivere
        Dim pointY As String = 300 'Coordinate dove vuoi scrivere


        Instance.DrawString(s, font, brush, pointx, pointY)


Dammi un bel grazie se ti è servito e se hai domande posta pure!;)
Ultima modifica effettuata da secretfabios 03/09/09 14:01
aaa
03/09/09 16:12
kejan
non mi sta funzionando dove sbaglio^^
Public Class Form1

    Public Shared Function ScreenShot() As Bitmap
        SendKeys.SendWait("^{PRTSC}")
        Dim Obj As IDataObject = Clipboard.GetDataObject
        If (Obj.GetDataPresent(DataFormats.Bitmap)) Then
            Dim Img As Bitmap = New Bitmap(CType((Obj.GetData("System.Drawing.Bitmap")), Bitmap))
            Return Img
        End If
        Return Nothing
    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Instance As Graphics = Graphics.FromImage(ScreenShot)
        Dim s As String = "Screenshot di Fabio" 'Quello ke vuoi scrivere
        'Il font o meglio lo stile del carattere
        Dim font As Font = New Font("Arial", 12, FontStyle.Italic Or FontStyle.Bold)
        Dim brush As Brush = Brushes.Red 'Colore
        Dim pointX As String = 300 'Coordinate dove vuoi scrivere
        Dim pointY As String = 300 'Coordinate dove vuoi scrivere
        Instance.DrawString(s, font, brush, pointX, pointY)
        ScreenShot.Save("C:\prova.jpg")
    End Sub
End Class
aaa
03/09/09 17:38
secretfabios
L' immagine credo ke sia Img e non Screenshot
aaa
03/09/09 18:55
kejan
mi posti tutto il codice che hai usato tu....
perchè non ho capito
poi come testo ne devo stampare sono due .....
aaa
03/09/09 22:18
secretfabios
Ti salto tutte le dichiarazioni per fare lo screenshot (spero ke almeno quello funzioni da te!)
Imports System.Drawing
Pubblic Class Form1
Protected Sub CaptureScreen()
        Dim hSDC, hMDC As Integer
        Dim hBMP, hBMPOld As Integer
        Dim r As Integer
        hSDC = CreateDC("DISPLAY", "", "", "")
        hMDC = CreateCompatibleDC(hSDC)
        FW = GetDeviceCaps(hSDC, 8)
        FH = GetDeviceCaps(hSDC, 10)
        hBMP = CreateCompatibleBitmap(hSDC, FW, FH)
        hBMPOld = SelectObject(hMDC, hBMP)
        r = BitBlt(hMDC, 0, 0, FW, FH, hSDC, 0, 0, 13369376)
        hBMP = SelectObject(hMDC, hBMPOld)
        r = DeleteDC(hSDC)
        r = DeleteDC(hMDC)
        'oBackground è lo screenshot
        oBackground = Image.FromHbitmap(New IntPtr(hBMP))

        Dim Instance As Graphics = Graphics.FromImage(oBackground)
        Dim s As String = "PC BLOCCATO"
        Dim font As Font = New Font("Arial", 30, FontStyle.Regular Or FontStyle.Bold)
        Dim brush As Brush = Brushes.Red
        Dim pointx As String = 500
        Dim pointY As String = 500
        Instance.DrawString(s, font, brush, pointx, pointY)

        DeleteObject(hBMP)


    End Sub
 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            CaptureScreen()
            'System.Threading.Thread.Sleep(1000)
            'Mette lo screenshot nel backgorund del FORM
            Me.BackgroundImage = oBackground
    End Sub
Ultima modifica effettuata da secretfabios 03/09/09 22:21
aaa