.\
cgtransparentimage.pro
top cgTransparentImage
Graphics
result = cgTransparentImage( [image] [, /BREWER] [, CTINDEX=integer] [, MISSING_VALUE=various] [, FILENAME=string] [, /NOGUI] [, PALETTE=byte] [, PNGFILE=PNGFILE] [, /REVERSE] [, TRANSPARENT=integer] [, WSET=long])
Creates a semi-transparent image for display. Optionally, a "missing" color or color index (for 2D images) can be set to a completely transparent value. The transparent image can be saved as a transparent PNG file.
Parameters
- image in optional type=byte
A 2D image or a 24-bit image with or without an alpha channel. If an alpha channel is present, it will be modified by the program.
Keywords
- BREWER in optional type=boolean default=0
This keyword is used only if the
CTIndex
keyword is used to select a color table number. Setting this keyword allows Brewer color tables to be used.- CTINDEX in optional type=integer
The index number of a color table. The
Brewer
andReverse
keywords will be checked to see how to load the color table into thePalette
keyword. This keyword will take precidence over any colors that are loaded with thePalette
keyword.- MISSING_VALUE in optional type=various
The "color" of a pixel that will be treated as a "missing" color or value. Any pixels in the image with this color value will be set completely transparent. If
Color
is a string, use cgColor to obtain a color triple. IfColor
is a non-strint scalar, this value is taken to be the missing color index in a 2D image. Otherwise, this is assumed to be a color triple that indicates the "missing" color or value in the output image. The alpha channel in the output image is set to 0 for the "missing" color, which makes this value completely transparent.- FILENAME in optional type=string
The name of an image file that can be read with READ_IMAGE. Used to select the input image if the
image
parameter is not used.- NOGUI in optional type=boolean default=0
Set this keyword if you do not wish to have the user confirm the name of the output PNG file selected with the
PNGFile
keyword.- PALETTE in optional type=byte
Set this keyword to a 3x256 or 256x3 byte array containing the RGB color vectors to be loaded before the transparent image is created. Such vectors can be obtained, for example, from cgLoadCT with the RGB_TABLE keyword:
The default is to use whatever colors are loaded in the current hardware color table. A palette applies only to 2D input images.IDL> cgLoadCT, 4, /BREWER, /REVERSE, RGB_TABLE=palette IDL> tImage = cgTransparentImage( cgDemoData(7), PALETTE=palette)
- PNGFILE in optional
If this keyword is set, the output image is written as a transparent PNG file in 4xMxN format. Optionally, this keyword can be set to the name of the output PNG file. The user will have the option of confirming the name of the output file, unless the
NoGUI
keyword is set.- REVERSE in optional type=boolean default=0
Set this keyword to reverse the color table vectors selected with the
CTIndex
keyword.- TRANSPARENT in optional type=integer default=50
The percentage of transparency desired in the output image. A number between 0 and 100.
- WSET in optional type=long
If image parameter is not present, make the window indicated with this keyword the current graphics window for obtaining an image parameter. If not passed, and no image is present, then the current graphics window is used to create the image.
Examples
To create and display a transparent image:
cgDisplay, WID=0
cgImage, cgDemoData(5), CTIndex=0, /Interp
timage = cgTransparentImage(MISSING_VALUE='black', TRANSPARENT=50)
cgDisplay, WID=1
cgImage, cgDemoData(7), CTIndex=22
cgImage, timage
Author information
- Author:
FANNING SOFTWARE CONSULTING:
David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: david@idlcoyote.com Coyote's Guide to IDL Programming: http://www.idlcoyote.com
- Copyright:
Copyright (c) 2012, Fanning Software Consulting, Inc.
- History:
Change History:
Written, 23 October 2012 to replace Make_Transparent_Image, which was retired. DWF.
File attributes
Modification date: | Fri Mar 27 11:07:37 2015 |
Lines: | 292 |
Docformat: | rst rst |