VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code calls setpixel & getpixel api functions.(just for beginners!)

by Mohammad Dindoost (1 Submission)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 24th May 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code calls setpixel & getpixel api functions.(just for beginners!)

API Declarations


Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

Rate This code calls setpixel & getpixel api functions.(just for beginners!)



Private Sub Timer1_Timer()
Dim dc As Long
Dim screenarray(0 To 100, 0 To 100) As Long

dc = GetWindowDC(GetDesktopWindow())

Form1.WindowState = vbMinimized

Randomize
x = Rnd * 800
y = Rnd * 800
For i = 0 To 100
     For j = 0 To 100
          screenarray(i, j) = GetPixel(dc, x + i, y + j)
     Next j
     
Next i

Randomize
X1 = Rnd * 800
Y1 = Rnd * 800
For i = 0 To 100
     For j = 0 To 100
          a = SetPixel(dc, X1 + i, Y1 + j, screenarray(i, j))
     Next j
     
Next i


End Sub

Download this snippet    Add to My Saved Code

This code calls setpixel & getpixel api functions.(just for beginners!) Comments

No comments have been posted about This code calls setpixel & getpixel api functions.(just for beginners!). Why not be the first to post a comment about This code calls setpixel & getpixel api functions.(just for beginners!).

Post your comment

Subject:
Message:
0/1000 characters