public static String convertImageToHex(Bitmap orginalImage){
StringBuffer sb = new StringBuffer();
int height = orginalImage.getHeight();
int width = orginalImage.getWidth();
int rgb, red, green, blue, index = 0;
char auxBinaryChar[] = {'0', '0', '0', '0', '0', '0', '0', '0'};
for (int h = 0; h < height; h++) {
for (int w = 0; w < width; w++) {
rgb = orginalImage.getPixel(w,h);
red = (rgb >> 16) & 0x000000FF;
green = (rgb >> 8) & 0x000000FF;
blue = (rgb) & 0x000000FF;
char auxChar = '1';
int totalColor = red + green + blue;
if (totalColor > 450) {
auxChar = '0';
}
auxBinaryChar[index] = auxChar;
index++;
if (index == 8 || w == (width - 1)) {
int decimal = Integer.parseInt(new String(auxBinaryChar), 2);
String hex = decimal > 15 ? Integer.toString(decimal, 16).toUpperCase() : "0" + Integer.toString(decimal, 16).toUpperCase();
sb.append(hex);
auxBinaryChar = new char[]{'0', '0', '0', '0', '0', '0', '0', '0'};
index = 0;
}
}
}
return sb.toString();
}
cpcl:"EG " + width + " " + height * 8 + " 0" + " 0" + " " + imgHex
zpl:"^GFA," + width * height * 8 + "," + width * height * 8 + "," + width + "," + imgHex