graphicsContextWithBitmapImageRep: with flipped view
graphicsContextWithBitmapImageRep: with flipped view
- Subject: graphicsContextWithBitmapImageRep: with flipped view
- From: Mathieu Martin <email@hidden>
- Date: Wed, 23 Nov 2005 14:23:41 -0500
Hello,
I'm trying to capture a view to create a CIImage I want to use with
some CoreGraphics filters.
This method works fine when I try to capture the all view or if the
view is not clipped by a scrollview. But as soon as I try to capture
the visible portion of a view that is clipped I don't get every thing
I ask for. The top or the bottom is empty but what is drawn is at the
right position. My view is flipped so I tried to convert [self
visibleRect] but then the position of the elements of my view are
wrong and I still get those horizontal lines at the top or the button
of the image, depending of where I scroll the view.
this is the code I use to capture the visible content of my view
based Apple sample code reducer app (cf AnimatedTabView.m - (void)
selectTabViewItem:(NSTabViewItem *)tabViewItem) and Mac OS X
Developer Release Note for tiger (cf: NSView drawing redirection).
- (CIImage *) visibleRectCIImage{
NSBitmapImageRep *imageBitMapRep = [self
bitmapImageRepForCachingDisplayInRect:[self visibleRect]];
NSGraphicsContext *bitmapGraphicsContext = [NSGraphicsContext
graphicsContextWithBitmapImageRep:imageBitMapRep];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:bitmapGraphicsContext];
[[NSColor clearColor] set];
NSRectFill(NSMakeRect(0, 0, [imageBitMapRep size].width,
[imageBitMapRep size].height));
[NSGraphicsContext restoreGraphicsState];
[self cacheDisplayInRect:[self visibleRect]
toBitmapImageRep:imageBitMapRep];
CIImage *currentLayerImage = [[[CIImage alloc]
initWithBitmapImageRep:imageBitMapRep] retain];
// for test only
[[imageBitMapRep TIFFRepresentation] writeToFile:[@"~/
testImage.tiff" stringByExpandingTildeInPath] atomically:YES];
return currentLayerImage;
}
I someone have an idea about this, that would be nice to let me know.
regards
mat.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden