本文整理汇总了Java中net.sourceforge.zbar.Symbol.getData方法的典型用法代码示例。如果您正苦于以下问题:Java Symbol.getData方法的具体用法?Java Symbol.getData怎么用?Java Symbol.getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sourceforge.zbar.Symbol
的用法示例。
在下文中一共展示了Symbol.getData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decodeWithZbar
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
public String decodeWithZbar(byte[] data, int width, int height, Rect crop) {
changeZBarDecodeDataMode();
Image barcode = new Image(width, height, "Y800");
barcode.setData(data);
if (null != crop) {
barcode.setCrop(crop.left, crop.top, crop.width(), crop.height());
}
int result = mImageScanner.scanImage(barcode);
String resultStr = null;
if (result != 0) {
SymbolSet syms = mImageScanner.getResults();
for (Symbol sym : syms) {
resultStr = sym.getData();
}
}
return resultStr;
}
示例2: onPreviewFrame
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Size size = parameters.getPreviewSize();
Image barcode = new Image(size.width, size.height, "Y800");
barcode.setData(data);
int result = scanner.scanImage(barcode);
if (result != 0) {
previewing = false;
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
SymbolSet syms = scanner.getResults();
for (Symbol sym : syms) {
String info = sym.getData();
Intent returnIntent = new Intent();
returnIntent.putExtra("result", info);
setResult(RESULT_OK, returnIntent);
finish();
}
}
}
示例3: onPreviewFrame
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
// Log.d("CameraTestActivity", "onPreviewFrame data length = " + (data != null ? data.length : 0));
codeImage.setData(data);
int result = scanner.scanImage(codeImage);
if (result != 0) {
SymbolSet syms = scanner.getResults();
for (Symbol sym : syms) {
lastScannedCode = sym.getData();
if (lastScannedCode != null) {
scanText.setText(getString(R.string.scan_result_label) + lastScannedCode);
barcodeScanned = true;
}
}
}
camera.addCallbackBuffer(data);
}
示例4: onPreviewFrame
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Size size = parameters.getPreviewSize();
Image barcode = new Image(size.width, size.height, "Y800");
barcode.setData(data);
int result = scanner.scanImage(barcode);
if (result != 0) {
previewing = false;
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
SymbolSet syms = scanner.getResults();
for (Symbol sym : syms) {
String text = sym.getData();
parseWifiInfo(text);
break;
}
}
}
示例5: processData
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
private String processData(Image barcode) {
String result = null;
if (mScanner.scanImage(barcode) != 0) {
SymbolSet syms = mScanner.getResults();
for (Symbol sym : syms) {
String symData = sym.getData();
if (!TextUtils.isEmpty(symData)) {
result = symData;
break;
}
}
}
return result;
}
示例6: onPreviewFrame
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Camera.Size size = parameters.getPreviewSize();
Image barcode = new Image(size.width, size.height, "Y800");
barcode.setData(data);
int result = mScanner.scanImage(barcode);
if (result != 0) {
mCamera.cancelAutoFocus();
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
mPreviewing = false;
SymbolSet syms = mScanner.getResults();
for (Symbol sym : syms) {
String symData = sym.getData();
if (!TextUtils.isEmpty(symData)) {
Intent dataIntent = new Intent();
dataIntent.putExtra(SCAN_RESULT, symData);
dataIntent.putExtra(SCAN_RESULT_TYPE, sym.getType());
setResult(Activity.RESULT_OK, dataIntent);
finish();
break;
}
}
}
}
示例7: onPreviewFrame
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Camera.Size size = parameters.getPreviewSize();
Image barcode = new Image(size.width, size.height, "Y800");
barcode.setData(data);
int result = mScanner.scanImage(barcode);
if (result != 0) {
mCamera.cancelAutoFocus();
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
mPreviewing = false;
SymbolSet syms = mScanner.getResults();
for (Symbol sym : syms) {
String symData = sym.getData();
if (!TextUtils.isEmpty(symData)) {
Intent dataIntent = new Intent();
dataIntent.putExtra(SCAN_RESULT, symData);
dataIntent.putExtra(SCAN_RESULT_TYPE, sym.getType());
setResult(Activity.RESULT_OK, dataIntent);
finish();
break;
}
}
}
}
示例8: onPreviewFrame
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Camera.Size size = parameters.getPreviewSize();
Image barcode = new Image(size.width, size.height, "Y800");
barcode.setData(data);
int result = mScanner.scanImage(barcode);
if (result != 0) {
mCamera.cancelAutoFocus();
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
mPreviewing = false;
SymbolSet syms = mScanner.getResults();
for (Symbol sym : syms) {
String symData = sym.getData();
if (!TextUtils.isEmpty(symData)) {
Intent dataIntent = new Intent();
dataIntent.putExtra(SCAN_RESULT, symData);
dataIntent.putExtra(SCAN_RESULT_TYPE, sym.getType());
setResult(Activity.RESULT_FIRST_USER, dataIntent);
finish();
break;
}
}
}
}
示例9: runDecode
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
public static String runDecode(android.media.Image image/*TaskWorkerProgressHandler handler, TaskWorkerImageProvider provider*/)
{
// handler.setDecodeStateStarted();
// byte[] byteArray = provider.getFrameBuffer();
LuminanceSource source = new PlaneLuminanceSource(
image.getPlanes()[0],
image.getWidth(),
image.getHeight()
);
// HybridBinarizer binarizer = new HybridBinarizer(source);
// BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);
// MultiFormatReader multiFormatReader = new MultiFormatReader();
// ArrayList<BarcodeFormat> possibleFormats= new ArrayList<>();
// possibleFormats.add(BarcodeFormat.CODE_128);
// Map<DecodeHintType, ArrayList> hints = new HashMap<>();
// hints.put(DecodeHintType.POSSIBLE_FORMATS, possibleFormats);
// multiFormatReader.setHints(hints);
// Result contents;
// try
// {
// contents = multiFormatReader.decode(binaryBitmap);
// Log.d("BarCodeTaskWorker", contents.getText());
// return contents.getText();
//// handler.setDecodeStateCompleted();
// }
// catch (NotFoundException e)
// {
//// e.printStackTrace();
//// handler.setDecodeStateFailed();
//
// }
Image barcode = new Image(image.getWidth(), image.getHeight(), "Y800");
barcode.setData(source.getMatrix());
ImageScanner scanner = new ImageScanner();
scanner.setConfig(0, Config.X_DENSITY, 3);
scanner.setConfig(0, Config.Y_DENSITY, 3);
int result = scanner.scanImage(barcode);
if (result != 0) {
SymbolSet syms = scanner.getResults();
for (Symbol sym : syms) {
return sym.getData();
}
}
return null;
}
示例10: onPreviewFrame
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Camera.Size size = parameters.getPreviewSize();
int width = size.width;
int height = size.height;
if(DisplayUtils.getScreenOrientation(getContext()) == Configuration.ORIENTATION_PORTRAIT) {
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
int tmp = width;
width = height;
height = tmp;
data = rotatedData;
}
Image barcode = new Image(width, height, "Y800");
barcode.setData(data);
int result = mScanner.scanImage(barcode);
if (result != 0) {
stopCamera();
if(mResultHandler != null) {
SymbolSet syms = mScanner.getResults();
Result rawResult = new Result();
for (Symbol sym : syms) {
String symData = sym.getData();
if (!TextUtils.isEmpty(symData)) {
rawResult.setContents(symData);
rawResult.setBarcodeFormat(BarcodeFormat.getFormatById(sym.getType()));
break;
}
}
mResultHandler.handleResult(rawResult);
}
} else {
camera.setOneShotPreviewCallback(this);
}
}
示例11: onPreviewFrame
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Camera.Size size = parameters.getPreviewSize();
int width = size.width;
int height = size.height;
if(DisplayUtils.getScreenOrientation(getContext()) == Configuration.ORIENTATION_PORTRAIT) {
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
int tmp = width;
width = height;
height = tmp;
data = rotatedData;
}
Image barcode = new Image(width, height, "Y800");
barcode.setData(data);
int result = mScanner.scanImage(barcode);
if (result != 0) {
stopCamera();
if(mResultHandler != null) {
SymbolSet syms = mScanner.getResults();
Result rawResult = new Result();
for (Symbol sym : syms) {
String symData = sym.getData();
if (!TextUtils.isEmpty(symData)) {
rawResult.setContents(symData);
rawResult.setBarcodeFormat(BarcodeFormat.getFormatById(sym.getType()));
break;
}
}
mResultHandler.handleResult(rawResult);
}
} else {
camera.setOneShotPreviewCallback(this);
}
}
示例12: onPreviewFrame
import net.sourceforge.zbar.Symbol; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Camera.Size size = parameters.getPreviewSize();
Image barcode = new Image(size.width, size.height, "Y800");
barcode.setData(data);
int result = scanner.scanImage(barcode);
if (result != 0) {
previewing = false;
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
SymbolSet syms = scanner.getResults();
for (Symbol sym : syms) {
//scanText.setText("barcode result " + sym.getData());
barcodeScanned = true;
// start sharing activity
Intent intent = new Intent(getApplicationContext(), ShareActivity.class);
String message = sym.getData();
Log.d("MATCH", ""+message.matches(pattern));
if (message.matches(pattern)) {
Toast.makeText(getApplicationContext(), "Location Scanned: "+message,Toast.LENGTH_SHORT).show();
intent.putExtra(EXTRA_MESSAGE,message);
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), "No coordinates found in code: "+message,Toast.LENGTH_SHORT).show();
//mPreview.setCamera(mCamera);
mCamera.setPreviewCallback(previewCb);
mCamera.startPreview();
previewing=true;
mCamera.autoFocus(autoFocusCB);
}
}
}
}