Edit: it turned out that my earlier implementation was faster on my machine, not sure why. I’m using 2.4.1. Here’s what I’ve built around that:
#@gui 8-Bit planes : fx_bitplane8, fx_bitplane8_preview(1)
#@gui : Mode = choice("Decompose","Recompose")
#@gui : Split mode = choice("Z layers","Separate images")
#@gui : Scale mode = choice("True","1","255")
fx_bitplane8 :
if $1
##recompose
if {!$2} s z fi
repeat {int($!/8)} l[$>-{$>+7}]
repeat 8
iter=$>
l[$>]
if {$3==0}
/ {2^$iter} cut 0,1 round 0,1 * {2^$iter}
elif {$3==1}
cut 0,1 round 0,1 * {2^$iter}
elif {$3==2}
/ 255 cut 0,1 round 0,1 * {2^$iter}
fi
endl done
+
endl done
else
##decompose
repeat 8
[0]
&[-1] {2^$>}
if {$3==1}
/[-1] {2^$>}
elif {$3==2}
/[-1] {2^$>/255}
fi
if {!$2} a[^0] z fi
done
rm[0]
fi
#n 0,255
fx_bitplane8_preview :
fx_bitplane8 $*