What is the B64 algorithm that accepts to print an image

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

Anonymous (not verified)
Hi Daniel,The best option is

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-pm-en.pdf#page=1316

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


daniel Ppe
Once you get the MIME code,

Once you get the MIME code, how did you find it to read zpl?

With this command

^ FO0.608 ^ GFA, 46080,46080,00072, B64:

Thank you!!!!!!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Daniel,The ^GF command

Hi Daniel,

The ^GF command does not work as well with PNG graphics.  You are better off using the download object command:

~DYE:IMAGE,P,P,46080,,B64:....

^XA...^FO0,608^IME:IMAGE.PNG^FS...^XZ

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


daniel Ppe
Ok, then it's:     ~DYE:IMAGE

Ok, then it's:

    

~DYE:IMAGE,P,P,46080,,B64:  Encode B64:CRC

^XA

^FO0,608^IME:IMAGE.PNG^FS

^XZ

And if it is with the Zebra SDK how do I get the B64 with java?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Tim Borowsky
Hello Robin,Which image

Hello Robin,

Which image/graphic types does the ^GF command work with well?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
For the compression type for

For the compression type for ^GF, please check the ^GF – Graphic Field requirements. If we have an image in a different type, we can always to the Graphic Conversion Wizard tool that comes with the ZebraNet Bridge Enterprise.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments