title: CIBlendWithMask sizes
body: <p>I'm trying to create an image with mask using filter. I have 3 images, all of them with same size:</p>
  
  <pre><code>(lldb) p img1.size
  (CGSize) $33 = (width=369, height=370)
  (lldb) p img2.size
  (CGSize) $34 = (width=369, height=370)
  (lldb) p img3.size
  (CGSize) $36 = (width=369, height=370)
  </code></pre>
  
  <p>Then i'm allocating CIImages for them:</p>
  
  <pre><code>CIImage *inputImage = [[CIImage alloc] initWithCGImage:img1.CGImage options:nil];
  CIImage *bgImage = [[CIImage alloc] initWithCGImage:img2.CGImage options:nil];
  CIImage *maskImage = [[CIImage alloc] initWithCGImage:img3.CGImage options:nil];
  </code></pre>
  
  <p>And create CIFilter with given CIImages:</p>
  
  <pre><code>CIFilter *filter = [CIFilter filterWithName:@"CIBlendWithMask"];
  [filter setValue:inputImage forKey:@"inputImage"];
  [filter setValue:bgImage forKey:@"inputBackgroundImage"];
  [filter setValue:maskImage forKey:@"inputMaskImage"];
  CIImage *outputImage = [filter outputImage];
  </code></pre>
  
  <p>However, when i'm trying to get outputImage like this:</p>
  
  <pre><code>CGImageRef outputRef = [_context createCGImage:outputImage fromRect:[outputImage extent]];
  UIImage *result = [UIImage imageWithCGImage:outputRef];
  CGImageRelease(outputRef);
  </code></pre>
  
  <p>Result image has strange size:</p>
  
  <pre><code>(lldb) p outputImage.size
  (CGSize) $37 = (width=738, height=740)
  </code></pre>
  
  <p>When i take a look into the image, it is located on bottom left (CGContext inverted Y-ax) and has a size of these 3 initial images (width=369, height=370), rest of image size is just empty (alpha = 0.0f). Mask is applied on full area, what is ok.</p>
  
  <p>It may be important, that in the beginning i do something like this:</p>
  
  <pre><code>UIGraphicsBeginImageContextWithOptions(img2.size, NO, 0.0);
  UIImage *img1 = UIGraphicsGetImageFromCurrentImageContext(); // transparent image
  [anotherImg drawInRect:CGRectMake(0,0,img2.size.width,img2.size.height)];
  UIImage *img3 = UIGraphicsGetImageFromCurrentImageContext(); // mask image with proper size
  UIGraphicsEndImageContext();
  </code></pre>
  
  <p>When I use in filter anotherImage instead of img3 as mask, output image is with correct size (img2 is drawn on full area instead of 1/3) however the mask is smaller (1/3 of size while it should be full area). So opposite situation.</p>
  
  <p>What am I doing wrong? How to fix it, so i have both image and mask drawn on full area?
  As a note - i have to use filter, <a href="https://stackoverflow.com/questions/18273724/cifilter-uiimage-alpha-mask?rq=1">cant draw with mask in cgcontext</a>.</p>