0

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

4 Comments

I'm getting the array from a network socket. It is in a NSMutableData and I hae to draw the picture from this.
using the method UIImage * image = [[UIImage alloc]initWithData:imageData]; should not be a problem for you then. Have you tried it?
This is not going to work. UIImage:initWithData: is for image data encoded in PNG, JPEG or another supported image format. However, here we're dealing with a custom, uncompressed format.
this was not told when the question was posted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.