Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - Scrivere un testo su un immagine screenshot
Forum - C# / VB.NET - Scrivere un testo su un immagine screenshot

Pagine: [ 1 2 ] Precedente | Prossimo
Avatar
kejan (Normal User)
Newbie


Messaggi: 20
Iscritto: 12/08/2009

Segnala al moderatore
Postato alle 17:31
Mercoledì, 02/09/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

  1. Public Class Form1
  2.  
  3.     Public Shared Function ScreenShot() As Bitmap
  4.         SendKeys.SendWait("^{PRTSC}")
  5.         Dim Obj As IDataObject = Clipboard.GetDataObject
  6.         If (Obj.GetDataPresent(DataFormats.Bitmap)) Then
  7.             Dim Img As Bitmap = New Bitmap(CType((Obj.GetData("System.Drawing.Bitmap")), Bitmap))
  8.             Return Img
  9.         End If
  10.         Return Nothing
  11.     End Function
  12.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  13.         ScreenShot.Save("C:\prova.jpg")
  14.     End Sub
  15. End Class


PM Quote
Avatar
secretfabios (Normal User)
Rookie


Messaggi: 59
Iscritto: 17/08/2009

Segnala al moderatore
Postato alle 10:32
Giovedì, 03/09/2009
Dai una occhiata a Graphics.Drawstring()
http://msdn.microsoft.com/it-it/library/system.drawing.gra ...

Ultima modifica effettuata da secretfabios il 03/09/2009 alle 10:32
PM Quote
Avatar
kejan (Normal User)
Newbie


Messaggi: 20
Iscritto: 12/08/2009

Segnala al moderatore
Postato alle 14:26
Giovedì, 03/09/2009
lo già visto ma non ci ho capito molto....
sai darmi una mano....

PM Quote
Avatar
secretfabios (Normal User)
Rookie


Messaggi: 59
Iscritto: 17/08/2009

Segnala al moderatore
Postato alle 15:47
Giovedì, 03/09/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

  1. Dim Instance As Graphics = Graphics.FromImage(oBackground)
  2.         Dim s As String = "Screenshot di Fabio" 'Quello ke vuoi scrivere
  3.         'Il font o meglio lo stile del carattere
  4.         Dim font As Font = New Font("Arial", 12, FontStyle.Italic Or FontStyle.Bold)
  5.         Dim brush As Brush = Brushes.Red'Colore
  6.         Dim pointX As String = 300 'Coordinate dove vuoi scrivere
  7.         Dim pointY As String = 300 'Coordinate dove vuoi scrivere
  8.  
  9.  
  10.         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
PM Quote
Avatar
kejan (Normal User)
Newbie


Messaggi: 20
Iscritto: 12/08/2009

Segnala al moderatore
Postato alle 18:12
Giovedì, 03/09/2009
non mi sta funzionando dove sbaglio^^
Codice sorgente - presumibilmente VB.NET

  1. Public Class Form1
  2.  
  3.     Public Shared Function ScreenShot() As Bitmap
  4.         SendKeys.SendWait("^{PRTSC}")
  5.         Dim Obj As IDataObject = Clipboard.GetDataObject
  6.         If (Obj.GetDataPresent(DataFormats.Bitmap)) Then
  7.             Dim Img As Bitmap = New Bitmap(CType((Obj.GetData("System.Drawing.Bitmap")), Bitmap))
  8.             Return Img
  9.         End If
  10.         Return Nothing
  11.     End Function
  12.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  13.         Dim Instance As Graphics = Graphics.FromImage(ScreenShot)
  14.         Dim s As String = "Screenshot di Fabio" 'Quello ke vuoi scrivere
  15.         'Il font o meglio lo stile del carattere
  16.         Dim font As Font = New Font("Arial", 12, FontStyle.Italic Or FontStyle.Bold)
  17.         Dim brush As Brush = Brushes.Red 'Colore
  18.         Dim pointX As String = 300 'Coordinate dove vuoi scrivere
  19.         Dim pointY As String = 300 'Coordinate dove vuoi scrivere
  20.         Instance.DrawString(s, font, brush, pointX, pointY)
  21.         ScreenShot.Save("C:\prova.jpg")
  22.     End Sub
  23. End Class


PM Quote
Avatar
secretfabios (Normal User)
Rookie


Messaggi: 59
Iscritto: 17/08/2009

Segnala al moderatore
Postato alle 19:38
Giovedì, 03/09/2009
L' immagine credo ke sia Img e non Screenshot

PM Quote
Avatar
kejan (Normal User)
Newbie


Messaggi: 20
Iscritto: 12/08/2009

Segnala al moderatore
Postato alle 20:55
Giovedì, 03/09/2009
mi posti tutto il codice che hai usato tu....
perchè non ho capito
poi come testo ne devo stampare sono due .....

PM Quote
Avatar
secretfabios (Normal User)
Rookie


Messaggi: 59
Iscritto: 17/08/2009

Segnala al moderatore
Postato alle 0:18
Venerdì, 04/09/2009
Ti salto tutte le dichiarazioni per fare lo screenshot (spero ke almeno quello funzioni da te!)
Codice sorgente - presumibilmente VB.NET

  1. Imports System.Drawing
  2. Pubblic Class Form1
  3. Protected Sub CaptureScreen()
  4.         Dim hSDC, hMDC As Integer
  5.         Dim hBMP, hBMPOld As Integer
  6.         Dim r As Integer
  7.         hSDC = CreateDC("DISPLAY", "", "", "")
  8.         hMDC = CreateCompatibleDC(hSDC)
  9.         FW = GetDeviceCaps(hSDC, 8)
  10.         FH = GetDeviceCaps(hSDC, 10)
  11.         hBMP = CreateCompatibleBitmap(hSDC, FW, FH)
  12.         hBMPOld = SelectObject(hMDC, hBMP)
  13.         r = BitBlt(hMDC, 0, 0, FW, FH, hSDC, 0, 0, 13369376)
  14.         hBMP = SelectObject(hMDC, hBMPOld)
  15.         r = DeleteDC(hSDC)
  16.         r = DeleteDC(hMDC)
  17.         'oBackground è lo screenshot
  18.         oBackground = Image.FromHbitmap(New IntPtr(hBMP))
  19.  
  20.         Dim Instance As Graphics = Graphics.FromImage(oBackground)
  21.         Dim s As String = "PC BLOCCATO"
  22.         Dim font As Font = New Font("Arial", 30, FontStyle.Regular Or FontStyle.Bold)
  23.         Dim brush As Brush = Brushes.Red
  24.         Dim pointx As String = 500
  25.         Dim pointY As String = 500
  26.         Instance.DrawString(s, font, brush, pointx, pointY)
  27.  
  28.         DeleteObject(hBMP)
  29.  
  30.  
  31.     End Sub
  32.  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  33.             CaptureScreen()
  34.             'System.Threading.Thread.Sleep(1000)
  35.             'Mette lo screenshot nel backgorund del FORM
  36.             Me.BackgroundImage = oBackground
  37.     End Sub


Ultima modifica effettuata da secretfabios il 04/09/2009 alle 0:21
PM Quote
Avatar
kejan (Normal User)
Newbie


Messaggi: 20
Iscritto: 12/08/2009

Segnala al moderatore
Postato alle 8:59
Venerdì, 04/09/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^^

PM Quote
Pagine: [ 1 2 ] Precedente | Prossimo