• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Screen capture?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Screen capture?


  • Subject: Screen capture?
  • From: Andreas Monitzer <email@hidden>
  • Date: Fri, 3 May 2002 18:09:43 +0200

What's the easiest way to get a screen capture? My current code is the following:

- (void)AM_drawSnapshotOfDisplay:(CGDirectDisplayID)display inRect:(NSRect)rect {
NSBitmapImageRep *rep=[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
pixelsWide:CGDisplayPixelsWide(display)
pixelsHigh:CGDisplayPixelsHigh(display)
bitsPerSample:CGDisplayBitsPerSample(display)
samplesPerPixel:CGDisplaySamplesPerPixel(display)
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bytesPerRow:CGDisplayBytesPerRow(display)
bitsPerPixel:CGDisplayBitsPerPixel(display)];

bcopy(CGDisplayBaseAddress(display),[rep bitmapData],CGDisplayBytesPerRow(display)*CGDisplayPixelsHigh(display));

[rep drawInRect:rect];
[rep release];
}

Sidenote: Using CGDisplayBaseAddress() directly for the data plane doesn't work, the app crashes in
#0 0x7722ce98 in decode_data
#1 0x77187180 in CGSImageDataLock
#2 0x73d44994 in ripc_RenderImage
#3 0x77190cb0 in CGContextDrawImageObj
#4 0x7718e318 in CGDrawBitmapOpDecode
#5 0x70bf0eb0 in _NSDrawBitmapWithFlip
#6 0x70beaf38 in -[NSBitmapImageRep draw]
#7 0x70d2a038 in -[NSImageRep drawInRect:]
#8 0x70c931d8 in -[NSBitmapImageRep drawInRect:]

However, something doesn't work here, as the captured screen shot is only red/yellow. (I know that it doesn't work at all for 15 bit displays, but I don't care about them yet.) My guess is that I didn't calculate the display memory size properly, but I can't think of any other way than <bytes per row>*<rows per screen>.

Maybe somebody has already done it and likes to share some code and/or experience?

thanks
andy
--
DigiTunnel Public Beta released, offering full PPTP-support for Mac OS X!
http://www.gracion.com/vpn/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Screen capture?
      • From: Finlay Dobbie <email@hidden>
  • Prev by Date: Seeing/Viewing/browsing a stacktrace
  • Next by Date: Re: NSTableView scrollbars won't activate
  • Previous by thread: Seeing/Viewing/browsing a stacktrace
  • Next by thread: Re: Screen capture?
  • Index(es):
    • Date
    • Thread