NSCGImageSnapshotRep,如何获取bitmapData [英] NSCGImageSnapshotRep, how get bitmapData

查看:561
本文介绍了NSCGImageSnapshotRep,如何获取bitmapData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个只有一个表示形式的图片,这是一个 NSCGImageSnapshotRep



c $ c> [NSCGImageSnapshotRep bitmapData] ,但是类没有 bitmapData 的选择器。



有人知道这个班吗?如何获取 bitmapData






这个来自Webkit的NSImage [DOMElement renderedImage]



创建DOMElement目标C的位图



正确的用法是 [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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆