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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:17:07+00:00 2026-06-10T21:17:07+00:00

For the iPhone, I am clipping an image with CGContextClipToMask. In 320×480, it is

  • 0

For the iPhone, I am clipping an image with CGContextClipToMask.

In 320×480, it is looking beautiful.
But in the retina display/simulator the masking looks like it has been done in 320×480, and then scaled up to 640×960 – it looks a bit tatty.

The correct 640×960 images are being used (I’ve marked them to make sure).

My code is below. Does anyone know what it might be? Would be super grateful for some help. Many thanks.

-(id)makeMainImage:(UIImage*)initMaskImg initMainImage:(UIImage*)initMainImage{

    //get images
    UIImage *mainImg = initMainImage;
    UIImage *maskImg = initMaskImg;

    //new context, to draw image into
    UIGraphicsBeginImageContext(mainImg.size);
    CGContextRef context = UIGraphicsGetCurrentContext();

    //position context
    CGContextTranslateCTM(context, 0,480);
    CGContextScaleCTM(context, 1.0, -1.0);//flip coordinates

    //rect
    CGRect imageRect = CGRectMake(0, 0, 320, 480);

    //set mask
    CGContextClipToMask(context, imageRect, maskImg.CGImage);

    //main image
    CGContextDrawImage(context, imageRect, mainImg.CGImage);

    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();    

    return newImage;
}
  • 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-10T21:17:08+00:00Added an answer on June 10, 2026 at 9:17 pm

    Don’t use ‘UIGraphicsBeginImageContext’, use

    UIGraphicsBeginImageContextWithOptions(size, opaque, 0); // last option is the scale option
    

    This is how you create retina images.

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

Sidebar

Related Questions

Cocos2d-iphone 1.0.1 I enable retina display for my app. I provide myimage.png,but I don't
in iphone i have requirement of store image in cache . but how i
iPhone 4 has 960-by-640 resolution while iPhone 3G only 480-by-320. Do I have to
iPhone simulator is running on my Mac but it's not showing the simulator. Two
Cocos2d-iphone uses the -hd extension for Retina images (and other assets). The cocos2d Retina
iPHone: We use MonoTouch, but Obj-C answers are ok. My singleton domain object takes
iPhone doesn't allow background processes to run, but is possible to get a notification
the iphone app I am writing shows white screen when first launched, but become
iPhone Simulator is version 4.0 (211.1) I know, this is a weird question for
iPhone code When I use this code it always show error password but I

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.