NSCGImageSnapshotRep, how get bitmapData

自闭症网瘾萝莉.ら 提交于 2020-01-23 06:22:10

问题


I got a image with only one representation, and that was a NSCGImageSnapshotRep.

I tried [NSCGImageSnapshotRep bitmapData] but, the class has no selector for bitmapData.

Someone knows this class? How can I get the bitmapData?


I'm getting this NSImage from Webkit [DOMElement renderedImage].

Create bitmap of a DOMElement Objective C

The correct use is [NSBitmapImageRep representationUsingType:id properties:id], this means doesn't work in the case.

I didn't think about compatibily, I'll be glad to find a solution 10.5+ or 10.6+.


回答1:


NSImage *img = [DOMElement renderedImage] ;
[img lockFocus] ;
NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect(0.0, 0.0, [img size].width, [img size].height)] ;
[img unlockFocus] ;

...

// don't forget when you are done with the rep:
[bitmapRep release] ;


来源:https://stackoverflow.com/questions/4438802/nscgimagesnapshotrep-how-get-bitmapdata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!