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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:51:05+00:00 2026-05-28T07:51:05+00:00

Given an image G with dimensions w x h , how can I surround

  • 0

Given an image G with dimensions w x h, how can I surround the image with white to produce a new image that is 320 x 480 where G is centered, surrounded by white. The width and height of the incoming image might be larger than 320 or 480, repsecitively, so first I would need to scale it to ensure that it is less than 320×480 (or equal to).

-(UIImage *)whiteVersion:(UIImage *)img {

}

I would use these steps:

Firstly, scale image if needed...then:
1. Create a UIImage of size 320x480
2. Paint the whole thing white
3. Paint G (the image) in the center by using some simple math to find the location

However, I can’t figure out step 1 or 2.

  • 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-28T07:51:05+00:00Added an answer on May 28, 2026 at 7:51 am

    You don’t draw into images. You draw into graphics contexts. There are different kinds of graphics contexts. An image graphics context lets you take a snapshot of its contents as an image.

    - (UIImage *)whiteVersion:(UIImage *)myImage {
        UIGraphicsBeginImageContextWithOptions(CGSizeMake(320, 480), YES, myImage.scale);
        [[UIColor whiteColor] setFill];
        UIRectFill(CGRectInfinite);
        [myImage drawAtPoint:CGPointMake((320 - myImage.size.width) / 2, (480 - myImage.size.height) / 2)];
        UIImage *myPaddedImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return myPaddedImage;
    }
    

    You can learn more about drawing on iOS by perusing the Drawing and Printing Guide for iOS and the Quartz 2D Programming Guide.

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

Sidebar

Related Questions

Given an image: maxWidth = 400; maxHeight = 200; width = photo.Width; height =
Given a path and filename how can I get the Image object: Image image
Given a list of image paths how can I iterate through them and find
Given a list of image paths how can I iterate through them and find
When the image gets saved, the height and width of the image get saved
I need to get the dimensions of the display rectangle that the application can
I need to generate new dimensions for an image to match a ratio of
I'm pretty new to Image Processing and found out that the FFT convolution speeds
Given a URL how do I pull the largest image (in terms of image-dimensions)
I need to upload a given image using Amazon S3 I have this PHP:

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.