Another IKImageView Question: copying a region

Posted by Brian Postow on Stack Overflow See other posts from Stack Overflow or by Brian Postow
Published on 2010-03-22T21:49:18Z Indexed on 2010/03/24 22:13 UTC
Read the original article Hit count: 348

I'm trying to use the select and copy feature of the IKImageView. If all you want to do is have an app with an image, select a portion and copy it to the clipboard, it's easy. You set the copy menu pick to the first responder's copy:(id) method and magically everything works.

However, if you want something more complicated, like you want to copy as part of some other operation, I can't seem to find the method to do this.

IKImageView doesn't seem to have a copy method, it doesn't seem to have a method that will even tell you the selected rectangle!

I have gone through Hillegass' book, so I understand how the clipboard works, just not how to get the portion of the image out of the view...

Now, I'm starting to think that I made a mistake in basing my project on IKImageView, but it's what Preview is built on (or so I've read), so I figured it had to be stable... and anyway, now it's too late, I'm too deep in this to start over...

So, other than not using IKImageView, any suggestions on how to copy the select region to the clipboard manually?

EDIT actually, I have found the copy(id) method, but when I call it, I get

 <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 16 bits/pixel; 1-component color space; kCGImageAlphaPremultipliedLast; 2624 bytes/row.

Which obviously doesn't happen when I do a normal copy through the first-responder... I understand the error message, but I'm not sure where it's getting those parameters from...

Is there any way to trace through this and see how this is happening? A debugger won't help for obvious reasons, as well as the fact that I'm doing this in Mozilla, so a debugger isn't an option anyway...

EDIT 2 It occurs to me that the copy:(id) method I found may be copying the VIEW rather than copying a chunk of the image to the clipboard, which is what I need.

The reason I thought it was the clipboard copy is that in another project, where I'm copying from an IKImageView to the clipboard straight from the edit menu, it just sends a copy:(id) to the firstResponder, but I'm not actually sure what the firstresponder does with it...

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about ikimageview