Re: screen dump crash with out sleep
Re: screen dump crash with out sleep
- Subject: Re: screen dump crash with out sleep
- From: Dorian Johnson <email@hidden>
- Date: Fri, 22 Jun 2007 23:49:41 -0500
Carbon isn't deprecated. There's no reason you shouldn't Carbon in
Cocoa apps when necessary. The cocoa-purity attitude is destructive
and will only hinder you.
Just a hunch: try doing a [window display] instead of sleeping. If
that alone doesn't work, try setting the window to setOneShot:NO as
well as displaying it first.
- Dorian
On Jun 21, 2007, at 3:49 PM, email@hidden wrote:
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:
40dorianjohnson.com
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