| |
|
|
| |
Read all bitmap pixels from file (don't use for big images) |
|
| |
|
|
the bitmap object
an array with all the pixels
| |
|
|
| |
Implementation
01 function bmp_readpixels( bitmap )
02 dim w: w = bitmap( BMP_INFO )( BMP_WIDTH )
03 dim h: h = bitmap( BMP_INFO )( BMP_HEIGHT )
04 dim length: length = w * h
05 dim bpp: bpp = bitmap( BMP_INFO )( BMP_BITS )
06 dim bps: bps = ( ( ( w * bpp ) + 31 ) \ 32 ) * 4
07 dim stride: stride = bps - ( w * ( bpp / 8 ) )
08
09 dim pixels: pixels = array_allocate( length )
10 select case bitmap( BMP_INFO )( BMP_BITS )
11 case 32
12 dim index
13 for index = 0 to length - 1
14 pixels( index ) = file_readdword( bitmap( BMP_FILE ) )
15 next
16 bmp_readpixels = pixels
17 case 24
18 dim x, y
19 for y = 0 to h - 1
20 for x = 0 to w - 1
21 dim b: b = file_readbyte( bitmap( BMP_FILE ) )
22 dim g: g = file_readbyte( bitmap( BMP_FILE ) )
23 dim r: r = file_readbyte( bitmap( BMP_FILE ) )
24 pixels( index ) = rgb( r, g, b )
25 index = index + 1
26 next
27 call file_skipbytes( bitmap( BMP_FILE ), stride )
28 next
29 bmp_readpixels = pixels
30 case else
31 bmp_readpixels = vbnull
32 end select
33 end function
|
|
| |
|
|

|