diff options
author | Jay Berkenbilt <ejb@ql.org> | 2018-01-14 00:13:18 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2018-01-14 01:49:42 +0100 |
commit | d9c90497089ae5cf00891d6febfa7f486f021833 (patch) | |
tree | 37ff785d288aa4433eba89230ab7c877b573bc91 /libqpdf/BitWriter.cc | |
parent | bf2fb239d7a39255fe122db50dd5d03f9baa25ae (diff) | |
download | qpdf-d9c90497089ae5cf00891d6febfa7f486f021833.tar.zst |
Add signed support to BitStream and BitWriter
Diffstat (limited to 'libqpdf/BitWriter.cc')
-rw-r--r-- | libqpdf/BitWriter.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libqpdf/BitWriter.cc b/libqpdf/BitWriter.cc index 4fb375cb..7513ac76 100644 --- a/libqpdf/BitWriter.cc +++ b/libqpdf/BitWriter.cc @@ -18,6 +18,21 @@ BitWriter::writeBits(unsigned long long val, unsigned int bits) } void +BitWriter::writeBitsSigned(long long val, unsigned int bits) +{ + unsigned long long uval = 0; + if (val < 0) + { + uval = static_cast<unsigned long long>((1 << bits) + val); + } + else + { + uval = static_cast<unsigned long long>(val); + } + writeBits(uval, bits); +} + +void BitWriter::flush() { if (bit_offset < 7) |