English 中文(简体)
• 如何比较海洋轨道地图?
原标题:How to do comparisons of bitmaps in iOS?

I have three CGLayers who s data I d like to compare.

void *a = CGBitmapContextGetData(CGLayerGetContext(layerA));
void *b = CGBitmapContextGetData(CGLayerGetContext(layerB));
void *c = CGBitmapContextGetData(CGLayerGetContext(layerC));

我愿获得这样的结果(a OR b)和c),即只有一层的轨道。 A或层B 以及层 最终结果。 这些层系kCGImageAlphaOnly 因此,只有8个轨道“去除”,我只带1.0个字母。 我也没有必要知道重叠之处,我只需要知道,结果是否有 任何<>>> > 字。

今天,我确实失踪了QuickDraw,它迅速开展了大量面向轨道的行动。 关于如何做到这一点的想法?

最佳回答

这里,假定所有三者规模都相同,便可加以缓解:

unsigned char *a = CGBitmapContextGetData(CGLayerGetContext(layerA));
unsigned char *b = CGBitmapContextGetData(CGLayerGetContext(layerB));
CGContextRef context = CGLayerGetContext(layerC);
unsigned char *c = CGBitmapContextGetData(context);
size_t bytesPerRow = CGBitmapContextGetBytesPerRow(context);
size_t height = CGBitmapContextGetHeight(context);
size_t len = bytesPerRow * height;
BOOL bitsFound = NO;
for (int i = 0; i < len; i++) {
    if ((a[i] | b[i]) & c[i]) { bitsFound = YES; break; }
}

自你重新安抚“快速” 凭着,我假定你本可以写到,你知道这很可能是缓慢的。

如果你能够保证标尺大小,你可以使用<代码>int<>/code>而不是char,并在某一时间用四根 by操作。

为了更认真优化,你应检查加速框架。

问题回答

>:CGBlendModes? <代码>kCGBlendModeDestinationOver,作为A和B的<编码>OR,然后由您使用kCGBlendModeDestination 在AND中,该结果与C。





相关问题
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, ...

热门标签