bitsy-wallet/PDFJet/src/main/java/com/pdfjet/BitBuffer.java
Severiano Jaramillo 5c6c727b00 Update PDF generation library.
- Added the PDFjet library as a Java Library module to the project and moved all the logic to create the transactions PDF in the TransactionsFragment to use the new PDF lib instead of the old one.
- Fixed the time formatter that was being used to format the transaction's times in exported PDF/CSV files, it was printing months in the place of minutes.
2019-10-01 16:39:35 -05:00

62 lines
1.2 KiB
Java

/**
*
Copyright (c) 2009 Kazuhiko Arase
URL: http://www.d-project.com/
Licensed under the MIT license:
http://www.opensource.org/licenses/mit-license.php
The word "QR Code" is registered trademark of
DENSO WAVE INCORPORATED
http://www.denso-wave.com/qrcode/faqpatent-e.html
*/
package com.pdfjet;
/**
* BitBuffer
* @author Kazuhiko Arase
*/
class BitBuffer {
private byte[] buffer;
private int length;
private int increments = 32;
public BitBuffer() {
buffer = new byte[increments];
length = 0;
}
public byte[] getBuffer() {
return buffer;
}
public int getLengthInBits() {
return length;
}
public void put(int num, int length) {
for (int i = 0; i < length; i++) {
put(((num >>> (length - i - 1)) & 1) == 1);
}
}
public void put(boolean bit) {
if (length == buffer.length * 8) {
byte[] newBuffer = new byte[buffer.length + increments];
System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);
buffer = newBuffer;
}
if (bit) {
buffer[length / 8] |= (0x80 >>> (length % 8));
}
length++;
}
}