screen dump crash with out sleep
screen dump crash with out sleep
- Subject: screen dump crash with out sleep
- From: email@hidden
- Date: Thu, 21 Jun 2007 22:49:27 +0200
Hi
I am programming a screen dump. Please see my code. If the sleep is
removed, then the application crashes.
The image is in another method directly written to file. So far it
seems to be the sleep that makes it crash or not crash.
Please could somebody explain why?
Please suggestions for better/faster code is much appreciated.
However please not deprecated carbon, or to low level openGL
Thank you very much
NSWindow *window;
NSBitmapImageRep *rep;
NSImage *image;
window = [[NSWindow alloc] initWithContentRect:rect
styleMask:NSTitledWindowMask
backing:NSBackingStoreNonretained defer:NO];
[window setBackgroundColor:[NSColor blueColor]];
[window setLevel:NSScreenSaverWindowLevel + 1];
[window setHasShadow:NO];
[window setAlphaValue:0.0];
[window orderFront:self];
[window setContentView:[[[NSView alloc] initWithFrame:rect]
autorelease]];
sleep(1);
[[window contentView] lockFocus];
NSRect bRect = [[window contentView] bounds];
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:bRect];
[[window contentView] unlockFocus];
[window orderOut:self];
[window close];
image = [[[NSImage alloc] initWithSize:[rep size]] autorelease];
[image addRepresentation:rep];
return image;
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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