kejan (Normal User)
Newbie
Messaggi: 20
Iscritto: 12/08/2009
|
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...
Codice sorgente - presumibilmente VB.NET |
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
|
|
|
secretfabios (Normal User)
Rookie
Messaggi: 59
Iscritto: 17/08/2009
|
Ultima modifica effettuata da secretfabios il 03/09/2009 alle 10:32 |
|
kejan (Normal User)
Newbie
Messaggi: 20
Iscritto: 12/08/2009
|
lo già visto ma non ci ho capito molto....
sai darmi una mano....
|
|
secretfabios (Normal User)
Rookie
Messaggi: 59
Iscritto: 17/08/2009
|
Scusa se ci ho messo un po...ma ho dovuto capirlo ankio XD
Mettiamo ke lo screenshot si chiami oBackground (come nel mio caso)
Codice sorgente - presumibilmente VB.NET |
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 il 03/09/2009 alle 16:01 |
|
kejan (Normal User)
Newbie
Messaggi: 20
Iscritto: 12/08/2009
|
non mi sta funzionando dove sbaglio^^
Codice sorgente - presumibilmente VB.NET |
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
|
|
|
secretfabios (Normal User)
Rookie
Messaggi: 59
Iscritto: 17/08/2009
|
L' immagine credo ke sia Img e non Screenshot
|
|
kejan (Normal User)
Newbie
Messaggi: 20
Iscritto: 12/08/2009
|
mi posti tutto il codice che hai usato tu....
perchè non ho capito
poi come testo ne devo stampare sono due .....
|
|
secretfabios (Normal User)
Rookie
Messaggi: 59
Iscritto: 17/08/2009
|
Ti salto tutte le dichiarazioni per fare lo screenshot (spero ke almeno quello funzioni da te!)
Codice sorgente - presumibilmente VB.NET |
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 il 04/09/2009 alle 0:21 |
|
kejan (Normal User)
Newbie
Messaggi: 20
Iscritto: 12/08/2009
|
non mi sta funzionando....
ti chiedo per favore col codice che ti do al inizio del post ci puoi dare una sistemata per aggiungere sta parte del testo^^
|
|