473,771 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CAPTCHA image .NET error/problem

8 New Member
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:
Expand|Select|Wrap|Line Numbers
  1. <img src="TuringImage.aspx" alt="" />
  2.  

My code on TuringImages.as px have this code:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="TuringImage.aspx.vb" Inherits="TuringImage" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <head runat="server">
  5. <title>TurningImage</title>
  6. </head>
  7. <body>
  8. </body>
  9. </html>
  10.  

My code_behind for this site it then:
Expand|Select|Wrap|Line Numbers
  1. Imports System.IO
  2. Imports System.Collections
  3. Imports System.ComponentModel
  4. Imports System.Data
  5. Imports System.Drawing
  6. Imports System.Drawing.Drawing2D
  7. Imports System.Drawing.Imaging
  8. Imports System.Web
  9. Imports System.Web.SessionState
  10. Imports System.Web.UI
  11. Imports System.Web.UI.WebControls
  12. Imports System.Web.UI.HtmlControls
  13.  
  14. Partial
  15. Class TuringImage
  16. Inherits System.Web.UI.Page
  17. Private random As Random = New Random
  18. Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
  19. 'Width and height of image
  20. Dim width As Integer = 200
  21. Dim height As Integer = 50
  22. Dim familyName As String = "Times New Roman"
  23. 'String imageText = "123456";
  24. Dim imageText As String = Me.Session("TuringImageText").ToString
  25. 'Create a new 32-bit bitmap image.
  26. Dim bitmap As System.Drawing.Image = New Bitmap(width, height, PixelFormat.Format32bppArgb)
  27. 'Create a graphics object for drawing.
  28. Dim g As Graphics = Graphics.FromImage(bitmap)
  29. g.SmoothingMode = SmoothingMode.AntiAlias
  30. Dim rect As Rectangle = New Rectangle(0, 0, width, height)
  31. 'Fill in the background.
  32. Dim hatchBrush As HatchBrush = New HatchBrush(HatchStyle.SmallConfetti, Color.LightGray, Color.White)
  33. g.FillRectangle(hatchBrush, rect)
  34. 'Set up the text font.
  35. Dim size As SizeF
  36. Dim fontSize As Single = rect.Height + 1
  37. Dim font As Font
  38. 'Adjust the font size until the text fits within the image.
  39. Do
  40. System.Math.Max(System.Threading.Interlocked.Decrement(CLng(fontSize)), fontSize + 1)
  41. font = New Font(familyName, fontSize, FontStyle.Bold)
  42. size = g.MeasureString(imageText, font)
  43. Loop While size.Width > rect.Width
  44. 'Set up the text format.
  45. Dim format As StringFormat = New StringFormat
  46. format.Alignment = StringAlignment.Center
  47. format.LineAlignment = StringAlignment.Center
  48. 'Create a path using the text and warp it randomly.
  49. Dim path As GraphicsPath = New GraphicsPath
  50. path.AddString(imageText, font.FontFamily, CType(font.Style, Integer), font.Size, rect, format)
  51. Dim v As Single = 4.0F
  52. 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)}
  53. Dim matrix As Matrix = New Matrix
  54. matrix.Translate(0.0F, 0.0F)
  55. path.Warp(points, rect, matrix, WarpMode.Perspective, 0.0F)
  56. 'Draw the text.
  57. hatchBrush = New HatchBrush(HatchStyle.LargeConfetti, Color.LightGray, Color.DarkGray)
  58. g.FillPath(hatchBrush, path)
  59. 'Add some random noise.
  60. Dim m As Integer = Math.Max(rect.Width, rect.Height)
  61. Dim i As Integer = 0
  62. While i < CType((rect.Width * rect.Height / 30.0F), Integer)
  63. Dim x As Integer = Me.random.Next(rect.Width)
  64. Dim y As Integer = Me.random.Next(rect.Height)
  65. Dim w As Integer = Me.random.Next(m / 50)
  66. Dim h As Integer = Me.random.Next(m / 50)
  67. g.FillEllipse(hatchBrush, x, y, w, h)
  68. System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
  69. End While
  70. 'Change the response headers to output a JPEG image.
  71. Me.Response.Clear()
  72. Me.Response.ContentType = "image/jpeg"
  73. bitmap.Save(Me.Response.OutputStream, ImageFormat.Jpeg)
  74. 'Clean up.
  75. 'font.Dispose();
  76. hatchBrush.Dispose()
  77. g.Dispose()
  78. End Sub
  79. End Class 
  80.  
Mar 26 '07 #1
0 1438

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2793
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
0
1743
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
7
10164
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/)
4
5794
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...
11
2438
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
7
1490
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..
0
1597
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...
1
1493
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) ....
10
7858
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>
0
9619
marktang
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...
0
9454
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,...
0
10102
jinu1996
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...
0
9910
tracyyun
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...
1
7460
isladogs
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...
0
6712
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();...
0
5354
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...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.