English 中文(简体)
参考 明显业绩过于缓慢
原标题:drawInRect performance too slow

我的所作所为是把2个图像合并成单一形象。

这里是法典。

UIGraphicsBeginImageContext(CGSizeMake(1024, 768));

[image1 drawInRect:CGRectMake(0, 0, 512, 768)];
[image2 drawInRect:CGRectMake(512, 0, 512, 768)];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

但是, InRect似乎过于缓慢。

是否有更快的办法来合并图像?

最佳回答

备选案文 页: 1


Option 1

如果你知道目的地大小(perhaps Self.frame.size?),你就可以在目的地大小(and上从两个来源图像(flatten)中形成一个形象,避免污染。 从而:

  1. Reduce the memory you need
  2. Reduce the number of images you must draw
  3. Avoid interpolation (High CPU if you want it to look good)
  4. Look better - the composite can use High Quality interpolation.

当然,只有在混合物的频率低于必须提取时,才有意义。

Option 2

即使你想要两个图像,而且你知道其大小不会改变,也只是将其与必须从中抽取的规模相去甚远(如果你正在扩大这些图像的话,监测你的记忆使用)。

Option 3

如果这不是一种选择,则你可以改变的状态,并降低污染质量。 如果你重新用于类似的工厂转变,你可能对低质量或无污染感到满意。

问题回答

你们可以做的一件事情不是执行,而是完全执行,而是有两幅带有你两种形象的外科医生,然后把一片人放在前面。 这一点并不肯定会更快,但我认为可能如此(因为加澳新集团随后可以轻松地处理万国邮联。)





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签