gbaor
gbaor

Reputation: 1427

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?

Upvotes: 0

Views: 308

Answers (2)

NSGod
NSGod

Reputation: 22958

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.

Upvotes: 1

Vaibhav Tekam
Vaibhav Tekam

Reputation: 2344

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];

Upvotes: 0

Related Questions