....original 'Lena.bmp',
....false colour look-up image also needed.
-
'LenaFalseColour.bas'
nomainwin
dim ColLookUp$( 256, 12)
data 5, 18, 33, 44, 53, 62, 80, 93, 105, 118, 129
WindowWidth =720: WindowHeight =500
graphicbox #w.gb, 38, 10, 206, 206 ' drawing area 200x200 for bmp file.
graphicbox #w.gb2, 8,240, 261, 140 ' drawing area for colour look-up.
graphicbox #w.gb3, 290, 10, 406, 408 ' drawing area for false colour copy.
open "Bitmap demo" for window as #w
#w "trapclose [quit]"
#w.gb "down ; fill white"
#w.gb2 "down ; fill white"
#w.gb3 "down ; fill white"
loadbmp "lena", "lena.bmp"
#w.gb "drawbmp lena 2 2 ; flush"
loadbmp "table", "QuadSpectrum.bmp"
#w.gb2 "drawbmp table 1 1 ; flush"
handleg2 =hwnd( #w.gb2)
calldll #user32, "GetDC", handleg2 as ulong, h2DC as ulong
for l =1 to 11 ' since my bmp has 11 graduated colour stripes
read yy ' which is how far down next colour stripe is centred
for v =0 to 255
calldll #gdi32, "GetPixel", h2DC as ulong, v as long, yy as long, pixcol as long
bl = int( pixcol /( 256*256))
gr = int( (pixcol -bl *256*256) / 256)
re = int( pixcol -bl *256*256 - gr *256)
ColLookUp$( v, l) =str$( re) +" " +str$( gr) +" " +str$( bl)
print v, l, ColLookUp$( v, l)
next v
scan
next l
unloadbmp "table"
callDll #user32, "ReleaseDC", handleg2 as ulong, h2DC as ulong, result as ushort
handlegb =hwnd( #w.gb)
calldll #user32, "GetDC", handlegb as ulong, hDC as ulong
for ch =1 to 11
for y =1 to 200 ' Display false colour version
for x =1 to 200
calldll #gdi32, "GetPixel", hDC as ulong, x as long, y as long, pixcol as long
bl = int( pixcol /( 256*256))
gr = int( (pixcol -bl *256*256) / 256)
re = int( pixcol -bl *256*256 - gr *256)
gray =int( ( re +gr +bl) /3)
#w.gb3, "color "; ColLookUp$( gray, ch)
#w.gb3 "set "; x +102; " "; y + 102
next x
scan
next y
#w.gb3 "flush"
#w.gb3 "getbmp scr 102 102 200 200"
bmpsave "scr", "falseCol1" +right$( "000" +str$( ch), 3) +".bmp"
next ch
[quit]
callDll #user32, "ReleaseDC", handlegb as ulong, hDC as ulong, result as ushort
close #w
end