         bit-count>> {
             ! { 32 [ GL_BGRA GL_UNSIGNED_INT_8_8_8_8 ] } ! broken
             { 24 [ GL_BGR GL_UNSIGNED_BYTE ] }
+            { 8 [ GL_BGR GL_UNSIGNED_BYTE ] }
+            { 4 [ GL_BGR GL_UNSIGNED_BYTE ] }
         } case
     ] keep array>> glDrawPixels ;
 

io.backend graphics.viewer io io.binary io.files kernel libc
math math.functions namespaces opengl opengl.gl prettyprint
sequences strings ui ui.gadgets.panes io.encodings.binary
accessors ;
IN: graphics.bitmap

! Currently can only handle 24bit bitmaps.

        swap [ >>array ] [ >>color-index ] bi
        24 >>bit-count ;

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

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

: raw-bitmap>array ( bitmap -- array )
    dup bit-count>>
    {
        { 32 [ "32bit" throw ] }
        { 24 [ color-index>> ] }
        { 16 [ "16bit" throw ] }
        { 8 [ 8bit>array ] }
        { 4 [ 4bit>array ] }
        { 2 [ "2bit" throw ] }
        { 1 [ "1bit" throw ] }
    } case >byte-array ;

ERROR: bitmap-magic ;

