Printer doesn't take the alignment of the image in to account. The logo is always left aligned by default. Text gets aligned with no problem. So there is nothing wrong with the aligncenter()
method .When I set the alignment inside the while loop, a series of question marks get printed all over the paper.
public void printImage(Bitmap bitmap, boolean center) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int newWidth = this.mType58 ? 384 : 576;
if (width > (this.mType58 ? 384 : 576)) {
bitmap = LibUtil.setImgSize(bitmap, (float) newWidth, (float) (height / (width / newWidth)), (float) width, (float) height);
}
try {
PrinterWriter mThirdPrinter = this.mType58 ? new PrinterWriter58mm(384, 384) : new PrinterWriter80mm(576, 576);
ArrayList<byte[]> datas = mThirdPrinter.getImageByte(bitmap);
if (mThirdPrinter.getDataAndClose() == null) {
if (this.mCallback != null) {
this.mCallback.onError(ErrorCode.IMAGE_NOT_FONUD);
}
return;
}
try {
datas.add(mThirdPrinter.getDataAndClose());
} catch (NullPointerException e) {
e.printStackTrace();
}
if (datas == null) {
DebugLog.LogD("imgpath is empty, datas is null, maybe is TFCard");
return;
}
this.mPrinterModule.sendData(new byte[]{(byte) 27, (byte) 74, (byte) 0});
Iterator it = datas.iterator();
byte [] alignment = alignCenter();
int i = 0 ;
byte [] data1 = null ;
while (it.hasNext()) {
data1[i] = (byte) it.next();
}
this.mPrinterModule.sendData(alignment);
this.mPrinterModule.sendData(data1);
} catch (IOException e2) {
e2.printStackTrace();
}
}