フラッド フィル メソッドが不正なアクセス エラーでクラッシュしています。エラーが見つかりません。何かアイデアをお願いします。
アプリを起動すると、小さなオブジェクトを問題なくペイントできますが、ペイント バケツのようなフラッド フィルを使用して大きなオブジェクトをペイントで塗りつぶそうとすると、BAD ACCESS エラーでクラッシュします。
私は初心者で、多くのことを試しましたが、再帰の数は増えましたが、それでもクラッシュします。このアプリでARCを使用しています。
-(void)paintingBucket:(int)point point2:(int)point2 width:(int)width colorAtPoint:(UIColor *)color {
int offset = 0;
int x = point;
int y = point2;
if (point<1025 && point2<705) {
offset = 4*((width*round(y))+round(x));
int alpha = data[offset];
int red = data[offset + 1];
int green = data[offset + 2];
int blue = data[offset + 3];
color1 = [UIColor colorWithRed:(green/255.0f) green:(red/255.0f) blue:(alpha/255.0f) alpha:(blue/255.0f)];
if ([color1 isEqual: color] ) {
color3 = self.currentColor ;
CGFloat r,g,b,a;
[color3 getRed:&r green:&g blue: &b alpha: &a];
int reda = (int)(255.0 * r);
int greena = (int)(255.0 * g);
int bluea = (int)(255.0 * b);
int alphaa = (int)(255.0 * a);
// NSLog(@" red: %u green: %u blue: %u alpha: %u", reda, greena, bluea, alphaa);
data[offset + 3] = alphaa;
data[offset + 2] = reda;
data[offset + 1] = greena;
data[offset] = bluea;
[self paintingBucket:x+1 point2:y width:width colorAtPoint:color];
[self paintingBucket:x point2:y+1 width:width colorAtPoint:color];
[self paintingBucket:x-1 point2:y width:width colorAtPoint:color];
[self paintingBucket:x point2:y-1 width:width colorAtPoint:color];
}
}
}
編集: クラッシュしたときに取得する情報は、「0x995d7d5f: calll 0x995d7d64 ; szone_malloc_should_clear + 14」だけです
メモリの問題があることは理解していますが、それを特定できず、解決できません。私が言ったように、目標cの初心者なので、どんな助けも素晴らしいでしょう。