Bit-Based BinaryWriter in C#

后端 未结 4 1977
生来不讨喜
生来不讨喜 2021-02-08 23:22

I\'m working on a bit-based B/W/Greyscale Pre-Compiled font format, and was having issues with either reading or writing the format, (I\'ve not been able to determine where the

4条回答
  •  佛祖请我去吃肉
    2021-02-09 00:07

    I don't believe there's anything in the framework for this, no. Basically you'd need to write a class to wrap a BinaryWriter (or just a stream) and "the byte written so far" and the number of bits written. When the number of bits gets to 8, write the byte to the underlying stream and clear.

    EDIT: the OP posted a possible and working implementation of the above suggestion below.

提交回复
热议问题