atom feed13 messages in net.java.dev.rococoa.usersRe: Invalid memory access of location...
FromSent OnAttachments
Sami NopanenNov 1, 2009 1:08 pm 
Paul LoyNov 1, 2009 2:06 pm 
Sami NopanenNov 1, 2009 2:18 pm 
Andrew ThompsonNov 1, 2009 3:25 pm 
Sami NopanenNov 1, 2009 4:12 pm 
Sami NopanenNov 6, 2009 8:43 am 
Paul LoyNov 6, 2009 9:00 am 
Sami NopanenNov 6, 2009 11:44 am 
Duncan McGregorNov 6, 2009 3:12 pm 
Andrew ThompsonNov 6, 2009 8:00 pm 
Sami NopanenNov 6, 2009 8:51 pm 
Andrew ThompsonNov 7, 2009 7:56 am 
Sami NopanenNov 7, 2009 9:07 am 
Subject:Re: Invalid memory access of location...
From:Sami Nopanen (snop@gmail.com)
Date:Nov 6, 2009 8:43:21 am
List:net.java.dev.rococoa.users

I seem to have gotten my screenshot code to become stable. I did this by getting the bitmap data through ApplicationServices framework, instead of through NSBitmapImageRep. Unfortunately, I still don't understand why the old code did not work, so if anyone figures it out, I'd be interested.

The new code is below.

Sami

private Screenshot _getScreenshot(int windowId) { NSRect nullRect = new NSRect(new NSPoint(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY), new NSSize(0, 0));

ID imageRef = QuartzLibrary.INSTANCE.CGWindowListCreateImage(nullRect, QuartzLibrary.kCGWindowListOptionIncludingWindow, windowId, QuartzLibrary.kCGWindowImageBoundsIgnoreFraming);

long width = AppLibrary.INSTANCE.CGImageGetWidth(imageRef); long height = AppLibrary.INSTANCE.CGImageGetHeight(imageRef); long bytesPerRow = AppLibrary.INSTANCE.CGImageGetBytesPerRow(imageRef);

ID nsdataRef = AppLibrary.INSTANCE.CGDataProviderCopyData(AppLibrary.INSTANCE.CGImageGetDataProvider(imageRef)); Foundation.cfRelease(imageRef); NSData nsdata = Rococoa.wrap(nsdataRef, NSData.class, false);

byte[] data = new byte[nsdata.length()]; nsdata.getBytes(data);

return new Screenshot(width, height, bytesPerRow, data); }

I get a popup of the Apple error reporting tool, with some the following dump. Also, attaching the latest version of the source I've been using for trying to isolate this. The dump is from this version.