Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert images to bytes and bytes to image?

Tags:

ios

iphone

How to convert images to bytes and send out to a stream, then receive bytes from the input stream, and convert the bytes into images again?

like image 552
user831098 Avatar asked Oct 18 '25 19:10

user831098


1 Answers

For getting bytes from an image:

NSData *imageData = UIImageJPEGRepresentation(image, imageQuality);

For getting an image from bytes:

UIImage *image = [UIImage imageWithData: imageData];

BTW, If you need the bytes from the NSData just call its bytes method.

like image 181
Jason Fuerstenberg Avatar answered Oct 20 '25 09:10

Jason Fuerstenberg