Re: Drawing over a QTCaptureView
Re: Drawing over a QTCaptureView
- Subject: Re: Drawing over a QTCaptureView
- From: "douglas a. welton" <email@hidden>
- Date: Thu, 5 Jun 2008 08:41:22 -0400
Ben,
one more suggestion - subclass the QTCaptureView and add a CALayer.
Then, do your drawing on the CALayer, as opposed to the the
QTCaptureView's Layer.
I haven't tried this myself, so it may not work... but if it does, it
provides a way for you to do your drawing without having to
transmogrify the CIImage in the delegate method.
later,
douglas
On Jun 5, 2008, at 1:40 AM, Ben Lachman wrote:
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
_______________________________________________
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