Java 星微中心图像
我试图在80毫米纸上居中放置一个图像,但它总是在左边,这就是我尝试的。谢谢Java 星微中心图像,java,printing,receipt,Java,Printing,Receipt,我试图在80毫米纸上居中放置一个图像,但它总是在左边,这就是我尝试的。谢谢 AssetManager assetManager = mContext.getAssets(); InputStream istr = null; try { istr = assetManager.open("www/img/logo.jpg"); } catch (IOException e) { e.printStackTrace(); }
AssetManager assetManager = mContext.getAssets();
InputStream istr = null;
try {
istr = assetManager.open("www/img/logo.jpg");
} catch (IOException e) {
e.printStackTrace();
}
Bitmap bm = BitmapFactory.decodeStream(istr);
StarBitmap starbitmap = new StarBitmap(bm, false, 200);
commands.add(new byte[] { 0x1b, 0x61, 0x01 }); //align center
commands.add(starbitmap.getImageEscPosDataForPrinting(false,true));
我最终把这张图做成了纸的大小。因此,我使用了3英寸80mm,因此我制作了1200宽250高的图形,并将图像居中在画布上,使图像居中。我最终将图形制作成纸张大小。所以我用了3英寸80mm,所以我制作了1200宽250高的图形,并将我的图像放在画布的中心,画布为我居中