How to convert a specific array of bytes to image
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];
精彩评论