Swi*_*ily 4 iphone objective-c cgcontext ios ios5
我有一个应用程序,它使用CGContextDrawImage函数组合两个图像.这是我的问题.只有一个图像出现而另一个没有出现在iphone 5的ios模拟器中,而在iphone 3的iphone模拟器上,显示这些图像没有问题,我没有任何问题.顺便说一下,这里是Xcode给我的错误列表.
//错误
:CGContextRotateCTM:无效的上下文0x0.这是一个严重的错误.该应用程序或其使用的库正在使用无效的上下文,从而导致系统稳定性和可靠性的整体降低.此通知是礼貌的:请解决此问题.它将成为即将到来的更新中的致命错误.
:CGContextDrawImage:无效的上下文0x0.这是一个严重的错误.该应用程序或其使用的库正在使用无效的上下文,从而导致系统稳定性和可靠性的整体降低.此通知是礼貌的:请解决此问题.它将成为即将到来的更新中的致命错误.
:CGBitmapContextCreateImage:无效的上下文0x0.这是一个严重的错误.该应用程序或其使用的库正在使用无效的上下文,从而导致系统稳定性和可靠性的整体降低.此通知是礼貌的:请解决此问题.它将成为即将到来的更新中的致命错误.
有人可以帮我吗?提前致谢.
这是我的示例代码:
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGRect xFirstFrame = m_pUserImgView.frame;
int nWidth = xFirstFrame.size.width;
int nHeight = xFirstFrame.size.height;
CGFloat rScaleX;
CGPoint xOrgCenter;
UIImage* pJustinImage = m_pJustinImgView.image;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
xOrgCenter = CGPointMake(384, 512);
}
else
if ([self appDelegate].isiPhone5 == YES)
{
xOrgCenter = CGPointMake(160, 284);
}
else
{
xOrgCenter = CGPointMake(160, 240);
}
CGContextRef buf_context = CGBitmapContextCreate(nil, nWidth, nHeight, 8, nWidth * 4, colorSpace, kCGImageAlphaPremultipliedLast);
CGColorSpaceRelease(colorSpace);
CGRect rect = CGRectMake(0,0, nWidth, nHeight);
CGRect xSecRect = m_pJustinImgView.bounds;
UIGraphicsPushContext(buf_context);
CGContextClearRect(buf_context, rect);
CGContextDrawImage(buf_context, rect, m_pUserImgView.image.CGImage);
//Transform Context
CGAffineTransform pTransform = m_pJustinImgView.transform;
CGAffineTransform xRealTrans = CGAffineTransformMake(pTransform.a, pTransform.b, pTransform.c, pTransform.d, pTransform.tx, -pTransform.ty);
CGPoint xOrgPoint = CGPointMake(xOrgCenter.x + pTransform.tx, xOrgCenter.y - pTransform.ty);
CGFloat rDegree = [self CalcRotateAngle:xRealTrans];
CGContextTranslateCTM(buf_context, xOrgPoint.x, xOrgPoint.y);
CGContextRotateCTM(buf_context, -rDegree);
rScaleX = sqrtf(pTransform.a * pTransform.a + pTransform.c * pTransform.c);
CGContextDrawImage(buf_context, CGRectMake(- xSecRect.size.width * rScaleX/2, - xSecRect.size.height * rScaleX/2, xSecRect.size.width * rScaleX , xSecRect.size.height * rScaleX), pJustinImage.CGImage);
UIGraphicsPopContext();
CGImageRef image = CGBitmapContextCreateImage(buf_context);
CGContextRelease(buf_context);
UIImage* pCombImage = [[UIImage alloc] initWithCGImage:image];
CGImageRelease(image);
return pCombImage;
Run Code Online (Sandbox Code Playgroud)
}
//加载图像的代码
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGRect xFirstFrame = m_pBackImageView.frame;
int nWidth = xFirstFrame.size.width;
int nHeight = xFirstFrame.size.height;
CGFloat rScaleX;
CGPoint xOrgCenter;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
xOrgCenter = CGPointMake(384, 512);
}
else
{
if ([self appDelegate].isiPhone5 == YES)
{
xOrgCenter = CGPointMake(160, 284);
}
else
{
xOrgCenter = CGPointMake(160, 240);
}
}
CGContextRef buf_context = CGBitmapContextCreate(nil, nWidth, nHeight, 8, nWidth * 4, colorSpace, kCGImageAlphaPremultipliedLast);
CGColorSpaceRelease(colorSpace);
CGRect rect = CGRectMake(0,0, nWidth, nHeight);
CGRect xSecRect = m_pUserImgView.bounds;
UIGraphicsPushContext(buf_context);
CGContextClearRect(buf_context, rect);
CGContextDrawImage(buf_context, rect, m_pBackImageView.image.CGImage);
//Transform Context
CGAffineTransform pTransform = m_pUserImgView.transform;
CGAffineTransform xRealTrans = CGAffineTransformMake(pTransform.a, pTransform.b, pTransform.c, pTransform.d, pTransform.tx, -pTransform.ty);
CGPoint xOrgPoint = CGPointMake(xOrgCenter.x + pTransform.tx, xOrgCenter.y - pTransform.ty);
CGFloat rDegree = [self CalcRotateAngle:xRealTrans];
CGContextTranslateCTM(buf_context, xOrgPoint.x, xOrgPoint.y);
CGContextRotateCTM(buf_context, -rDegree);
rScaleX = sqrtf(pTransform.a * pTransform.a + pTransform.c * pTransform.c);
CGContextDrawImage(buf_context, CGRectMake(- xSecRect.size.width * rScaleX/2, - xSecRect.size.height * rScaleX/2, xSecRect.size.width * rScaleX , xSecRect.size.height * rScaleX), m_pUserImgView.m_pViewImage.CGImage);
UIGraphicsPopContext();
CGImageRef image = CGBitmapContextCreateImage(buf_context);
CGContextRelease(buf_context);
UIImage* pCombImage = [[UIImage alloc] initWithCGImage:image];
CGImageRelease(image);
return pCombImage;
Run Code Online (Sandbox Code Playgroud)
Jur*_*tas 10
试试这个:在xcode中为CGPostError添加符号断点.(添加符号断点,并添加到符号字段类型CGPostError)
发生错误时,调试器将停止代码执行,您可以检查方法调用堆栈并检查参数.寻找0大小的表面.一些参数的大小为0.
| 归档时间: |
|
| 查看次数: |
5000 次 |
| 最近记录: |