I need your help.
I am trying to print an image in B64, but I have not succeeded, I have read several forums and I hace not found the solution, I need to know which algorithm zpl accepts, the development i hace in Java 8.
I only need to know what the algorithm is to convert a PNG to B64, but without using an external tool.???
Thanks!!
MyCode:
public void Converter(){
File file = new File("/storage/sdcard0/DCIM/image.png"); try {
FileInputStream imageInFile = new FileInputStream(file); byte imageData[] = new byte[(int) file.length()]; imageInFile.read(imageData); String imageDataString = encodeImage(imageData); ZCRC16 zcrc16 = new ZCRC16(); String crc16 = zcrc16.getCRC16ForZpl(imageDataString); Log.d("B64 :: " + imageDataString.toString()); Log.d("CRC :: ", crc16); } catch (FileNotFoundException e) {
System.out.println("Image not found" + e); } catch (IOException ioe) {
System.out.println("Exception while reading the Image " + ioe); }
}
public static String encodeImage(byte[] imageByteArray) {
return Base64.encodeBytes(imageByteArray, Base64.ENCODE); }
Please!!
Thanks
What is the B64 algorithm that accepts to print an image |
1 Replies
Hi Daniel,
The best option is to use the Base64.Encoder class in Java if you are not going to use the Zebra SDK. You need to set it to MIME output by getting and using the MIME encoder.
https://www.tutorialspoint.com/java8/java8_base64.htm
https://www.zebra.com/content/dam/zebra/manuals/en-us/software/zpl-zbi2…