iPhone中的图表捕获图像比iPad更大

时间:2014-09-01 11:21:10

标签: ios iphone uiimage core-plot

我们使用以下代码将png图像从iPhone / iPad保存到媒体库,但尺寸比iPad大。

我们正在使用coreplot来生成图表。使用cofGraph中的imageofLayer保存图像。

CPTGraph *gp = self.hostView.hostedGraph;
self.hostView.bounds = CGRectMake(0,0,640,480);
gp.bounds = CGRectMake(0, 0, 640, 480);
graph.title = txtChartTitle.text;

UIImage *newImage=[gp imageOfLayer ];
NSData *imgData = UIImagePNGRepresentation(newImage);
UIImage* im2 = [UIImage imageWithData:imgData];
CGRect cropRect = CGRectMake(0.0 ,0.0 , 640.0, 480.0);
UIGraphicsBeginImageContextWithOptions(cropRect.size, YES, 0.0);

[im2 drawInRect:cropRect];
UIGraphicsEndImageContext();

[UIPasteboard generalPasteboard].image = im2;

if([self diskSpace]>[imgData length])
{
UIImageWriteToSavedPhotosAlbum(im2, self,@selector(image:didFinishSavingWithError:contextInfo:),nil);

}
else
{

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@""
                                                    message:@"The chart cannot be saved due to insufficient storage space available."
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];
    alert=NULL;
}

0 个答案:

没有答案