So let me make some principle remarks:
If it's at all possible, use local variables. Global variables should only be used at reasonable exceptions, as e.g. the screen parameters or the image pointers, which are valid within the whole programme.
Don't write a sub for one single statement. The GetGraphicsParameter() function is needless, you can write the ScreenInfo - statement right into the code. It's also needless to call this function multiple times, for their values don't change until the screen is resized, so it only has to be called once after the screen has been established.
Maybe the RGB - statement works at 8 bit colour depth, but if you look how it's calculated, you'll se that its lowest value is 4278190080, so in any case you commit an illegal value. Maybe it works because the overhead bits are ignored, but it's not a good style. You should rather name the colours and define them relating to the colour depth. This also increases the readability of yor code:
Code: Select all
Dim Shared As Integer black, blue, green, cyan, red, magenta, brown, lt_grey, grey, _
lt_blue, lt_green, lt_cyan, lt_red, pink, yellow, white
Select Case d
Case 16,32
black = RGB(0,0,0)
blue = RGB(0,0,255)
green = RGB(0,255,0)
cyan = RGB(0,255,255)
red = RGB(255,0,0)
magenta = RGB(255,0,255)
brown = RGB(139,69,19)
lt_grey = RGB(200,200,200)
grey = RGB(128,128,128)
lt_blue = RGB(80,80,255)
lt_green = RGB(80,255,80)
lt_cyan = RGB(80,255,255)
lt_red = RGB(255,80,80)
pink = RGB(255,20,147)
yellow = RGB(255,255,0)
white = RGB(255,255,255)
Case Else
black = 0
blue = 1
green = 2
cyan = 3
red = 4
magenta = 5
brown = 6
lt_grey = 7
grey = 8
lt_blue = 9
lt_green = 10
lt_cyan = 11
lt_red = 12
pink = 13
yellow = 14
white = 15
End Select
Regarding to the "padding" you are right, every line consists of a multiple of 16 bits. This considerably increases the calculation speed of the processor.
Accessing to the pixel data, the only thing you have to know about the put header is that it's 34 bytes long so you can skip it. If you're interested in more details look here:
http://www.freebasic.net/forum/viewtopi ... 2&start=30
Static variables are used inside of procedures (subs and functions) to keep their value from one call to the next (otherwise every local variable is set to its initial value when entering a procedure). Variables in the main programme are "automatically" static.
Regards
grindstone