I'm trying to create a barcode scanner app für iOS using RoboVM.
I'm using the
ZXing framework for that, because it works fine under swing and android.
Now I wonder how I can convert the UIImage (iOS) class to an BinaryBitmap (ZXing model class).
This is how to use the framework in swing:
BufferedImage bImage = ImageIO.read(new File("barcode.png"));
LuminanceSource source = new BufferedImageLuminanceSource(bImage);
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new MultiFormatReader();
Result result = reader.decode(binaryBitmap);
String text = result.getText();
This is the android way:
Bitmap mBitmap = BitmapFactory.decodeFile("barcode.png");
int width = mBitmap.getWidth();
int height = mBitmap.getHeight();
int[] pixels = new int[width * height];
mBitmap.getPixels(pixels, 0, width, 0, 0, width, height);
RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new MultiFormatReader();
Result result = reader.decode(binaryBitmap);
String text = result.getText();
What is the RoboVM / iOS way to do that?