qb64-include/solarize.bm

28 lines
838 B
Text
Raw Normal View History

2022-09-19 01:27:48 +02:00
$if Solarize = undefined then
$let Solarize = defined
2022-05-20 23:24:48 +02:00
Sub Solarize (image As Long, threshold)
Dim oldDest As Long
Dim oldSource As Long
Dim y As Long
Dim x As Long
Dim orgc As _Unsigned Long
Dim r As Integer
Dim g As Integer
Dim b As Integer
oldDest = _Dest
oldSource = _Source
_Dest image
_Source image
For y = 0 To _Height(image) - 1
For x = 0 To _Width(image) - 1
orgc = Point(x, y)
If _Red(orgc) > threshold Then r = 255 - _Red(orgc) Else r = _Red(orgc)
If _Green(orgc) > threshold Then g = 255 - _Green(orgc) Else g = _Green(orgc)
If _Blue(orgc) > threshold Then b = 255 - _Blue(orgc) Else b = _Blue(orgc)
PSet (x, y), _RGB32(r, g, b)
2022-03-18 18:33:58 +01:00
Next
Next
2022-05-20 23:24:48 +02:00
_Dest oldDest
_Source oldSource
End Sub
2022-09-19 01:27:48 +02:00
$end if