I’m new to the CGAffine world. Anyone know why my transformation doesn’t work/take ?
-
I have a valid PDFContext created with UIGraphicsBeginPDFContextToData and the following current matrix:
CGAffineTransform curMat = CGContextGetCTM(context); NSLog (@"current context matrix: %f %f %f %f %f %f", curMat.a, curMat.b, curMat.c, curMat.d, curMat.tx, curMat.ty); -
NSLog values:
current matrix: 1.000000 0.000000 -0.000000 -1.000000 0.000000 792.000000
-
I create the transformation matrix with:
CGAffineTransform xform = CGAffineTransformMake(a, b, c, d, tx, ty); -
NSLog values:
transform matrix: 0.062500 0.000000 0.000000 0.062500 0.000000 0.000000
-
I get the my rect from:
CGRect pdfBounds = UIGraphicsGetPDFContextBounds(); -
NSLog values:
pdfBounds: 0.000000 0.000000 612.000000 792.000000
-
I apply the transformation matrix with:
CGRectApplyAffineTransform (pdfBounds, xform); -
Then I re-check the current matrix value with:
CGAffineTransform curMat2 = CGContextGetCTM(context); NSLog (@"current context matrix after transformation: %f %f %f %f %f %f", curMat2.a, curMat2.b, curMat2.c, curMat2.d, curMat2.tx, curMat2.ty) -
and the NSLog values are the same as at the beginning.
current context matrix after transformation: 1.000000 0.000000 -0.000000 -1.000000 0.000000 792.000000
What am I missing ? Why is the transformation not happening/taking ? Thank you.
You are ignoring the result of the applied transformation and you are also not applying any transformation to the context.
Step 7 should be: