01-02-2023, 08:18 PM
Code: (Select All)
pic = _LoadImage("Pandora.jpg", 32)
Screen pic
Sleep
pic256 = Grayscale256(pic)
Screen pic256
Sleep
red256 = RedScale256(pic)
Screen red256
Sleep
green256 = GreenScale256(pic)
Screen green256
Sleep
blue256 = BlueScale256(pic)
Screen blue256
Sleep
Function Grayscale256 (image As Long)
Dim As Long d, s, temp, r, g, b
Dim As _MEM m(1): Dim As _Offset o(1), l
d = _Dest: s = _Source
m(0) = _MemImage(image): o(0) = m(0).OFFSET
temp = _NewImage(_Width(image), _Height(image), 256)
m(1) = _MemImage(temp): o(1) = m(1).OFFSET
_Dest temp: For i = 0 To 255: _PaletteColor i, _RGB32(i): Next: _Dest d
Do
r = _MemGet(m(0), o(0) + 1, _Unsigned _Byte): g = _MemGet(m(0), o(0) + 2, _Unsigned _Byte): b = _MemGet(m(0), o(0) + 3, _Unsigned _Byte)
_MemPut m(1), o(1), _RGB(r, g, b, temp) As _UNSIGNED _BYTE
o(0) = o(0) + 4: o(1) = o(1) + 1
Loop Until o(0) >= (m(0).OFFSET + m(0).SIZE)
Grayscale256 = temp
_MemFree m()
End Function
Function RedScale256 (image As Long)
Dim As Long d, s, temp: d = _Dest: temp = Grayscale256(image)
_Dest temp: For i = 0 To 255: _PaletteColor i, _RGB32(i, 0, 0): Next: _Dest d
RedScale256 = temp
End Function
Function GreenScale256 (image As Long)
Dim As Long d, s, temp: d = _Dest: temp = Grayscale256(image)
_Dest temp: For i = 0 To 255: _PaletteColor i, _RGB32(0, i, 0): Next: _Dest d
GreenScale256 = temp
End Function
Function BlueScale256 (image As Long)
Dim As Long d, s, temp: d = _Dest: temp = Grayscale256(image)
_Dest temp: For i = 0 To 255: _PaletteColor i, _RGB32(0, 0, i): Next: _Dest d
BlueScale256 = temp
End Function