Getting 256 Colors in PostScript Output
QUESTION: My images look like they only have about a dozen colors. I thought I had a 256 color (or grayscale) PostScript printer. What's going on?
ANSWER: By default, the IDL PostScript driver is set up to deliver only 16 colors or shades of gray for image output. If you don't know this, your PostScript images will look "washed out" or "blocky".
The default setting for the PostScript driver is to save 4 bits of information for each image pixel. This is enough for only 16 colors or shades of gray. If you want 256 colors, you must set the BITS_PER_PIXEL keyword to 8, in addition to setting the COLOR keyword, like this:
Set_Plot, 'PS' Device, Bits_per_Pixel=8, Color=1
Since PostScript settings are “sticky,” it is not a bad idea to put these commands in your IDL start-up file, so your PostScript device is always configured correctly from the beginning.
thisDevice = !D.Name Set_Plot, 'PS' Device, Bits_per_Pixel=8, Color=1, Isolatin1=1 Set_Plot, thisDevice
Note that a tool like PSConfig, which I always use to configure the PostScript device, assumes 8 bits per pixel and color or grayscale output by default. (It also assumes Isolatin encoding, so you don't have font problems later.)
keywords = PSConfig(Cancel=cancelled) IF ~cancelled THEN BEGIN thisDevice = !D.Name Set_Plot, 'PS' Device, _EXTRA=keywords Plot, findgen(11) ; Or whatever your graphics needs are. Device, /Close_File Set_Plot, thisDevice ENDIF
|PSConfig is an easy way to allow the user to completely configure the PostScript device. It sets BITS_PER_PIXEL=8 and COLOR=1 by default.|
In addition, Coyote Graphics routines make it possible to use 24-bit colors (16.7 million simultaneous colors) in the PostScript device. Details can be found in Coyote's Guide to Traditional IDL Graphics.
Version of IDL used to prepare this article: IDL 7.0.1.