What does the file properties say? Mine says 32 BPP for a four bit and an 8 bit one.
'public domain, november 2011, michael calkins
CONST dat = 14~&
DIM Dword AS _UNSIGNED LONG
DIM siz AS _UNSIGNED LONG
DIM wid AS _UNSIGNED LONG
DIM hei AS _UNSIGNED LONG
DIM Word AS _UNSIGNED INTEGER
DIM Byte AS _UNSIGNED _BYTE
DO
LINE INPUT "Enter existing BMP file name to convert to icon: ", BMP$
LOOP UNTIL _FILEEXISTS(BMP$)
DO
LINE INPUT "Enter ICO file name to create (must not exist): ", ICO$
LOOP UNTIL _FILEEXISTS(ICO$) = 0
OPEN BMP$ FOR BINARY ACCESS READ AS 1 'BITMAP name
OPEN ICO$ FOR OUTPUT AS 2 'destination icon name
CLOSE 2
OPEN ICO$ FOR BINARY AS 2
GET 1, 1 + 2, siz 'skip "BM" in bitmap
siz = siz - 14 '14 bytes not used
Word = 0
PUT 2, 1, Word 'reserved
Word = 1
PUT 2, , Word 'resource id 1 as icon, 2 as cursor
PUT 2, , Word 'icon count in resource
GET 1, 1 + dat + 4, wid 'skip header size in BMP
SELECT CASE wid
CASE IS < &H100: Byte = wid '< 256
CASE &H100: Byte = 0
CASE ELSE: PRINT "bitmap is larger than 256 pixels.": END
END SELECT
PUT 2, , Byte 'width
GET 1, , hei
SELECT CASE hei
CASE IS < &H100: Byte = hei '< 256
CASE &H100: Byte = 0 '256 = 0
CASE ELSE: PRINT "bitmap is larger than 256 pixels.": END
END SELECT
PUT 2, , Byte 'height
Byte = 0
GET 1, 1 + dat + 14, Word 'number of colors from BPP
IF Word < 8 THEN Byte = 2 ^ Word ELSE Byte = 0 '256 colors = 0, 4BPP = 16
PUT 2, , Byte 'num of colors
Byte = 0
Dword = 0
PUT 2, , Byte 'reserved as byte
PUT 2, , Dword 'reserved 2 hotspots = 0
Dword = siz + (((wid * hei) + 7) \ 8)
PUT 2, , Dword 'size of data
Dword = 22 '6 byte header + 16
PUT 2, , Dword 'offset
'copy bitmap header down 14 bytes, palette and image info, but double height
SEEK 1, 1 + dat 'BMP info header size
FOR Dword = 1 TO siz 'actual size of data - 14 header bytes not used
GET 1, , Byte
IF Dword = 1 + 8 THEN
Word = hei * 2 ' 2 times height
PUT 2, , Word
Dword = Dword + 1
GET 1, , Byte
ELSE
PUT 2, , Byte
END IF
NEXT
'add null AND bitmask for full square image
Byte = 0
FOR Dword = 1 TO ((hei * wid) + 7) \ 8
PUT 2, , Byte
NEXT
CLOSE
SYSTEM
There is something else to consider. 16 and 48 wide icons pad the AND mask 2 bytes
BitsOver = Width& MOD 32
wid& = 32
hei& = 32
BitsOver = wid& MOD 32
n& = hei& * (wid& + BitsOver) \ 8
PRINT n&