0

从 icns 文件构建 NSImage 然后在 ImageAndTextCell 上绘制它时,速度非常慢。但是,如果我从 png、jpg 等创建 NSImage,它的绘制速度非常快。

如何加快速度?从 icns 创建 jpg(等)?保存创建的 NSImages 的缓存?

感谢您的建议,谢谢

更新(来自下面的评论):

似乎这是在加载 icns 文件时减慢执行速度的代码:

NSImage * image = [ [ [ NSImage alloc ] initWithContentsOfFile:
                      filename ] autorelease ];

从以下位置调用:-

( id ) tableView : ( NSTableView * ) aTableView objectValueForTableColumn :
       ( NSTableColumn * ) aTableColumn row : ( NSInteger ) rowIndex

如果我删除它,那么 NSTableView 绘制非常快。当不是icns文件,而是jpg、png等的时候,画图是非常快的。有什么提示吗?

4

1 回答 1

1

解决了!

真正快速使用:

NSImage * image = [ [ NSWorkspace sharedWorkspace ] iconForFile: bundleName ];  

使用速度很慢:

NSImage * image = [ [ [ NSImage alloc ] initWithContentsOfFile: filename ] autorelease ];
于 2012-07-05T08:34:43.313 回答