1
我有兩個重疊的圖像。如果我刪除上面的圖像的一部分,該特定的部分被擦除並且底層圖像應該出現。但是,如果我把這個特定的部分弄清楚,它應該讓我回到那個圖像的被刪除部分。擦除和刪除圖像
我不需要撤消功能,但只有刪除的部分應該出現。
這裏是我使用擦除上面的圖像的代碼:
在touchesMoved事件:
UIGraphicsBeginImageContext(frontImage.frame.size);
[frontImage.image drawInRect:CGRectMake(0, 0, frontImage.frame.size.width, frontImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone); //kCGImageAlphaPremultipliedLast);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
//this line code for erasing select the part of the image
CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, 10, 10));
//End the code
CGContextStrokePath(UIGraphicsGetCurrentContext());
frontImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
請幫我有關的問題。
謝謝大家提前
修改該部分圖像的alpha值是個好主意,但我們如何修改圖像的選定部分或觸摸部分的alpha值? 知道該怎麼做嗎? 請幫助我。 – milanjansari 2009-09-05 12:04:09
從圖像或圖層獲取位圖,請參閱http://developer.apple.com/mac/library/qa/qa2007/qa1509.html,然後快速通過位圖運行以找到觸摸點。然後播放周圍像素的Alpha值。 – mahboudz 2009-09-23 08:51:41
等一下,可能有更好的方法來做到這一點,就像用合適的混合模式在頂部繪製另一幅圖像,爲您提供所需的alpha。 – mahboudz 2009-09-23 08:52:48