GETPIXEL API

  • Thread starter Thread starter Serdar C.
  • Start date Start date
S

Serdar C.

ok i searched the internet for this api and i found the
usage of getpixel api like this:
getpixel(example.hdc,x,y)
but i cant find any property about this "hdc".. that does
that hdc 's equal in vb.net??? thanx for helping..
 
Hi,

The graphics object has a gethdc method. You must manually release
the hdc when you are done with it.

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

Dim g As Graphics = e.Graphics

Dim hdc As IntPtr = g.GetHdc

' Do something with the hdc

g.ReleaseHdc(hdc)

End Sub

Ken
 
I have never used the getpixelapi, but hdc normally means that it requires a
handle into the object that you are trying to manipulate.

Normall you would have to calls one to get the Windows Handle and return it
as a long and then pass that long through the call
 
Hello,

Serdar C. said:
ok i searched the internet for this api and i found the
usage of getpixel api like this:
getpixel(example.hdc,x,y)
but i cant find any property about this "hdc".. that does
that hdc 's equal in vb.net??? thanx for helping..

If you want a hDC to the form, use this code:

\\\
Dim g As Graphics = Me.CreateGraphics()
Dim hDC As IntPtr = g.GetHdc
..
..
..
g.ReleaseHdc(hDC)
g.Dispose()
///

HTH,
Herfried K. Wagner
 
Serdar C. said:
ok i searched the internet for this api and i found the
usage of getpixel api like this:
getpixel(example.hdc,x,y)
but i cant find any property about this "hdc".. that does
that hdc 's equal in vb.net??? thanx for helping..

Pass the return value of Graphics.GetHdc. You get a graphics object in sub
OnPaint/Paint event (e.graphics) or create a new one using
MyControl.CreateGraphics. (call it's dispose method after calling getpixel)
 
Back
Top