I need to transform an image into an array of bytes, how do I make this image into an Array Bytes?
I need to transform an image into an array of bytes, how do I make this image into an Array Bytes?
You can use the functions UIImageJPEGRepresentation or UIImagePNGRepresentation to cover your image in NSData
. From there you can allocate an array of bytes of the data size, and copy the bytes to it, as in the example below.
UIImage *image = [UImage imageNamed:@"foto.png"];
NSData *data = UIImagePNGRepresentation(image);
NSUInteger len = [data length];
Byte *bytes = (Byte*)malloc(len);
memcpy(bytes, [data bytes], len);