| |
|
|
| |
Read bitmap pixel from file (slower access, lower memory) |
|
| |
|
|
the bitmap object the x, y coordinates
color value of the pixel
| |
|
|
| |
Implementation
01 function bmp_readpixel( bitmap, x, y )
02 dim bpp: bpp = bitmap( BMP_INFO )( BMP_BITS ) \ 8
03 dim bps: bps = ( ( ( bitmap( BMP_INFO )( BMP_WIDTH ) * bitmap( BMP_INFO )( BMP_BITS ) ) + 31 ) \ 32 ) * 4
04 dim offset: offset = bitmap( BMP_HEADER )( BMP_BITOFFSET ) + x * bpp + y * bps
05 call file_moveto( bitmap( BMP_FILE ), offset )
06 select case bitmap( BMP_INFO )( BMP_BITS )
07 case 32
08 bmp_readpixel = file_readdword( bitmap( BMP_FILE ) )
09 case 24
10 dim b: b = file_readbyte( bitmap( BMP_FILE ) )
11 dim g: g = file_readbyte( bitmap( BMP_FILE ) )
12 dim r: r = file_readbyte( bitmap( BMP_FILE ) )
13 bmp_readpixel = rgb( r, g, b )
14 case else
15 bmp_readpixel = -1
16 end select
17 end function
|
|
| |
|
|
|