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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:20:51+00:00 2026-05-20T13:20:51+00:00

I am working on a pixelate application for iPhone. Because the pictures taken with

  • 0

I am working on a pixelate application for iPhone. Because the pictures taken with the iPhone 4 camera are too big and therefore the application is working really slow when updating the pixelated picture, I am trying to create tiles of the picture first and just update the tiles not the hole picture.

When building the tiles, it works for camera roll picture taken in landscape mode (2592 x 1936 pxl) and with low resolution pictures, but not with picture taken in portrait mode (1936 x 2592 pxl).

The code for cutting the tiles from the original image looks like this:

for (i = 0; i < NrOfTilesPerHeight; i++) {
  for (j = 0; j < NrOfTilesPerWidth; j++) {
    CGRect imageRect = CGRectMake(j*TILE_WIDTH, i*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT);
    CGImageRef image = CGImageCreateWithImageInRect(aux.CGImage, imageRect);
    UIImage *img = [UIImage imageWithCGImage:image];
    UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
  }
}

The problem is that the image created with these tiles it is rotated to a 90 degree angle anticlockwise.

Thank you a lot,
Andrei

  • 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-20T13:20:51+00:00Added an answer on May 20, 2026 at 1:20 pm

    It is because the imageOrientation isn’t taken into account.

    There is a similar question (Resizing UIimages pulled from the Camera also ROTATES the UIimage?) and I’ve modified the code a bit to work with cropping image.

    Here you are:

    static inline double radians (double degrees) {return degrees * M_PI/180;}
    
    +(UIImage*)cropImage:(UIImage*)originalImage toRect:(CGRect)rect{
    
        CGImageRef imageRef = CGImageCreateWithImageInRect([originalImage CGImage], rect);
    
        CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
        CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef);
        CGContextRef bitmap = CGBitmapContextCreate(NULL, rect.size.width, rect.size.height, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo);
    
        if (originalImage.imageOrientation == UIImageOrientationLeft) {
            CGContextRotateCTM (bitmap, radians(90));
            CGContextTranslateCTM (bitmap, 0, -rect.size.height);
    
        } else if (originalImage.imageOrientation == UIImageOrientationRight) {
            CGContextRotateCTM (bitmap, radians(-90));
            CGContextTranslateCTM (bitmap, -rect.size.width, 0);
    
        } else if (originalImage.imageOrientation == UIImageOrientationUp) {
            // NOTHING
        } else if (originalImage.imageOrientation == UIImageOrientationDown) {
            CGContextTranslateCTM (bitmap, rect.size.width, rect.size.height);
            CGContextRotateCTM (bitmap, radians(-180.));
        }
    
        CGContextDrawImage(bitmap, CGRectMake(0, 0, rect.size.width, rect.size.height), imageRef);
        CGImageRef ref = CGBitmapContextCreateImage(bitmap);
    
        UIImage *resultImage=[UIImage imageWithCGImage:ref];
        CGImageRelease(imageRef);
        CGContextRelease(bitmap);
        CGImageRelease(ref);
    
        return resultImage;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on an app that allows the user to draw pixelated images
Working with an .asp application that connects and displays data cleanly. Problem occurs with
Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB.
Working on a legacy application at the moment and we are replacing the data
In the app I'm working on, a button opens the camera. When you take
Working on a small game using an HTML5 canvas, and javascript. And it's working
Working with an undisclosed API, I found a function that can set the number
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
Working with H2 I get this error when I try to write a row
Working on the problems on Project Euler to try to learn Clojure. I'm on

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.