The CopyWindow function method copies the contents of the graphic window into a [3 x M x N] byte array. By default the resulting image has the same dimensions as the window, although the HEIGHT, WIDTH, and RESOLUTION keywords may be used to override this behavior.
Example
The following code sample creates a bar plot and saves the image to a PNG file.
x = FINDGEN(41)/10 - 2
gauss = EXP(-x^2)
p = BARPLOT(x, gauss, TITLE='Gaussian Distribution', $
XTITLE='$\it x$', YTITLE='$\it f(x)$', YRANGE=[0,1.1])
t = TEXT(0.75,0.85,'$\it f(x)=exp(-x^2)$', /DATA, FONT_SIZE=24)
result = p.CopyWindow(BORDER=0, RESOLUTION=48)
Syntax
Result = graphic.CopyWindow( /ANTIALIAS, BORDER=integer, HEIGHT=integer, RESOLUTION=integer, TRANSPARENT=array, WIDTH=integer )
Return Value
The result is a byte array of dimensions [3 x M x N] containing the window contents. If TRANSPARENT is set then the result will have dimensions [4 x M x N].
Arguments
None.
Keywords
ANTIALIAS
By default, if the output resolution is less than 300 dots-per-inch, then IDL will automatically use anti-aliasing to create a smoother-looking output image. Set this keyword to 0 to disable anti-aliasing.
BORDER
By default, the copied graphics includes all of the background regions around the graphics, out to the edge of the window. Set this keyword to an integer defining the width of the border around the graphic. For example, setting BORDER=0 will trim the graphic so that there are no extra border pixels surrounding the graphic.
HEIGHT
Set this keyword to the height of the output array. If this keyword is set, the RESOLUTION keyword is ignored and the width is automatically calculated from the window's aspect ratio.
RESOLUTION
Set this keyword to the output resolution (in dots per inch) to use when copying the window. If this keyword is not supplied, the result array will be the same size as the window dimensions. The maximum output dimensions are 8192 x 8192. If the output dimensions are larger than these values, the resolution will be automatically reduced.
TRANSPARENT
Set this keyword to an RGB value (a three-element vector of the form [R, G, B]) indicating which pixels in the output image should be made transparent. If this keyword is set to 1, the color of the lower left pixel in the image is used as the transparent color. If TRANSPARENT is set then the result will have dimensions [4 x M x N].
WIDTH
Set this keyword to the width of the output array. If this keyword is set, the RESOLUTION keyword is ignored and the height is automatically calculated from the window's aspect ratio.
Version History
8.0 |
Introduced |
8.4 |
Added ANTIALIAS keyword.
|
See Also
Print Method,
Using IDL Graphics