當我們編寫時它的工作很好: UIImage * img = [UIImage imageNamed:@「ImageName」];但是,當嘗試從nsdata,如:UIImage * img = [UIImage imageWithData:imageData]; 現在當我們試圖從img中獲取cgimage時,它會給badAccess。 如果有人知道確切的寫法,那麼請給我解決方案。 我使用CGImageRef sourceImageRef = [img CGImage];在UIView的Draw Rect方法中。從UIImage中獲取CGImage的錯誤
0
A
回答
0
您應該使用的alloc初始化,如:
UIImage* myImage = [[UIImage alloc] initWithCGImage:myCGImage];
1
試試這個轉換UIImage
到CGImage
-
CGImage imageRef = imageObject.CGImage
相關問題
- 1. CGImage/UIImage的泄漏
- 2. - [UIImage CGImage]返回零
- 3. 處理UIImage和CGImage
- 4. 的UIImage的CGImage返回NULL
- 5. 從PDF文件中獲取CGImage
- 6. CGImage到UIImage不起作用
- 7. 從UIImageView獲取UIImage
- 8. 從CGImage獲取RGB像素數據
- 9. 獲取CIImage從UIImage的(SWIFT)
- 10. iphone 4S - 的UIImage CGImage圖像尺寸
- 11. UIImage/CGImage改變我的像素顏色
- 12. 從UIImage獲取位圖數據時出現意外錯誤?
- 13. 無法從MPMediaItemPropertyArtWork獲取UIImage
- 14. 如何從AVCaptureVideoPreviewLayer獲取UIImage?
- 15. 從UIImage獲取CurrentBackgroundImage路徑
- 16. 如何從UIImage獲取URL?
- 17. 如何從UIImage獲取CGContextRef?
- 18. 從功能獲取UIImage
- 19. 如何從UIImagePickerControllerReferenceURL獲取UIImage
- 20. 從UIImage獲取底層NSData *
- 21. 如何從CGContextRef獲取UIImage?
- 22. 如何從UIImage獲取URL
- 23. iOS - 從CGBitmapContext獲取UIImage
- 24. 無法從URL獲取UIImage
- 25. 從UIImageVIew獲取UIImage origin.x
- 26. CGImage/UIImage傳遞導致EXE-BAD-ACCESS
- 27. 如何將UIImage或CGImage附加到AVAssetWriter?
- 28. 來自NSURL的CGImage工作,但不是從UIImage
- 29. 如何從我的XCode資產目錄中獲取CGImage
- 30. 是否從一個UIImage訪問CGImage徵收翻轉位圖?
提供一些更多的代碼 –
http://stackoverflow.com/questions/17576054/cgimage -to-uiimage-doesnt-work – codercat
http://stackoverflow.com/questions/12756295/uiimage-from-cgimageref – codercat