Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGPDFPageGetDrawingTransform refuses to upscale



At 12:32 -0700 31/3/05, Nick Nallick wrote:
On Mar 31, 2005, at 12:17 PM, David Niemeijer wrote:

This was, as sometimes happens, an historical decision that "seemed right at the time." This function was originally used for easy layout in N-up printing. In that case, it seemed better to avoid scaling up a PDF file when it was smaller than the page rect - instead, we kept the size unchanged and centered the PDF in the page rect. Unfortunately, this particular behavior now makes it necessary to jump through some hoops if you want uniform scaling both up and down.

And, probably those hoops are simple for you as you must be using transformations all the time, but I have been puzzling on this now for some time and cannot seem to figure out how to do this correctly. I can scale easily, but then my image also needs to be translated to keep it within my rectangle (if I just scale, it walks out of my rect as I make the rect bigger and bigger). What would be the correct way to do the upscaling taking into account the image's art box and the rect I want to display it in?

A scale is always relative to the current origin. The easiest way to get the scale you expect is to first translate the origin so that it's at the point on your PDF that you expect to remain unchanged by the scale (i.e., generally either the upper-left or lower-left corner). If you scale and then translate it can be more confusing because you're actually translating in the scaled coordinate system.

That makes sense, but the rectangle into which I want to draw, itself has a non-zero origin and then we get the transform that CGPDFPageGetDrawingTransform does. I wish there was some straight forward example on how to achieve proper translation and scaling when going from one rectangle with its coordinates to another rectangle with its own coordinates. For example, the art box of the PDF looks like this:


x 258.215 y 371.517
width 82.9009 height 104.702

and the rectangle I want to draw into looks like this:

x 4.9 y 12.375
width 88.2 height 129.25

What transforms would one use to properly scale and translate to get the PDF art to draw into that rectangle?

I am already using this code to make sure the image does not appear upside down:

CGContextTranslateCTM(inContext, 0, myRect.origin.y + CGRectGetMaxY(myRect));
CGContextScaleCTM(inContext,1.0f,-1.0f);

david.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden
References: 
 >CGPDFPageGetDrawingTransform refuses to upscale (From: David Niemeijer <email@hidden>)
 >Re: CGPDFPageGetDrawingTransform refuses to upscale (From: Derek Clegg <email@hidden>)
 >Re: CGPDFPageGetDrawingTransform refuses to upscale (From: David Niemeijer <email@hidden>)
 >Re: CGPDFPageGetDrawingTransform refuses to upscale (From: Derek Clegg <email@hidden>)
 >Re: CGPDFPageGetDrawingTransform refuses to upscale (From: David Niemeijer <email@hidden>)
 >Re: CGPDFPageGetDrawingTransform refuses to upscale (From: Nick Nallick <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.