2012-08-03 4 views
-1

백그라운드에서 UIView가 포 그라운드에서 & UIImageView 인 간단한 드로잉 응용 프로그램을 만들고 있습니다. UIView에서 드로잉 작업을하고 UIImageView에서 이미지를 설정했습니다. UIImageView의 투명도 효과를 추가하여 이미지 뒤에 선을 표시하고 싶습니다. 알파를 줄임으로써이 작업을 수행 할 수 있다는 것을 알고 있지만 이미지의 알파를 변경하고 싶지는 않습니다.iOS 드로잉 앱 문제

나는 CGContextSetBlendMode으로하고 싶지만 어떻게해야할지 모르겠다. 이 문제를 해결하도록 도와주십시오.

감사합니다. 당신은 당신이 늘 그들에 걸쳐 혼합 모드를 사용할 수 두 개의 서로 다른 상황에 그리기 때문에

이미지http://www.freeimagehosting.net/q3237

UIImage *img = [UIImage imageNamed:@"Image.png"];  

UIGraphicsBeginImageContext(self.view.frame.size); 
CGContextRef ctx = UIGraphicsGetCurrentContext(); 
CGContextSetBlendMode(ctx, kCGBlendModeMultiply); 
[img drawInRect:CGRectMake(0, 0, 768, 1004) blendMode:kCGBlendModeDarken alpha:1]; [imageView.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)]; 
CGContextSetBlendMode(ctx, kCGBlendModeDarken); 
imageView.image = UIGraphicsGetImageFromCurrentImageContext(); 
+0

을 – DivineDesert

+0

내가 할 수있는 건 알지만 문제는 내가 이것을 할 때마다 & (CGPath) 줄에 blendmode를 설정할 때마다 서로 겹칩니다. http : //i.stack.imgur.com/UroVd.png – Smith

+1

@Smith 질문을 편집하여 의견에 입력 한 코드를 포함시키고 해당 의견을 삭제하십시오. 읽을 시간이 매우 어렵습니다. – Stunner

답변

1

이미지 뷰를 유지할 필요가 없습니다이 .. 처럼 않습니다. 이를 위해 당신은 당신의 도면 뷰에 다른 물건을 그린 후 이미지를 그릴 필요 .. 당신은 내가 당신이 필요로 변경 무엇을 제안 할 수 있도록 u를 통해 UR 코드를 게시 할 수있는 UIView에 이미지를 그릴 필요가 들어

- (void)drawRect:(CGRect)rect { 

     // do ur drawing stuff first    

      CGContextRef context = UIGraphicsGetCurrentContext(); 
      CGContextTranslateCTM(context, 0, self.bounds.size.height); 
      CGContextScaleCTM(context, 1.0, -1.0); 
      CGContextDrawImage(context, self.bounds, self.image.CGImage); 
      CGContextSetBlendMode(context, kCGBlendModeSaturation); 
      CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0); 
      CGContextFillRect(context, rect); 
    } 
+0

어쨌든 내 UIImage를 CGBitmapContext로 변환 할 수 있습니까? 그래서 내 이미지에 blendmode를 적용 할 수 있습니까? – Smith