2010-01-22 25 views
0

我在PDF上绘制图像时遇到问题。我将缩放,旋转,移动等应用于图像并在PDF上绘制该图像。但绘图不正确输出。当我旋转图像时,它只是缩放而不旋转。在PDF上的图像绘制无法绘制图像的转换和输出错误

在这里,我将更详细地解释: 我在UIWebView上放置一个图像,使图像完全在PDF上产生假效果。然后,在制作PDF时,我在UIWebView上的PDF上绘制图像。

但是,当我去准备带有已应用大量转换的修改图像的PDF时,图像缩放不会旋转。

这里,img_copyright是一个继承UIImageView的自定义类。

CGFloat orgY = (newY-whiteSpace)+img_copyright.frame.size.height; 
CGFloat modY = pageRect.size.height-orgY; 

CGFloat orgX = img_copyright.frame.origin.x-PDF_PAGE_PADDING_WIDTH; 
CGFloat modX = orgX; 

//We're getting X,Y of the image here to decide where to put the image on PDF. 


CGRect drawRect = CGRectMake (modX, modY, img_copyright.frame.size.width, img_copyright.frame.size.height); 

//Preparing the rectangle in which image is to be drawn. 


CGContextDrawImage(pdfContext, drawRect, [img_copyright.image CGImage]); 
    [img_copyright release]; 

// Actually drawing the image. 

但是,当我看到PDF图像没有正确绘制到它。

你会有什么建议,是基于X,Y的图像绘制问题吗? 如果我们不依赖X,Y,我们如何决定将图像放在PDF上? 在旋转,缩放的PDF上绘制图像的确切方法是什么?

当我将图像插入到UIWebView的滚动条上时,图像。 http://www.freeimagehosting.net/ “>

当我绘制图像到PDF形象。
http://www.freeimagehosting.net/”>

+0

你好everyonce ,请对这个问题发表评论。我也想要可能性。我知道图像可以在pdf上旋转绘制,但我没有固定的位置,位置是动态的,我从图像本身得到x/y坐标。所以,如果我与图像中心合作会不会好? – 2010-01-25 05:43:53

回答

1
CGFloat angleInRadians =-1*Angle* (M_PI/180.0); 
CGAffineTransform transform=CGAffineTransformIdentity; 

transform = CGAffineTransformMakeRotation(angleInRadians); 
//transform = CGAffineTransformMakeScale(1, -1); 
//transform =CGAffineTransformMakeTranslation(0,80); 

CGRect rotatedRect = CGRectApplyAffineTransform(CGRectMake(0,0,Image.size.width,Image.size.height), transform); 

UIGraphicsBeginImageContext(rotatedRect.size); 
//[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0,rotatedRect.size.height); 
CGContextScaleCTM(UIGraphicsGetCurrentContext(),1, -1); 

//CGContextTranslateCTM(UIGraphicsGetCurrentContext(), +(rotatedRect.size.width/2),+(rotatedRect.size.height/2)); 

CGContextTranslateCTM(UIGraphicsGetCurrentContext(), (rotatedRect.origin.x)*-1,(rotatedRect.origin.y)*-1); 
CGContextRotateCTM(UIGraphicsGetCurrentContext(), angleInRadians); 
//CGContextTranslateCTM(UIGraphicsGetCurrentContext(), -(rotatedRect.size.width/2),-(rotatedRect.size.height/2)); 

CGImageRef temp = [Image CGImage]; 

CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, Image.size.width,Image.size.height), temp); 

//CGContextRotateCTM(UIGraphicsGetCurrentContext(), -angleInRadians); 
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

return viewImage; 
+0

谢谢老兄...很高兴有你的回应...应用程序现在有进步..! – 2010-02-06 12:57:52