Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
'This example simply puts random white pixels throughout the image.
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Resource "gbsnippets.pbr"
Global hDlg as DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,250, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Change Colors", 20,10,160,20
Control Add Graphic, hDlg, 200,"", 50,40,100,100 ', %ws_border
Graphic Attach hDlg, 200
Graphic Render "cowgirl", (0,0) - (99,99) 'Image from resource file
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local x as long, y as long, bmp$, i as Long, j as Long, k as Long
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
' Change all blue pixels to red - DIM ... AT method
Dim BgrArray() AS Long
Graphic Get Bits To bmp$
ReDim BGRArray(Len(bmp$)/4-3) At StrPTR(bmp$)+8
For i = 0 to UBound(BgrArray)
'lightly sprinkle with white dots
If Rnd(1,20) > 19 Then BgrArray(i) = Bgr(%White)
Next i
Graphic Set Bits bmp$
Graphic Redraw
End If
End Function
'gbs_00507
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm