如何打印图像从Android应用程序MZ220打印机? [英] How to print an image to a MZ220 Printer from Android application?
问题描述
我有一台Zebra MZ220便携式蓝牙打印机。
目前,我能够通过我的Android应用程序中使用以下code中的打印机上打印文本/字符串...
私有静态无效sendZplOverBluetooth(最后弦乐theBtMacAddress,最终字符串数据){
新主题(新的Runnable接口(){
公共无效的run(){
尝试{
ZebraPrinterConnection thePrinterConn =新BluetoothPrinterConnection(theBtMacAddress);
尺蠖prepare()。
thePrinterConn.open();
字符串zplData =数据;
thePrinterConn.write(zplData.getBytes());
视频下载(500);
thePrinterConn.close();
Looper.myLooper()退出()。
}
赶上(例外五){
e.printStackTrace();
}
}
})。开始();
}
我想知道是否有一种方法,我可以通过我的Android应用程序在打印机上打印图像时,如果又如何?图像存储在SD卡上。任何帮助?谢谢
是的,有!检查出来,随着SDK
来到开发商演示了开发者演示<$p$p><$c$c><install_dir>\\android\\<version>\\demos\\src\\com\\zebra\\android\\devdemo\\imageprint\\ImagePrintDemo.java下面是你如何得到一个位图:
BitmapFactory.de codeFILE(file.getAbsolutePath())
块引用>和您可以通过
传递到打印机
getGraphicsUtil()。printImage(pathOnPrinter,位图,[X],[Y])
块引用>I have a Zebra MZ220 portable Bluetooth printer.
currently i am able to print text/string on the printer through my android application using the following code...
private static void sendZplOverBluetooth(final String theBtMacAddress, final String Data) { new Thread(new Runnable() { public void run() { try { ZebraPrinterConnection thePrinterConn = new BluetoothPrinterConnection(theBtMacAddress); Looper.prepare(); thePrinterConn.open(); String zplData = Data; thePrinterConn.write(zplData.getBytes()); Thread.sleep(500); thePrinterConn.close(); Looper.myLooper().quit(); } catch (Exception e) { e.printStackTrace(); } } }).start();
}
I want to know if there is a way i can print an image on the printer through my android application, if so how? The image is stored on the SD card. Any assistance? Thanks
解决方案Yes there is! Check out the Developer demos that came developer demos that came with the SDK
<install_dir>\android\<version>\demos\src\com\zebra\android\devdemo\imageprint\ImagePrintDemo.java
Here is how you get a Bitmap:
BitmapFactory.decodeFile(file.getAbsolutePath())
and you can pass that to the printer via
getGraphicsUtil().printImage(pathOnPrinter, bitmap, [x], [y])
这篇关于如何打印图像从Android应用程序MZ220打印机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!