Code:
using System.Drawing;
using System.IO;
using System.Text;
namespace NeoFunctions
{
static class NeoOCR
{
public static Point OCR(string img)
{
using (MemoryStream ms = new MemoryStream(Encoding.Default.GetBytes(img)))
{
return OCR(new Bitmap(ms));
}
}
public static Point OCR(Bitmap img)
{
Point oS = new Point();
int width = img.Width;
int height = img.Height;
float darkPixel = 1;
for (int x = 0; x < width; x += 10)
{
for (int y = 0; y < height; y += 10)
{
float curPixel = img.GetPixel(x, y).GetBrightness();
if (curPixel < darkPixel)
{
darkPixel = curPixel;
oS.X = x;
oS.Y = y;
}
}
}
return oS;
}
public static string AlternatePrice(string price)
{
string oldprice = price.Replace(",", string.Empty);
string newprice = string.Empty;
int alt = 1;
while(newprice.Length < oldprice.Length)
newprice += oldprice[alt = alt == 1 ? 0 : 1];
return newprice;
}
}
}
OCR(string img) - string parameter is the HTML of the captcha image (headers excluded). Returns the coordinates (as a Point) of the pet.
OCR(Bitmap img) - Bitmap parameter is the captcha image. Returns the coordinates (as a Point) of the pet.
AlternatePrice(string price) isn't really part of the OCR process but this takes the price and alternates the first two characters.
Input: 28429 Output: 28282