Ok, Trying To Use ColourDiff and Converting Color To Number.

SickelSell
10-24-2006, 10:44 PM
This is my getpixel function, I changed the Longs to Integers.

Declare Function GetPixel Lib "gdi32" (ByVal hdc As Integer, ByVal x As Integer, _
ByVal y As Integer) As Integer




Dim y, x As Integer
Dim offby As Integer

offBy = 350

Do
For y = 10 To ocrpic.Height - 15 Step 4
For x = 10 To ocrpic.Width - 15 Step 4

Dim hdc = ocrpic.CreateGraphics.GetHdc
If ColourDiff(GetPixel(hdc, x, y), Color.Black) < offby Then
MsgBox(x)
Exit Do
End If
ocrpic.CreateGraphics.ReleaseHdc()
Next x
Next y
offBy = offBy + 50
Loop



I get the error


Value of type 'Integer' cannot be converted to 'System.Drawing.Color'.

On

[/PHP]GetPixel(hdc, x, y)[/PHP]



Can you help, Please?

MikeJ
10-24-2006, 10:47 PM
GetPixel returns an integer. ColorDiff is expecting a Color. May I ask why you are using Legacy VB coding practices and functions to accomplish whatever it is you are trying to accomplish when you are using .NET? (Also, please use [vb] tags, rather than [php] tags. Makes it easier to read!)

SickelSell
10-24-2006, 10:58 PM
GetPixel returns an integer. ColorDiff is expecting a Color. May I ask why you are using Legacy VB coding practices and functions to accomplish whatever it is you are trying to accomplish when you are using .NET? (Also, please use [vb] tags, rather than [php] tags. Makes it easier to read!)


Is their a better way to re-write that in Vb.NET Format?

Iceplug
10-25-2006, 06:08 AM
Bitmap objects have GetPixel and SetPixel functions built in. You may have to show advanced members in the Project Properties or Tools Options (I forget where it is and have no clue why it's off)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum