Each of my layers is actually a layer hierarchy.

The problem I'm seeing is that if the image context's size is larger than the 
layer being drawn, the resulting image is smaller than it should be, even for a 
single layer hierarchy.

For example, let's say my layer is 100 px wide, but the image context I create 
is 200 px wide. I render the image, then use that image to create a 
UIImageView. The pixels in the resulting view are not 100 px wide, but rather 
50 px (I'm guessing at the exact width, but it appears to be about that).

Drawing the second view, hopefully, is as easy as translating the CTM. It was 
NOT enough to set the view's frames.

-- 
Rick

On Aug 15, 2011, at 15:46 , Kyle Sluder wrote:

> On Mon, Aug 15, 2011 at 2:47 PM, Rick Mann <rm...@latencyzero.com> wrote:
>> Hi. I have two UIView hierarchies, visually side-by side, but at different 
>> parts of an overall view hierarchy. I'd like  to create a single UIImage of 
>> the two, using -renderInContext: and 
>> UIGraphicsGetImageFromCurrentImageContext(). I was able to make one work 
>> alone just fine. But when I make my graphics context (using 
>> UIGraphicsBeginImageContext()) large enough to encompass both, and set each 
>> UIView's frame so that they are side-by-side, the resulting image shows just 
>> the left-cell's content, squished horizontally.
> 
> Yes, but you need to set up the CTM to draw the layers in the right
> place. To be clear, you're asking the views'  layers to
> -renderInContext:, not the views themselves.
> 
> We use -renderInContext: to draw entire layer trees into one big
> context. You obviously aren't doing the same thing, but the principle
> is identical. You might want to look into our CALayer extension method
> for doing so: 
> https://github.com/omnigroup/OmniGroup/blob/master/Frameworks/OmniQuartz/CALayer-OQExtensions.m#L497
> 
> --Kyle Sluder

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to