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

  • Home
  • SEARCH
  • 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 8120233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:04:55+00:00 2026-06-06T05:04:55+00:00

I am using Grand Central Dispatch to queue a task to capture a UIView

  • 0

I am using Grand Central Dispatch to queue a task to capture a UIView as an image. Everything is working fine with this except that the image capturing running on a queue is taking quite a long time.

Is there any way to speed this up or improve my technique. Here is the code to capture and scale the image, which is then set to a UIImageView‘s image for displaying.

(void)captureScrollViewImageForLayoverView
{
    // capture big map image
    CGSize size = mainView.bounds.size;
    UIGraphicsBeginImageContext(size);
    [[mainView layer] renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    // scale map
    size = myLocationOverlay.bounds.size;
    UIGraphicsBeginImageContext(size);
    [newImage drawInRect:CGRectMake(0,0,size.width,size.height)];
    UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    myLocationOverlay.imageMap.image = scaledImage;
}

And Here is the code that is queueing the task.

...
mapImageDrawQueue = dispatch_queue_create("mapImage.drawQueue", NULL);

(void)captureScrollViewImageForLayoverViewWrapper {
    // multithreaded approach to draw map
    dispatch_async(mapImageDrawQueue, ^{ [self captureScrollViewImageForLayoverView]; });
}
  • 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-06T05:04:57+00:00Added an answer on June 6, 2026 at 5:04 am

    I used to load images at queue in my app with same issue you mentioned. I checked official programming guide, remembered it told that it can’t guarantee the queue run immediately after you call it. So I used NSThread do the job, and it’s working well:

    NSThread* myThread = [[NSThread alloc] initWithTarget:self
                                            selector:@selector(captureScrollViewImageForLayoverView)
                                            object:nil];
    [myThread start];
    

    Remember add these lines to the function captureScrollViewImageForLayoverView:

    At top : NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    At end : [pool release];

    Check this doc to know more – Threading Programming Guide
    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am testing some code that does asynchronous processing using Grand Central Dispatch. The
I am trying to understand the proper way of using Grand Central Dispatch (GCD)
I have been using with success, grand central dispatch in my apps, but I
Using Flex 3, I would like to take an image snapshot such as this:
I'm trying to enforce a specific order for tasks to complete using Grand Central
I am adding a block to a queue (not the main queue), using Grand
here is the code that i am using for the sub totals and grand
I've been scouring Apple's documentation on application states and Grand Central Dispatch, but I
I'm newbie programming for mac and i'm really surprised on Grand Central Dispatch. I
I have a UITableView with custom cells. I load images asynchronously using Grand Central

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.