#TUNING by cg
class: Image
changed: #fromScreen:on:grab:
fast image readout on OSX
--- a/Image.st Sun Feb 26 18:18:07 2017 +0100
+++ b/Image.st Sun Feb 26 18:25:16 2017 +0100
@@ -2409,24 +2409,35 @@
|depth vis img tmpFile util|
aDisplay supportsScreenReading ifFalse:[
- "/ workaround: look for a helper utility in support/<os>/screenshot
- "/ currently there is one for osx.
- tmpFile := Filename newTemporary withSuffix:'png'.
- util := Smalltalk packageDirectory asFilename / ('../support/',OperatingSystem getSystemType,'/screenshot').
- util exists ifTrue:[
- OperatingSystem executeCommand:('%1 %2 png %3 %4 %5 %6'
- bindWith:util pathName
- with:tmpFile pathName
- with:aRectangle left
- with:aRectangle top
- with:aRectangle width
- with:aRectangle height).
- ^ [
- Image fromFile:tmpFile.
- ] ensure:[
- tmpFile remove.
- ].
- ].
+ "/ workaround (fast): look if there is an OS-hook for this...
+ OperatingSystem isOSXlike ifTrue:[
+ Error handle:[:ex |
+ img := nil
+ ] do:[
+ img := OperatingSystem getFrameBufferImage:0 in:aRectangle
+ ].
+ ].
+ img isNil ifTrue:[
+ "/ workaround (slow): look for a helper utility in support/<os>/screenshot
+ "/ currently there is one for osx.
+ tmpFile := Filename newTemporary withSuffix:'png'.
+ util := Smalltalk packageDirectory asFilename / ('../support/',OperatingSystem getSystemType,'/screenshot').
+ util exists ifTrue:[
+ OperatingSystem executeCommand:('%1 %2 png %3 %4 %5 %6'
+ bindWith:util pathName
+ with:tmpFile pathName
+ with:aRectangle left
+ with:aRectangle top
+ with:aRectangle width
+ with:aRectangle height).
+ [
+ img := Image fromFile:tmpFile.
+ ] ensure:[
+ tmpFile remove.
+ ].
+ ].
+ ].
+ ^ img
].
depth := aDisplay depth.
@@ -2446,8 +2457,12 @@
img := self newForDepth:depth.
^ img fromScreen:aRectangle on:aDisplay grab:doGrab
- "Modified: / 26-01-1998 / 22:23:08 / cg"
+ "
+ Image fromScreen:(0@0 corner:100@100)
+ "
+
"Modified: / 30-01-2017 / 19:49:01 / stefan"
+ "Modified (comment): / 26-02-2017 / 18:24:41 / cg"
!
fromScreenArea