Cropped rectangle doesn't work as expected - objective-c

I have an NSView to draw a rectangle to crop image, and one NSImageView to be webcam (camera preview window).
I want to put the NSView on the NSImageView.
When I take a picture, it can produce a cropped image automatically.
The problem is that when I don't start the camera preview window, the crop rectangle can drag and resize normally, but when I start the camera preview window, the crop rectangle out of control.
I've implemented drag and resize function by mouse event.
How can I resolve this problem?
8/19 update: My code and program video.
code: gist.github.com/536831
video: http://www.youtube.com/watch?v=DLjuBGHh3f8
Thanks!!

Hmm, maybe one of the views has User Interaction Enabled set to NO (default value for UIImageView, for example)?

Related

Draw rectangle on image in Avalonia

Problem : I have an image with zoom and pan attached. I need to draw rectangles over it.
What I have done : I created a Canvas as an overlay over the image and made rectangle the children of canvas. Everything works well with zoom and pan etc but if the user resizes my the window then the added rectangles starts moving from their places because the rectangle position is set with respect to top and left of canvas.
I am thinking of drawing rectangles over the image and overriding the render. Any suggestions how can I achieve it easily?

Cocoa - screen capture and draw (retina)

I`m try get screen capture from retina display, and draw this image on window.
I can get capture
CGDirectDisplayID displayId = CGMainDisplayID()
CGImage imageRef = CGDisplayCreateImage(displayId)
image have a size 2560x1600
Now, i need draw this image on window. But if, i resize window to full screen, window return size 1280x800. If i wont draw image on window, i need scale image to 1280x800. Image lost quality, this is not good.
Please help me, how i can get screen capture from retina display and draw his on window, without lost quality ?
You can find out actual window size in pixels by passing its frame to this method:
-[NSWindow convertRectToBacking:]
Just draw the image to the view's bounds. In theory this is a scaling operation, but in reality it's not because the view's bounds are in points, not pixels. The backing buffer for the view is at the same DPI as the original screen capture, so it will be a straight blit. No detail will be lost.

Crop Image in specific shape Cocos2d

I have an UIImageView* shape which is in fixed position. Behind that view I have another view which I can move, scale and rotate with gestures. I would like when I finish with customising the view behind the "shape" to press a button crop and crop the image. You can see video here of what exactly I am trying to do.
Video: https://www.youtube.com/watch?v=4CTNGire1gQ&feature=youtu.be
You can mask one image with another image to get custom shape image. See tutorial to get some idea about masking
http://www.raywenderlich.com/4421/how-to-mask-a-sprite-with-cocos2d-1-0

I want to make some area of image transparent. Image is set as background of an UIButton

I have an image with irregular shape. I set it as a background image of an UIButton.
Now, I use OBShapedButton library to enable touch only where image is non-transparent. But, for some reason if I click on transparent image area, when view appears in screen, then it responds to click, whereas it should not.
I made some area of image transparent using adobe cs4 photoshop. Now, I want to try making it transparent in xcode only. May be it helps.
To have an idea of image shape I am attaching a sample image.
Does anyone know how to do that?

UIButton: Image stretched when clicking

I am using EGOImageButton to handle the asynchronous download of image. I've set the contentMode to Aspect Fit using uibutton.imageView.contentMode rather than uibutton.contentMode because it doesn't work on iPhone so I used the former. The image inside the button stretched to the size of the button when I clicked on it. What is the solution to prevent it from stretched?
Pleaase help