Hi,
I just ran into some odd behaviour with TVing an array to the PostScript
device. I get an additional column in color 255 on the right side of the
image. No problem occurs if the number of columns is even or the
X-Window evice is used.
I haven't found this on dejanews, so I thought it might be interesting.
The problem can be seen in the following piece of code:
-- cut here ---
; some test data
image = [$
[ 255B, 130B, 144B],$
[ 102B, 0B, 124B],$
[ 9B, 35B, 31B],$
[ 41B, 66B, 0B] ]
; set the plot position and ranges
position = [0.1, 0.1, 0.9, 0.9]
xsize = (position[2] - position[0]) * !D.X_VSize
ysize = (position[3] - position[1]) * !D.Y_VSize
xstart = position[0] * !D.X_VSize
ystart = position[1] * !D.Y_VSize
; use an inverted color table (otherwise the extra column would be
white...)
Loadct, 0
Tvlct, r, g, b, /GET
Tvlct, Reverse(r), Reverse(g), Reverse(b)
IF !D.NAME EQ 'PS' THEN DEVICE, Filename='test.ps', /Landscape, /Color
; plot the image, odd number of pixels in x
IF !D.NAME EQ 'PS' THEN $
TV, image, xstart, ystart, XSize=xsize, YSize=ysize $
ELSE $
TV, Congrid(image, xsize, ysize), xstart, ystart
Plot, [1], /nodata, /noerase, position=position, color=255,
title='wrong', $
xstyle=1, xrange=[0, (size(image))[1]], $
ystyle=1, yrange=[0, (size(image))[2]]
IF !D.NAME EQ 'PS' THEN Erase ELSE Window, 1
; skip the last column -> even number of pixels in x
image = image[0:(size(image))[1]-2, *]
IF !D.NAME EQ 'PS' THEN $
TV, image, xstart, ystart, XSize=xsize, YSize=ysize $
ELSE $
TV, Congrid(image, xsize, ysize), xstart, ystart
Plot, [1], /nodata, /noerase, position=position, color=255,
title='right', $
xstyle=1, xrange=[0, (size(image))[1]], $
ystyle=1, yrange=[0, (size(image))[2]]
IF !D.NAME EQ 'PS' THEN DEVICE, /Close
END
-- cut here ---
|