이 코드를 사용해보십시오. 전화 터치 이동과 터치가 시작이 방법은 화면에서 발생
-(void) getPixelColorAtLocation:(CGPoint)point {
unsigned char pixel[4] = {0};
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(pixel, 1, 1, 8, 4, colorSpace, kCGImageAlphaPremultipliedLast);
CGContextTranslateCTM(context, -point.x, -point.y);
[self.layer renderInContext:context];
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
if((pixel[0]=255) && (pixel[1] = 0) && (pixel[2] = 0)){
//if pixel are red then this condition become true
}
사용지고 이미지에 대해이 방법
- (UIImage *)drawLineFromPoint:(CGPoint)fromPoint toPoint:(CGPoint)toPoint image:(UIImage *)image
{
}
당신은 다음과 같이 호출 할 수 있습니다
self.image = [self drawLineFromPoint:previousPoint toPoint:point image:self.image];
감사 Keyur을 ,이 코드에서 나는 CGPoint를 전달하지만 어디서 어떻게 색상 비율을 검출하는이 방법으로 UIImage를 설정할 수 있습니까? 다시 한번 감사드립니다. – josh
나는 내 코드 pls 편집하려고합니다 어떤 prb 직면하려고하면 – kb920
고마워요, 버디 이미 UIImage 가지고 있지만 "- (void) getPixelColorAtLocation : (CGPoint) 포인트" 메서드를 사용하여 그냥 CGPoint 전달할 수 있지만 UIImage 위치는 무엇입니까? 이미지에서 픽셀을 얻는 방법은 무엇입니까? – josh