If you know you will always have a 24 bit bitmap image you can load it as a string in memory and read the pixels directly. That way it does not have to fit an LB graphic area. But LB has the easy ability to call Windows dll's, in particular one to read a pixel's colour. By using this to analyse a screen image it can be turned into a 2D matrix of values and manipulated- or processed small areas at a time. This is only one of many such programs I've written. Particularly good for drawing on an eggbot or 2D drawing machine.
By calling ImageMagick you could load/save as GIF or other image type. I find it easy to do these 'by hand', so at present you need to save first a 24 bit BMP of the right size. Easily added. And should add the equally easy 'Save as' to any image type.
Note this is still a work-in-progress. Plenty of ideas still for development, see also the remmed lines for examples!
How young I looked 50 years ago!
' *******************************************************
' ** **
' ** rasterWidth1.bas tenochtitlanuk 2016-2018 **
' ** **
' *******************************************************
' To-dos
' Add saving option
' Include ImageMagick to resize and enable other image types
nomainwin
WindowWidth =850
WindowHeight =660
open "Display" for graphics_nsb as #w
#w "trapclose quit"
handleg =hwnd( #w)
calldll #user32, "GetDC", handleg as ulong, hDC as ulong
filedialog "Choose bitmap- ideally <800x600", "*.bmp", fn$
if fn$ ="" then close #w: end
loadbmp "scr", fn$
#w "down ; drawbmp scr 10 10 ; backcolor white ; flush"
for y =10 to 790 step 10
for x =10 to 590 step 1
grey =0
for dy =y to y +9
calldll #gdi32, "GetPixel", hDC as ulong, x as long, dy as long, pixcol as ulong
bl = int( pixcol /( 256*256))
gr = int( (pixcol -bl *256*256) / 256)
re = int( pixcol -bl *256*256 -gr *256)
grey = grey +int( ( bl +gr +re) /3 /32)
next dy
grey =int( grey /10)
scan
#w "up; color 220 220 240 ; goto "; x; " "; y; " ; down ; goto "; x; " "; y +grey
#w "color black ; goto "; x; " "; y +9
next x
next y
wait
sub quit h$
close #h$
callDll #user32, "ReleaseDC", handleg as ulong, hDC as ulong, result as ushort
end
end sub
sub timeout t
timer t, [j]
wait
[j]
timer 0
end sub
nomainwin
WindowWidth =850
WindowHeight =660
open "Display" for graphics_nsb as #w
#w "trapclose quit"
handleg =hwnd( #w)
calldll #user32, "GetDC", handleg as ulong, hDC as ulong
[getFile]
filedialog "Choose image", "*.bmp", fn$
if fn$ ="" then [getFile]
loadbmp "scr", fn$
#w "down ; drawbmp scr 20 20 ; backcolor white ; flush"
while 1
x = 20 +int( 800 *rnd( 1))
y = 20 +int( 600 *rnd( 1))
calldll #gdi32, "GetPixel", hDC as ulong, x as long, y as long, pixcol as ulong
if pixcol <>255 and pixcol <> 2^24 -1 then
bl = int( pixcol /( 256*256)): gr = int( (pixcol -bl *256*256) / 256): re = int( pixcol -bl *256*256 -gr *256)
grey =int( ( bl +gr +re) /3 /32)
print x, y, re, gr, bl, grey
#w "color white"
#w "place "; x; " "; y
#w "circlefilled "; grey -2
#w "size "; 4
#w "color red"
#w "set "; x; " "; y
'call timeout 100
scan
end if
wend
wait
sub quit h$
callDll #user32, "ReleaseDC", handleg as ulong, hDC as ulong, result as ushort
close #h$
end
end sub
sub timeout t
timer t, [j]
wait
[j]
timer 0
end sub