简体   繁体   English

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

[英]How to print an image to a MZ220 Printer from Android application?

I have a Zebra MZ220 portable Bluetooth printer. 我有一台Zebra MZ220便携式蓝牙打印机。

currently i am able to print text/string on the printer through my android application using the following code... 目前我能够通过我的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();

} }

I want to know if there is a way i can print an image on the printer through my android application, if so how? 我想知道是否有办法可以通过我的Android应用程序在打印机上打印图像,如果是这样的话怎么样? The image is stored on the SD card. 图像存储在SD卡上。 Any assistance? 任何帮助? Thanks 谢谢

Yes there is! 就在这里! Check out the Developer demos that came developer demos that came with the SDK 查看随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()) BitmapFactory.decodeFile(file.getAbsolutePath())

and you can pass that to the printer via 你可以通过它传递给打印机

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM