2012-12-26 112 views
0

我在生成EAN 13條碼在黑莓操作系統7 我有一些問題,我實際上已經創建了一些代碼來生成EAN 13,它在模擬器9800操作系統6上工作良好,但是當我在模擬器9900達科他州OS 7條形碼進入全黑 有人可以請幫我解決我的問題生成條形碼EAN13黑莓操作系統7

這裏我的代碼

public void ean13writer(String ang){ 
    try { 
     EAN13Writer ean13 = new EAN13Writer(); 
     ByteMatrix barcode = ean13.encode(ang , BarcodeFormat.EAN_13 , width , height); 
     System.out.println("barcode : "+barcode); 

     jajal= ByteMatrix2Bitmap(barcode); 
     VerticalFieldManager cardcodemanager = new VerticalFieldManager(){ 

     }; 
     Bitmap borderBitmap = Bitmap.getBitmapResource("rounded-border.png"); 
     BitmapField cardcode = new BitmapField(jajal); 

     cardcodemanager.add(cardcode); 
     cardcodemanager.setMargin(2, 40, 2, 40); 
     cardcodemanager.setPadding(2, 10, 2, 10); 
     cardcodemanager.setBorder(
       BorderFactory.createBitmapBorder(
         new XYEdges(12,12,12,12), borderBitmap 
        ) 
       ); 

     cardScreen.add(cardcodemanager); 
    }catch (Exception e) { 
     //add(new RichTextField("gagal coy : " + e)); 
     String a = String.valueOf(e).toString(); 
     Dialog.alert(a); 
    } 
} 
private static Bitmap ByteMatrix2Bitmap(ByteMatrix matrix){ 
    int width = matrix.getWidth(); 
    int height = matrix.getHeight(); 
     //matrix is a 0-1 matrix 
     byte[][] array = matrix.getArray(); 
     int[] imgdata = new int[width*height]; 
     Bitmap bitmap = new Bitmap(width, height); 

     //System.out.println("hasil array byte [] [] ="+matrix.getArray()); 

     for (int y = 0; y < height; y++) { 
      for (int x = 0; x< width; x++){ 
       if (array[y][x] == 0){ 
         imgdata[y * width + x] = Bitmap.TRUE_WHITE; 
         //System.out.println("KALO 0 = "+imgdata[y * width + x]); 
       }else{ 
         imgdata[y * width + x] = Bitmap.TRUE_BLACK; 
         //System.out.println("KALO BUKAN = "+imgdata[y * width + x]); 
       } 
      } 
     } 
     bitmap.setARGB(imgdata, 0, width, 0, 0, width, height); 
     Bitmap retmap = new Bitmap(2*width ,10*height); 
     bitmap.scaleInto(retmap, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FIT); 


     return retmap; 
} 

問候 阿迪亞EKA太子

+0

我已經解決了這個問題:),問題是位圖.TRUE_WHITE在os 7上不起作用,所以我用(0xFFFFFF) –

回答

0

我已經解決了這個問題:),問題是Bitmap.TRUE_WHITE不適用於操作系統7,所以我用(0xFFFFFF) 取代它也許它可以幫助某人以後