I am working at printing an image to a thermal printer. The image needs to be converted into an unsigned char buffer. For example
unsigned char buffer[10]={0x55,0x66,0x77,0x88,0x44, 0x1B,0x58,0x31,0x15,0x1D}
So far I can covert the image to a black and white version and then loop through it to get each hexadecimal value as an NSString stored in an NSMutableArray. Like below when outputted in the NSLog
( 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 )
I need to be able to loop through the array and retrieve each hex value stored as a string and convert it into an unsigned char so I can add it to my buffer to print
Byte buffer[hexStringArray count];
for (int i=0;i=[hexStringArray count];i++)//add print content
{
buffer[i] = [hexStringArray objectAtIndex:i] // this from string to hex to unsigned char;
}
[sessionController writeData:[NSData dataWithBytes:buffer length:[hexStringArray count]];
How can I convert an NSString hex value into an actual hex, which can then be converted into an unsigned char.