Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Grayscale-image/FBSL/grayscale-image.fbsl
Normal file
15
Task/Grayscale-image/FBSL/grayscale-image.fbsl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
DIM colored = ".\LenaClr.bmp", grayscale = ".\LenaGry.bmp"
|
||||
DIM head, tail, r, g, b, l, ptr, blobsize = 54 ' sizeof BMP file headers
|
||||
|
||||
FILEGET(FILEOPEN(colored, BINARY), FILELEN(colored)): FILECLOSE(FILEOPEN) ' load buffer
|
||||
head = @FILEGET + blobsize: tail = @FILEGET + FILELEN ' set loop bounds
|
||||
|
||||
FOR ptr = head TO tail STEP 3 ' transform color triplets
|
||||
b = PEEK(ptr + 0, 1) ' read Windows colors stored in BGR order
|
||||
g = PEEK(ptr + 1, 1)
|
||||
r = PEEK(ptr + 2, 1)
|
||||
l = 0.2126 * r + 0.7152 * g + 0.0722 * b ' derive luminance
|
||||
SETMEM(FILEGET, RGB(l, l, l), ptr - head + blobsize, 3) ' write grayscale
|
||||
NEXT
|
||||
|
||||
FILEPUT(FILEOPEN(grayscale, BINARY_NEW), FILEGET): FILECLOSE(FILEOPEN) ' save buffer
|
||||
Loading…
Add table
Add a link
Reference in a new issue