I tried to print image and text in receipt using Cpcl format like that template. I have an example set logo as a variable and use function to read the image as string but that image in example is CPCL format I tried a lot to get my logo as a cpcl format but i can't so I need to know how to get my image logo as cpcl format or another way to set image and text like that templete.
====================================================
//this template used to design my ticket which it has image and text in the same ticket like what i need.
! 0 200 200 1050 1
PW 575
TONE 0
SPEED 3
ON-FEED IGNORE
NO-PACE
BAR-SENSE
BT 0 4 6
B 128 3 30 120 20 0 ${barcode}
/* the line below is used to set image as a string variable initialized
in code from image i have in the worked example which its extension
logo.cpcl" I don't know how it comes? and i need to change new logo to
Cpcl from png too "newlogo.png -> newlogo.cpcl" "pcx" x, y, data"*/
PCX 420 790 ${Logo}
ML 32
T270 7 0 550 170 ${typeTicket}
ENDML
ML 32
T270 7 0 498 170 ${validPeriod}
ENDML
ML 25
T270 7 0 446 170 ${park}
ENDML
ML 32
T270 7 0 370 170 ${price}
ENDML
ML 25
T270 7 0 300 170 ${termsOfUse}
ENDML
PRINT
=================================
//this function only to understand what i use to read the image.
[//this line I use to call the function to read cpcl image!
//and here we got the image from resources
result = StringUtils.replace(result, "${Logo}", PrinterUtil.readFormat(context, R.raw.logo));
//this is the code used to read image as a string and it works perfectly with the example.
public static String readFormat(Context context, int formatRes) {
InputStream is = null;
try {
is = context.getResources().openRawResource(formatRes);
try {
return readString(is);
} catch (IOException e) {
return null;
}
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
}
}
}
}][1]