gpt4 book ai didi

android - 如何从 Android 应用程序将图像打印到 MZ220 打印机?

转载 作者:太空狗 更新时间:2023-10-29 12:57:08 27 4
gpt4 key购买 nike

我有一台 Zebra MZ220 可移植蓝牙打印机。

目前我可以使用以下代码通过我的 android 应用程序在打印机上打印文本/字符串...

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();

我想知道是否有一种方法可以通过我的 android 应用程序在打印机上打印图像,如果可以的话怎么办?图像存储在 SD 卡上。有什么帮助吗?谢谢

最佳答案

是的,有!查看 SDK 附带的开发人员演示

<install_dir>\android\<version>\demos\src\com\zebra\android\devdemo\imageprint\ImagePrintDemo.java

这是获取位图的方法:

BitmapFactory.decodeFile(file.getAbsolutePath())

你可以通过

把它传给打印机

getGraphicsUtil().printImage(pathOnPrinter, bitmap, [x], [y])

关于android - 如何从 Android 应用程序将图像打印到 MZ220 打印机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5247371/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com