2016-05-26 38 views
1

我試圖在80毫米紙上居中一個圖像,但它總是在左邊的位置,這是我試過。謝謝星微米中心圖像

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)); 

回答

0

我最終使圖形成爲紙張的大小。所以我使用3英寸80毫米,因此我將圖形1200的寬度增加了250高度,並將我的圖像置於該圖像的中心,以使圖像居中。