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 7191833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:48:45+00:00 2026-05-28T19:48:45+00:00

I am going through the following tutorial . I need to get thumbnail images

  • 0

I am going through the following tutorial. I need to get thumbnail images of a large image. According to the tutorial the following method does it.

CGImageRef MyCreateThumbnailImageFromData (NSData * data, int imageSize)

note: look at the tutorial if you need the full code for this method

My questions are;

1.) i have a URL http://www.myimage.com/smile.jpg , and i need to resize it to a thumbnail. I don’t undestand what is the NSData * data parameter. All what i have is a String URL. So how can i pass my URL to this method programatically ?

2.) The above method returns a CGImageRef But i need a UIImage so i could add it to a UIIMageVIew and then display it in my project. So how can i use CGImageRef to display images in my project ?

3.) The images i am downloading are very big, 2MB or more. By making it to appear in a thumbnail size, will it reduce the time taken to load the image to the view ?

  • 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-05-28T19:48:46+00:00Added an answer on May 28, 2026 at 7:48 pm

    Lets go through this, step by step:

    1) An NSData object is a wrapper for an array of bytes, or char *. This is the raw bytes of the image you need.

    2) A CGImageRef is CoreGraphics‘s way of representing an image, which can be converted to a UIImage with the selector +imageWithCGImage:. Generally speaking, you have more fine control over the image with a CGImageRef.

    3) Converting these images to a thumbnail will not reduce the time it takes to download. The file must first be downloaded to memory before it is converted.

    Example of how to use your function:

    int myImageSize = .... // do what you need to to figure out the size of the image
    UIImage *myImage = [UIImage imageWithCGImage:MyCreateThumbnailImageFromData([NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.myimage.com/smile.jpg"]], myImageSize)];
    

    This, however will block the user interface, consider using GCD or NSURLConnection instead of -dataWithContentsOfURL:.

    EDIT: Example with GCD:

    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        __block UIImage *myImage = [UIImage imageWithCGImage:MyCreateThumbnailImageFromData([NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.myimage.com/smile.jpg"]], myImageSize)];
    
        [myImageView performSelectorOnMainThread:@selector(setImage:) withObject:myImage waitUntilDone:NO];
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the following error when going through the WCF tutorial. HTTP could not
While going through a Zend tutorial , I came across the following statement: Note
I'm going through the second edition of Ruby on Rails Tutorial (http://ruby.railstutorial.org/). I'm following
While Going through the java tutorial on sun site, I see following piece of
I am going through a series of NeHe OpenGK tutorials. Tutorial #9 does some
I am new to MVC. I am going through the following tutorial . I
I'm going through the Yii tutorial on creating a blog and following the steps.
I have been following a video tutorial from O'reilly media going through the basics
While going through university and from following the development of SO, I've heard a
Going through Javascript documentation, I found the following two functions on a Javascript object

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.