Code To Create PNG File in the Z-Graphics Buffer
Here is the code I am using to produce a line plot as a PNG file.
; Plot in the Z-graphics buffer
thisDevice = !D.Name
Set_Plot, 'Z'
Device, Set_Resolution=[500,500]
; Load drawing colors.
LoadCT, 0
TVLCT, cgColor('blue', /Triple), 1
TVLCT, cgColor('red', /Triple), 2
TVLCT, cgColor('white', /Triple), !P.Background
TVLCT, cgColor('black', /Triple), !P.Color
; Draw graphics.
Plot, Indgen(10), Color=1
OPlot, Indgen(10)+1, Color=2
; Add a legend.
Al_Legend, ['al_legend','plot','oplot'], LineStyle=[-99,0,0], $
Color=[255,1,2], /Right, /Bottom
; Save the image for output to a PNG file.
image = TVRD()
TVLCT, r, g, b, /Get
Write_PNG, 'test.png', image, r, g, b
Set_Plot, thisDevice
END
![]()
Version of IDL used to prepare this article: IDL 7.1.
![]()
![]()
Copyright ©
1996–2018 Fanning Software Consulting, Inc.
Written: 24 December 2011
