开发者

How to convert a specific array of bytes to image

开发者 https://www.devze.com 2023-02-18 13:13 出处:网络
The specific structure of array is: first number= count of bytes, second number= width, third number= height, after these are 3 numbers for RBG for all of pixels.

The specific structure of array is: first number= count of bytes, second number= width, third number= height, after these are 3 numbers for RBG for all of pixels.

Can I use a class or a method in 开发者_运维知识库iPhone SDK to convert these bytes to UIImage? Or do I have to write a function, which draw a picture from the byte array?


Look at CGImageCreate() which should allow you to create an image from data in a structured format. You can then create a UIImage from the resulting CGImage.


How are you getting that array, from some webService or you are creating in the coding side?

You can create an object of NSData Class

NSData * imageData = [[NSData allc] initWith..];

see different methods available for the class.

Use this data object to create your image.

UIImage * image = [[UIImage alloc]initWithData:imageData];
0

精彩评论

暂无评论...
验证码 换一张
取 消