Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

image de validation anti-bot

1 réponse
Avatar
lavache
Bonjour,
jai trouver ce code que jai un peux modifier.
et sa marche #1
mais je cherche a metre mon texte croche avec un font changeant.
Je sais sur le net ya plien de source mais sont tous en C#. moi je suis en
VB.
Quelque peux m'aidé????
merci
Sébas

#####
Imports System.Data.OleDb
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Imaging

Public Class vimage
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim monBitmap As Bitmap = New Bitmap(185, 50)
Dim monGraphic As Graphics = Graphics.FromImage(monBitmap)

' Choix aléatoire de la couleur du fond. RVB limité à 200 pour que
' le fond ne soit pas trop clair (car écriture blanche)
Dim nombreAleatoire As Random = New Random(DateTime.Now.Millisecond)
Dim r, v, b As Integer
r = nombreAleatoire.Next(0, 200)
v = nombreAleatoire.Next(0, 200)
b = nombreAleatoire.Next(0, 200)

' Coloration du fond
Dim monPinceau As New SolidBrush(Color.FromArgb(r, v, b))
monGraphic.FillRectangle(monPinceau, 0, 0, 185, 50)

' Création de la Font pour écrire le texte
Dim maFont As Font = New Font("Arial", 25, FontStyle.Regular)

' Création du "stylo" qui va nous permettre d'écrire le texte
Dim monStylo As New SolidBrush(Color.White)

' Structure PointF qui est un ensemble de 2 coordonnées pour le
début du texte
' sur la surface de dessin.
Dim mesCoor As New PointF(5.0F, 5.0F)


' Liste des caractères composant la chaîne aléatoire
'Dim liste() As String = {"A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", _
' "L", "M", "N", "O", "P", "Q", "R", "S",
"T", "U", "V", _
' "W", "X", "Y", "Z", "1", "2", "3", "4",
"5", "6", "7", "8", "9"}

' Variable qui va contenir le texte
Dim monTexte As String = ""

' Création aléatoire du texte
Dim i As Integer = 0
' While i < 6
monTexte += Session("patate") '(liste(nombreAleatoire.Next(0, 34)))
i += 1
'End While

' Détermination du rendu du texte dans l'image
monGraphic.TextRenderingHint =
Text.TextRenderingHint.ClearTypeGridFit

' La chaîne est "dessinée" sur l'image
monGraphic.DrawString(monTexte.ToString, maFont, monStylo, mesCoor)

' Affichage de l'image sur la page
Response.ContentType = "image/jpeg"
monBitmap.Save(Response.OutputStream, ImageFormat.Jpeg) 'Put user
code to initialize the page here
End Sub

End Class

#####

1 réponse

Avatar
Gilles TOURREAU
Le Thu, 25 Oct 2007 19:55:50 +0200, lavache <lavache|enleve|@9bit.qc.ca> a
écrit:

Bonjour,
jai trouver ce code que jai un peux modifier.
et sa marche #1
mais je cherche a metre mon texte croche avec un font changeant.
Je sais sur le net ya plien de source mais sont tous en C#. moi je suis
en
VB.
Quelque peux m'aidé????
merci
Sébas

#####
Imports System.Data.OleDb
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Imaging

Public Class vimage
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

'NOTE: The following placeholder declaration is required by the Web
Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim monBitmap As Bitmap = New Bitmap(185, 50)
Dim monGraphic As Graphics = Graphics.FromImage(monBitmap)

' Choix aléatoire de la couleur du fond. RVB limité à 200 pour
que
' le fond ne soit pas trop clair (car écriture blanche)
Dim nombreAleatoire As Random = New
Random(DateTime.Now.Millisecond)
Dim r, v, b As Integer
r = nombreAleatoire.Next(0, 200)
v = nombreAleatoire.Next(0, 200)
b = nombreAleatoire.Next(0, 200)

' Coloration du fond
Dim monPinceau As New SolidBrush(Color.FromArgb(r, v, b))
monGraphic.FillRectangle(monPinceau, 0, 0, 185, 50)

' Création de la Font pour écrire le texte
Dim maFont As Font = New Font("Arial", 25, FontStyle.Regular)

' Création du "stylo" qui va nous permettre d'écrire le texte
Dim monStylo As New SolidBrush(Color.White)

' Structure PointF qui est un ensemble de 2 coordonnées pour le
début du texte
' sur la surface de dessin.
Dim mesCoor As New PointF(5.0F, 5.0F)


' Liste des caractères composant la chaîne aléatoire
'Dim liste() As String = {"A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", _
' "L", "M", "N", "O", "P", "Q", "R", "S",
"T", "U", "V", _
' "W", "X", "Y", "Z", "1", "2", "3", "4",
"5", "6", "7", "8", "9"}

' Variable qui va contenir le texte
Dim monTexte As String = ""

' Création aléatoire du texte
Dim i As Integer = 0
' While i < 6
monTexte += Session("patate") '(liste(nombreAleatoire.Next(0,
34)))
i += 1
'End While

' Détermination du rendu du texte dans l'image
monGraphic.TextRenderingHint > Text.TextRenderingHint.ClearTypeGridFit

' La chaîne est "dessinée" sur l'image
monGraphic.DrawString(monTexte.ToString, maFont, monStylo,
mesCoor)

' Affichage de l'image sur la page
Response.ContentType = "image/jpeg"
monBitmap.Save(Response.OutputStream, ImageFormat.Jpeg) 'Put user
code to initialize the page here
End Sub

End Class

#####






Utilisez ce code au niveau du dessin de la chaine (code à la main...) :

Dim tabFont() As Font
Dim r As Random
Dim i As Integer

'Initialisation du nazard
r = new Random()

'Tableau des différentes polices disponibles
tabFont = New Font() {New Font("Arial", 15), New Font("Times New Roman",
10)}

For i = 0 To monTexte.Length

'Choisir un nombre entre 0 et la taille des polices disponibles
indice = r.Next(0, tabFont.Length)

'Dessiner la lettre avec la police à la position indice de tabFont
monGraphic.DrawString(monTexte(i), tabFont(indice), monStylo, mesCoor)

'Avancer les coordonnées de la largeur de la police pour la prochaine
lettre !
mesCoor.Offset(monGraphic.MeasureString(monTexte(i),
tabFont(indice)).Width, 0)

Next




Cordialement

--
Gilles TOURREAU


S.A.R.L. P.O.S
Le spécialiste en motoculture depuis + de 30 ans !
http://www.pos.fr