NSCGImageSnapshotRep,如何获取bitmapData [英] NSCGImageSnapshotRep, how get bitmapData
问题描述
我有一个只有一个表示形式的图片,这是一个 NSCGImageSnapshotRep
。
c $ c> [NSCGImageSnapshotRep bitmapData] ,但是类没有 bitmapData
的选择器。
有人知道这个班吗?如何获取 bitmapData
?
这个来自Webkit的NSImage [DOMElement renderedImage]
。
正确的用法是 [NSBitmapImageRep representationUsingType:id properties:id]
,这意味着在这种情况下不起作用。
< t考虑compatibily,我很高兴找到一个解决方案 10.5 + 或 10.6 + 。
NSImage * img = [DOMElement renderedImage];
[img lockFocus];
NSBitmapImageRep * bitmapRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect(0.0,0.0,[img size] .width,[img size] .height)];
[img unlockFocus];
...
//不要忘记当你完成rep:
[bitmapRep release];
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+.
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] ;
这篇关于NSCGImageSnapshotRep,如何获取bitmapData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!