Hi.
I have this CAPTCHA image for .Net in C-Sharp and translate it into VB and as Code_Behind.
http://www.mbarrick.co m/blog/d6plinks/20061221-01
If i run the site/script i get the site but there is not being showing an CAPTCHA image, Why not !?
http://www.kennelengga ard.dk/captcha.aspx
Hope someone can help me with this.
My code on Default.aspx have this line: -
<img src="TuringImage.aspx" alt="" />
-
My code on TuringImages.as px have this code: -
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="TuringImage.aspx.vb" Inherits="TuringImage" %>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" >
-
<head runat="server">
-
<title>TurningImage</title>
-
</head>
-
<body>
-
</body>
-
</html>
-
My code_behind for this site it then: -
Imports System.IO
-
Imports System.Collections
-
Imports System.ComponentModel
-
Imports System.Data
-
Imports System.Drawing
-
Imports System.Drawing.Drawing2D
-
Imports System.Drawing.Imaging
-
Imports System.Web
-
Imports System.Web.SessionState
-
Imports System.Web.UI
-
Imports System.Web.UI.WebControls
-
Imports System.Web.UI.HtmlControls
-
-
Partial
-
Class TuringImage
-
Inherits System.Web.UI.Page
-
Private random As Random = New Random
-
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
-
'Width and height of image
-
Dim width As Integer = 200
-
Dim height As Integer = 50
-
Dim familyName As String = "Times New Roman"
-
'String imageText = "123456";
-
Dim imageText As String = Me.Session("TuringImageText").ToString
-
'Create a new 32-bit bitmap image.
-
Dim bitmap As System.Drawing.Image = New Bitmap(width, height, PixelFormat.Format32bppArgb)
-
'Create a graphics object for drawing.
-
Dim g As Graphics = Graphics.FromImage(bitmap)
-
g.SmoothingMode = SmoothingMode.AntiAlias
-
Dim rect As Rectangle = New Rectangle(0, 0, width, height)
-
'Fill in the background.
-
Dim hatchBrush As HatchBrush = New HatchBrush(HatchStyle.SmallConfetti, Color.LightGray, Color.White)
-
g.FillRectangle(hatchBrush, rect)
-
'Set up the text font.
-
Dim size As SizeF
-
Dim fontSize As Single = rect.Height + 1
-
Dim font As Font
-
'Adjust the font size until the text fits within the image.
-
Do
-
System.Math.Max(System.Threading.Interlocked.Decrement(CLng(fontSize)), fontSize + 1)
-
font = New Font(familyName, fontSize, FontStyle.Bold)
-
size = g.MeasureString(imageText, font)
-
Loop While size.Width > rect.Width
-
'Set up the text format.
-
Dim format As StringFormat = New StringFormat
-
format.Alignment = StringAlignment.Center
-
format.LineAlignment = StringAlignment.Center
-
'Create a path using the text and warp it randomly.
-
Dim path As GraphicsPath = New GraphicsPath
-
path.AddString(imageText, font.FontFamily, CType(font.Style, Integer), font.Size, rect, format)
-
Dim v As Single = 4.0F
-
Dim points As PointF() = {New PointF(Me.random.Next(rect.Width) / v, Me.random.Next(rect.Height) / v), New PointF(rect.Width - Me.random.Next(rect.Width) / v, Me.random.Next(rect.Height) / v), New PointF(Me.random.Next(rect.Width) / v, rect.Height - Me.random.Next(rect.Height) / v), New PointF(rect.Width - Me.random.Next(rect.Width) / v, rect.Height - Me.random.Nex(rect.Height) / v)}
-
Dim matrix As Matrix = New Matrix
-
matrix.Translate(0.0F, 0.0F)
-
path.Warp(points, rect, matrix, WarpMode.Perspective, 0.0F)
-
'Draw the text.
-
hatchBrush = New HatchBrush(HatchStyle.LargeConfetti, Color.LightGray, Color.DarkGray)
-
g.FillPath(hatchBrush, path)
-
'Add some random noise.
-
Dim m As Integer = Math.Max(rect.Width, rect.Height)
-
Dim i As Integer = 0
-
While i < CType((rect.Width * rect.Height / 30.0F), Integer)
-
Dim x As Integer = Me.random.Next(rect.Width)
-
Dim y As Integer = Me.random.Next(rect.Height)
-
Dim w As Integer = Me.random.Next(m / 50)
-
Dim h As Integer = Me.random.Next(m / 50)
-
g.FillEllipse(hatchBrush, x, y, w, h)
-
System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
-
End While
-
'Change the response headers to output a JPEG image.
-
Me.Response.Clear()
-
Me.Response.ContentType = "image/jpeg"
-
bitmap.Save(Me.Response.OutputStream, ImageFormat.Jpeg)
-
'Clean up.
-
'font.Dispose();
-
hatchBrush.Dispose()
-
g.Dispose()
-
End Sub
-
End Class
-
0 1438 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Krishna Kumar |
last post by:
Hai all,
I am doing a project in .net and in that project I have a problem in
capturing text from an image. i.e images like CAPTCHA images . which has
inbuilt text with in the image.So, Can any one suggest me how to continue
my work or give their valuable suggestions for capturing text in the
CAPTCHA image .
yours
KrishnaKumar
|
by: aaronwmail-usenet |
last post by:
Announcing SkimpyGimpy Support for PNG image
CAPTCHA generation and PNG canvases.
You can now use SkimpyGimpy to generate
CAPTCHA text representations as PNG image files
in addition to preformatted text ASCII art, and
WAVE format audio streams, either from command
lines or within Python programs.
Also general support for drawing text and
|
by: mitchell |
last post by:
hi
i m using IE 6.0.
i want to refresh just the captcha part when the user clicks on an image.
i searched for articles on it and got a fairly good understanding of it.
but i m still unable to get any results.
i have used Simple AJAX Code-Kit (SACK) (http://www.twilightuniverse.com/)
|
by: xeiter |
last post by:
Hi, I have a captcha script on my website located at /captcha.php. What it does it generates an image with the code, displays the image (gd2) and saves the value of the code in session.
How do I access that code in session from my c# windows application. I have a form in my application for registering users. The application then calls to the webserver and uses regular .php page to submit user registration. It has captcha and thats why I need...
|
by: Twayne |
last post by:
Hi,
Learning PHP code; playing with various methods of generating captcha
codes:
In the code below, how would I change the size of the text displayed in
the captcha code?
Is it even possible with this method?
TIA,
Twayne
| |
by: =?Utf-8?B?bWF0dCBw?= |
last post by:
Steve Orr has a neat Captcha control:
http://steveorr.net/articles/CAPTCHASP.aspx
but aside from "dragging the control onto your toolbox.." Does anyone have
any installation instructions: e.g. aspx code, etc... ?? I could not find
any..
|
by: readnlearn |
last post by:
hai,
i have written this below code for displaying captcha image whenever i entered incorrect uname,password in login page.
for that i disable the controls of captcha like textbox,labels,button and image control in source code of designing part.
and i enable those controls in an if condition which display captcha.
but if i entered correct information which is in database
it shouldn't navigate to the corresponding page
and also if entered...
|
by: sb5309 |
last post by:
In CAPTCHA, one starts a session, name it, and keep the verification
code as this:
$_SESSION = $veristr;
When an end-user clicks SUBMIT, the server script will verify the code
as this:
if($_SESSION == $_POST) ....
|
by: jeddiki |
last post by:
Hi,
I have a captcha script which should pick up a background image and add some random letters to it and re-display
This is the part of the form that the captcha image is part of:
<span >Verification Image:</span>
<span ><img src="captcha.php" id="captcha" />
<a href="#renew" onclick="javascript: document.getElementById('captcha').src = 'captcha.php?' + Math.random();">refresh</a> </span>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |