Lately, I find myself sharing PNG images of graphics more and more. And the method I have been using to produce better quality images is to make PostScript output in IDL and convert that to PNG using ImageMagick. But it’s a major pain to have to do everything in 8-bit color. No longer! Set the DECOMPOSED keyword to DEVICE (and make sure COLOR is set too) and normal 24-bit colors work in the PostScript direct graphics device just like in the X and WIN devices.

For example, the following produces the PostScript file to create the plot above:

IDL> orig_device = !
IDL> set_plot, 'ps'
IDL> device, decomposed=1, /color
IDL> device, filename='', xsize=3, ysize=2, /inches
IDL> x = findgen(360) * !dtor
IDL> y = sin(x)
IDL> plot, x, y, /nodata, xstyle=9, ystyle=8
IDL> oplot, x, y, color='ff0000'x, thick=2
IDL> device, /close_file
IDL> set_plot, orig_device

Then I run through ImageMagick to get the PNG file displayed.

While the documentation says that the GET_DECOMPOSED keyword to DEVICE should return whether the PostScript device is in indexed or decomposed color, it does not. In fact, it does not recognize the GET_DECOMPOSED keyword. The only way to tell right now is the output from help, /device.

UPDATE: I changed the color of the plot from red to blue because red is a bad color to test whether we’re in indexed or decomposed color as noted by David in the comments.