title: Cropping Core Image issues
body: <p>I'm using OpenGL to draw image to screen. Due to zoom ability my image sometimes gets translated through z-axis. And user, for example, has image with size 3200x2000, he zooms it out because it doesn't fits the screen. And after zooming out he wants to crop part of image. I register selection rectangle. Then use bottom left corner coordinates and distance between top right corner and bottom left corner. Coordinates are used like that:</p>
  
  <pre><code>//I get one coordinate from mouse down, and then last point from moueDragged events. 
  float firstx = mouseDownFirst.x * (zoomSlider.floatValue * (-10));
  float firsty = mouseDownFirst.y * (zoomSlider.floatValue * (-10));
  float lastx = mouseDragLast.x * (zoomSlider.floatValue * (-10));
  float lasty = mouseDragLast.y * (zoomSlider.floatValue * (-10));
  
  //Then I draw selection rectangle to screen.
  glBegin(GL_QUADS);
  glVertex2f(firstx, firsty);
  glVertex2f(firstx, lasty);
  glVertex2f(lastx, lasty);
  glVertex2f(lastx, firsty);
  glEnd();
  glFlush();
  
  //and do crop. Because image is drawn to framebuffer, I will read frame buffer info and make image from it. Coordinates are being translated back to normal
  firstx = firstx / (zoomSlider.floatValue * (-10));
  firsty = firsty / (zoomSlider.floatValue * (-10))
  lastx = lastx / (zoomSlider.floatValue * (-10));
  lasty = lasty / (zoomSlider.floatValue * (-10));
  
  
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
  glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, [tempRep bitmapData]);
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
  
  CIImage *firstImage = [[CIImage alloc] initWithBitmapImageRep:tempRep];
  
  //cropping image to rect and getting result image
  float distanceWidth = lastx - firstx;
  float distanceHeight = lasty - firsty;
  
  CIImage* secondImage = [firstImage imageByCroppingToRect:CGRectMake(firstx, firsty, distanceWidth, distanceHeight)];
  
  CIFilter* transform = [CIFilter filterWithName:@"CIAffineTransform"];
  NSAffineTransform* affineTransform = [NSAffineTransform transform];
  [affineTransform translateXBy:-firstx yBy:-firsty];
  [transform setValue:affineTransform forKey:@"inputTransform"];
  [transform setValue:secondImage forKey:@"inputImage"];
  CIImage* lastImage = [transform valueForKey:@"outputImage"];
  </code></pre>
  
  <p>But it returns bad image. Not what I selected. For example:</p>
  
  <p>Selection
  <img src="https://i.stack.imgur.com/aNgUt.png" alt="enter image description here"></p>
  
  <p>Cropped image<br>
  <img src="https://i.stack.imgur.com/6HAp2.png" alt="enter image description here"></p>