Re: Drawing over a QTCaptureView
Re: Drawing over a QTCaptureView
- Subject: Re: Drawing over a QTCaptureView
- From: Ben Lachman <email@hidden>
- Date: Thu, 05 Jun 2008 01:40:35 -0400
Gordon:
I think view:willDisplayImage: is the way to do it, although it is a
bit kludgey in my opinion since you have to convert to something
drawable and then back. Attached is the code I worked up. It should
work on 10.4 and 10.5. All it does is draw a centered rounded square
over the QTCaptureView's preview image.
- (CIImage *)view:(QTCaptureView *)view willDisplayImage:(CIImage *)
image {
NSImage *capturedImage = [[NSImage alloc] init];
[capturedImage addRepresentation:[NSCIImageRep
imageRepWithCIImage:image]];
[capturedImage lockFocus];
NSSize imageSize = [capturedImage size];
NSRect overlayRect = NSZeroRect;
overlayRect.size = imageSize;
overlayRect.size.width = NSHeight(overlayRect);
overlayRect.origin.x = (imageSize.width - NSWidth(overlayRect))/2;
overlayRect = NSInsetRect(overlayRect, 6, 6);
CGFloat oldLineWidth = [NSBezierPath defaultLineWidth];
[NSBezierPath setDefaultLineWidth:4];
[[[NSColor grayColor] colorWithAlphaComponent:.75] set];
[NSBezierPath strokeRoundRectInRect:overlayRect radius:10];
[NSBezierPath setDefaultLineWidth:oldLineWidth];
[capturedImage unlockFocus];
// create CIImage from data
CIImage * ciImage = [[CIImage alloc] initWithData:[capturedImage
TIFFRepresentation]];
[capturedImage release];
return [ciImage autorelease];
}
Hope this helps,
->Ben
--
Ben Lachman
Acacia Tree Software
http://acaciatreesoftware.com
email: email@hidden
twitter: @benlachman
mobile: 740.590.0009
On Jun 4, 2008, at 8:40 PM, Gordon Apple wrote:
And then what can you do with it? Although I've been able to
rotate the
image with a transform, I still haven't figured out how to clip the
image to
a Bezier. You can't focus and draw into a CIImage like you can a
NSImage.
If it were the latter, I could just use NSBezier setClip. After
drowning in
filter documentation, I gave up for now.
Apparently, from what I can tell, the whole purpose of CIImage
is to get
it done in the GPU instead of the CPU. Unfortunately, I haven't
found any
useful documentation on how to do simple functions with these things.
Posting on the QT forum got no response.
Ben,
check out the documentation for QTCaptureView delegate:
- (CIImage *)view:(QTCaptureView *)view willDisplayImage :(CIImage
*)image
this will give you access to the display pipeline.
later,
douglas
On Jun 4, 2008, at 4:01 PM, Ben Lachman wrote:
I'm wonder what's the easiest way to draw a simple box over a
QTCaptureView. Overriding drawRect doesn't work and putting another
view over the QTCV doesn't work. Any Thoughts?
Thanks,
->Ben
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden