• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[iPhone] UIImage drawInRect not scaling image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iPhone] UIImage drawInRect not scaling image


  • Subject: [iPhone] UIImage drawInRect not scaling image
  • From: "Stuart A. Malone" <email@hidden>
  • Date: Mon, 10 Mar 2008 08:23:21 -0400

(Please correct me if I'm on the wrong list. Cocoa-dev seems to be the list suggested at the end of the iPhone developer videos, and I can't find any other.)

I've begun working with the iPhone SDK, and quickly ran into what looks like a bug in UIImage drawInRect: and drawInRect:blendMode:alpha: in the iPhone simulator. But before filing a bug report, I wanted to check with others to make sure that I'm not suffering from some misunderstanding of what these functions are supposed to do.

I'm trying to draw an image obtained from the UIPickerImageController so that it fits within a particular portion of my custom UIView. I find that using either of the drawInRect: routines, the image is drawn with the correct bottom-left corner, but the image is not scaled to fit the height and width of the rectangle. I've worked around the problem using the lower-level CGContext routines as follows:

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextTranslate(context, 0, rect.origin.y + rect.origin.y + rect.size.height);
CGContextScale(context, 1, -1);
CGContextSetBlendMode(context, blendMode);
CGContextDrawImage(context, rect, image.CGImage);
CGContextRestoreGState(context);


This results in the image being scaled to fit exactly in the rectangle I specified. Am I correct that this is also how the UIImage drawInRect: routines are supposed to work?


Best wishes,

--Stuart A. Malone
  Llamagraphics, Inc.
  Makers of Life Balance personal coaching software
  http://www.llamagraphics.com/


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: [iPhone] UIImage drawInRect not scaling image
      • From: Jamie Phelps <email@hidden>
  • Prev by Date: No track index in iTunes SB?
  • Next by Date: picture proportions
  • Previous by thread: Re: No track index in iTunes SB?
  • Next by thread: Re: [iPhone] UIImage drawInRect not scaling image
  • Index(es):
    • Date
    • Thread