How to convert image into hexa decimal bytes array to send it to output stream in iOS sdk

后端 未结 2 1948
醉酒成梦
醉酒成梦 2021-02-06 17:53

I wan to print an image on a bluetooth printer. I got some sample code by the printer manufacturer. Here is the code -

unsigned char buffer3[796]={
                     


        
2条回答
  •  天命终不由人
    2021-02-06 18:31

    I guess, the printer will not take any image format? However, here is how you can convert an image to a byte array, hope this will help:

    NSData *data = [NSData dataWithContentsOfFile:imagePath];
    NSUInteger length = [data length];
    Byte *bytes = (Byte*)malloc(length);
    memcpy(bytes, [data bytes], length);
    

提交回复
热议问题