Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7878525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:41:06+00:00 2026-06-03T03:41:06+00:00

I am working with a webservice which gives me an image as an array

  • 0

I am working with a webservice which gives me an image as an array of integers. I have managed to convert this array into an NSData object and then into a UIImage using the code below.
Now I am in doubt how I will convert an image into a similar array.

The array looks like this:

[255,216,255,224,0,16,74,70,73,70,0,1,1,1,0,96,0,96,0,0,255,219,0,67,0,8,6,6,7,6,5,8,7,7,7,9,9,8,10,12,...]

This is the code I use to convert the above array to a UIImage.

+ (UIImage *)imageFromBytes:(NSArray *)bytes
{
    unsigned char *buffer = (unsigned char *) malloc(bytes.count);
    int i = 0;
    for (NSDecimalNumber *num in bytes)
        buffer[i++] = num.intValue;
    NSData *data = [NSData dataWithBytes:buffer length:bytes.count];
    free(buffer);

    return [UIImage imageWithData:data];
}

So, I need to convert a UIImage into an array of integers (a byte array).

Can anybody point me in the right direction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:41:07+00:00Added an answer on June 3, 2026 at 3:41 am

    You can get the data for an image with:

    UIImage *image = [UIImage imageNamed:@"image.png"];
    NSData *data = UIImagePNGRepresentation(image);
    

    If you use a JPG you can use UIImageJPEGRepresentation.

    And then, extract the array of bytes:

    NSUInteger len = [data length];
    Byte *byteData = (Byte*)malloc(len);
    memcpy(byteData, [data bytes], len);
    free(byteData)
    

    You can use also the method (void)getBytes:(void *)buffer length:(NSUInteger)length from NSData:

    [data getBytes:&byteData length:len];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fragment which pulls down data from a webservice and displays this
I have an asp.net webservice which is giving me this: <ArrayOfString> <string>Musterbetrieb</string> <string>Testbetrieb</string> </ArrayOfString>
I'm working on a webservice + AJAX interface, and I'm worried about authentication. This
I am working with the iPhone SDK and I have to process a webservice
I have developed a WebService which will be accessed by 1000's of users at
I am working on an android app in which i have to fetch data
I have a simple Gadget which shows weather details. I am using this google
I am working on a application which gives me all near by places within
I am working in Flex3. Here I have a datagrid which contains data. some
I have some POJOs which are the basis for this RESTful API I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.