PicHandle 到 CGImageRef
该项目是一个具有核心图形支持的通用 C++ 插件。我无法成功将 PicHandle 转换为 CGImageRef。从 CFDataRef 保存图像会导致图像损坏。
if(pic)
{
Handle thePictureFileHandle;
thePictureFileHandle = NewHandleClear(512);
HandAndHand((Handle)pic,thePictureFileHandle);
dataProvider= CGDataProviderCreateWithData(NULL,(void*)*thePictureFileHandle,GetHandleSize( (Handle)thePictureFileHandle ),NULL );
CFDataRef data = CGDataProviderCopyData(dataProvider);
CGImageSourceRef source = CGImageSourceCreateWithDataProvider(dataProvider, NULL);
if ( source )
{
cgImageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL);
}
CGDataProviderRelease(dataProvider);
CFRelease( source );
CFRelease( data );
}
This project is a generic C++ plugin with core-graphics support. I am unable to convert a PicHandle to CGImageRef successfully. Saving off image from CFDataRef results in a bad image.
if(pic)
{
Handle thePictureFileHandle;
thePictureFileHandle = NewHandleClear(512);
HandAndHand((Handle)pic,thePictureFileHandle);
dataProvider= CGDataProviderCreateWithData(NULL,(void*)*thePictureFileHandle,GetHandleSize( (Handle)thePictureFileHandle ),NULL );
CFDataRef data = CGDataProviderCopyData(dataProvider);
CGImageSourceRef source = CGImageSourceCreateWithDataProvider(dataProvider, NULL);
if ( source )
{
cgImageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL);
}
CGDataProviderRelease(dataProvider);
CFRelease( source );
CFRelease( data );
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
CGImageSourceCreateImageAtIndex
中,您需要传递字典说明您的数据是PICT
。请参阅此处的 Apple 文档。你需要做类似的事情
In
CGImageSourceCreateImageAtIndex
, you need to pass the dictionary saying that your data is aPICT
.See the Apple documentation here. You need to do something like