Smart window Isis software documentation

Smart window

This library defines an object called a smart window which is designed to keep track of what parts of an image have been modified so that when it is displayed or cleared, only the necessary portions of the image are transferred. The object does not actually open any windows.


Creating a smart-window object

(set smartwin (new-smart-window)) # create a new smart window object Once the object is created, there are 4 commands you can send to it: modify, clear, save, and display. These commands are invoked by calling the returned object like this: (smartwin 'm' [xmin ymin xmax ymax]) # mark rectangle as modified (smartwin 'm' [xmin ymin] [xdim ydim]) # mark rectangle as modified (smartwin 'c' fgimage bgimage) # clear foreground (smartwin 's' fgimage bgimage) # save (update background) (smartwin 'd' fgimage) # display, returns [ subimage disploc ] The modify command marks the specified rectangle in the image as modified. The clear command will clear fgimage so that it is identical to bgimage, transferring only the necessary parts to do so. The save command updates the background (the opposite of clear), transferring the necessary parts of fgimage to bgimage. The display command returns a list of 2 items, a sub-image of fgimage, and the location at which that image should be displayed. If nothing should be displayed, Null is returned instead (be sure to check for it).

Here is an example program:

# Smart window example script (set win (xwin-create Null "Smart Window test" [100 100] [620 480])) (set smartwin (new-smart-window)) (set foreground (new-standard-image 3 [640 480])) (set background (new-standard-image 3 [640 480])) # fill foreground to red (image-fill-constant 255 (isolate-channel 0 foreground)) (image-fill-constant 0 (isolate-channel 1 foreground)) (image-fill-constant 0 (isolate-channel 2 foreground)) (smartwin 'm' [0 0 639 479]) # mark entire image as modified (smartwin 's' foreground background) # save foreground to background (set dispinfo (smartwin 'd' foreground)) # get area to display (print "Displaying a " ((dispinfo 0) buf-dims) "size piece at " (dispinfo 1) newline) (xwin-display-image win (dispinfo 0) (dispinfo 1)) # display it (print "Press return to continue" newline) (read-string) # make a rectangle (image-fill-constant 255 (isolate-sub-image [100 100] [100 200] (isolate-channel 1 foreground))) (smartwin 'm' [100 100 199 299]) # mark that area as modified (set dispinfo (smartwin 'd' foreground)) # get area to display (print "Displaying a " ((dispinfo 0) buf-dims) "size piece at " (dispinfo 1) newline) (xwin-display-image win (dispinfo 0) (dispinfo 1)) # display it (print "Press return to continue" newline) (read-string) (smartwin 'c' foreground background) # clears the foreground # make a different rectangle (image-fill-constant 255 (isolate-sub-image [150 200] [200 100] (isolate-channel 2 foreground))) (smartwin 'm' [150 200 349 299]) # mark that area as modified (set dispinfo (smartwin 'd' foreground)) # get area to display (print "Displaying a " ((dispinfo 0) buf-dims) "size piece at " (dispinfo 1) newline) (xwin-display-image win (dispinfo 0) (dispinfo 1)) # display it (print "Press return to continue" newline) (read-string) (smartwin 'c' foreground background) (set dispinfo (smartwin 'd' foreground)) # get area to display (print "Displaying a " ((dispinfo 0) buf-dims) "size piece at " (dispinfo 1) newline) (xwin-display-image win (dispinfo 0) (dispinfo 1)) # display it (print "Press return to continue" newline) (read-string)


Requirements:
Scripts: (load "smart-window.isis")