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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:32:17+00:00 2026-05-24T19:32:17+00:00

In my app I am using the camera and photo library to get an

  • 0

In my app I am using the camera and photo library to get an UIImage,
this UIImage is then scaled down about 20 times its normal size
I then set a NSData object based off the UIImage.

_regularImage = [self resizeImage:_takenImage width:100 height:100];


-(UIImage *)resizeImage:(UIImage *)anImage width:(int)width height:(int)height
{

    CGImageRef imageRef = [anImage CGImage];

    CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef);

    if (alphaInfo == kCGImageAlphaNone)
        alphaInfo = kCGImageAlphaNoneSkipLast;


    CGContextRef bitmap = CGBitmapContextCreate(NULL, width, height, CGImageGetBitsPerComponent(imageRef), 4 * width, CGImageGetColorSpace(imageRef), alphaInfo);

    CGContextDrawImage(bitmap, CGRectMake(0, 0, width, height), imageRef);

    CGImageRef ref = CGBitmapContextCreateImage(bitmap);
    UIImage *result = [UIImage imageWithCGImage:ref];

    CGContextRelease(bitmap);
    CGImageRelease(ref);

    return result;      
}

NSData *image1Data = UIImageJPEGRepresentation(_regularImage, 1);

I cant seem to figure anything else out that might cause this

Thank you

LittleRy

  • 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-24T19:32:18+00:00Added an answer on May 24, 2026 at 7:32 pm

    The issue here may be that you are creating your bitmap context or UIImage in the wrong way. Try debugging and checking if _regularImage is nil, or if it’s invalid. For scaling an image, I would suggest using a third party library called ANImageBitmapRep. It’s a small set of classes that allows for easy cropping, resizing, rotating, etc of images on the iPhone. Scaling a UIImage can be done like this:

    ANImageBitmapRep * irep = [ANImageBitmapRep imageBitmapRepWithImage:myImage];
    [irep setSize:BMPointMake(myWidth, myHeight)]; // scale the image
    UIImage * theImage = [irep image];
    [irep release];
    NSData * jpeg = UIImageJPEGRepresentation(theImage, 1);
    

    With this sort of code I doubt that UIImageJPEGRepresentation would be the issue. The ANImageBitmapRep class itself handles the CGContextRef stuff internally, making your job very much easier.

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

Sidebar

Related Questions

i am trying to scale down a image i get from photo library on
In my app i am using this code to get Image from Gallery and
In my iPhone app, I am using the iPhone's camera to take a photo
I'm having an issue where I'm using the camera app to take a photo
Im developing a photo app. Here i'm using the images from both photo library
I am using photo library in my app. And after selecting image from photo
I'm using the phone's camera in an Android app to take a photo. I'm
I'm building an app that allows users to snap pictures using the iPhone camera,
In my PhoneGap/jQuery Mobile app, I'm currently using PhoneGaps' Camera API to allow the
Im building an app that takes a photo of the user, its working fine

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.