MATLAB Programming/Psychtoolbox/Screen Commands/PutImage

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Usage:

Screen(windowPtr,'PutImage',imageArray,[rect],[copyMode])

Copy imageArray to a window, slowly. imageArray may be double or uint8. Its values, which should be non-negative integers, are copied to the window, by CopyBits or CopyBitsQuickly. imageArray can be an MxN array (for any window) or MxNx3 array (only if the window pixelSize is 16 or 32 bits). In the latter case the three r g b components are combined, as appropriate for the window pixelSize, to form a single value that is copied to the window. In 16-bit mode r, g, and b each contribute 5 bits. In 32-bit mode r, g, and b each contribute 8 bits.

rect is in window coordinates. The whole image is copied to rect, scaling if necessary. The rect default is the imageArray's rect, centered in the window. The orientation of the array in the window is identical to that of MATLAB's numerical array displays in the Command Window. The first pixel is in the upper left, and the rows are horizontal. Unless you specify a Quickly copyMode, PutImage inherits the behavior of CopyBits, scaling the image into the rect.

The copyMode argument is a string variable that is passed to the VideoToolbox CopyWindows routine. copyMode can be 'srcCopy' (default) or 'bltFast'.

The copying is done in two stages. First, slowly, from the image array into a temporary offscreen window, and then, quickly, from there to the window designated by windowPtr.