Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Contributor
Posts: 27
Registered: ‎07-26-2012
My Device: i dont have a blackberry device
My Carrier: i dont have a blackberry device

Barcode 1D EAN 13 Writer Blackberry Java OS 7

Hello, Everybody

I have a problem during Generate EAN 13 Barcode on Blackberry OS 7.

I already create a code that generate EAN 13 i tested it on simulator os 6 9800 its working fine

but when i try on simulator dakota 9900 os 7 the barcode goes all black

this is my code

 

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

 

 

 

can somebody help me to solve this problem ?

best regards,

aditya eka putra

best regards,
aditya eka putra (@abang_adit)