                 ! color-important
                 [ drop 0 write4 ]
 
-                ! rgb-quads
+                ! color-palette
                 [
                     [ bitmap>color-index ]
                     [ dim>> first 3 * ]

    ] when ;

: parse-bitmap ( loading-bitmap -- loading-bitmap )
    dup rgb-quads-length read >>rgb-quads
    dup color-index-length read >>color-index
    fixup-color-index ;

: load-bitmap-data ( path -- loading-bitmap )
    binary [
        loading-bitmap new
        parse-file-header parse-bitmap-header parse-bitmap

<PRIVATE

: 8bit>buffer ( bitmap -- array )
    [ color-palette>> 4 <sliced-groups> [ 3 head-slice ] map ]
    [ color-index>> >array ] bi [ swap nth ] with map concat ;

ERROR: bmp-not-supported n ;
