Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
I am wondering there are any tricks to managing the color table in an 8-bit Z buffer. I read "Graphics without Graphics Windows" on the coyote website as well as comments in cgSetColorState. Both indicate why there are problems. Say I want to create several graphics, each with independent color choices. The last graphic seems to determine how all others will appear. An example is below. I can set the pixel depth to 24 and things work fine. The Pixel depth is 8-bits by default, though, which was making things not working out the way I wanted. Made me curious... Below is an example. ============= How It Should Look ============= ;Create window and positions window, /Free, XSize=400, YSize=600 pos = cgLayout([1,3]) ;Create data data1 = cgDemoData(1) data2 = cgDemoData(13) data3 = cgDemoData(21) ;Draw plots and images cgPlot, data1, AXISCOLOR='Grey', POSITION=pos[*,0], TITLE='Time Series', XTITLE='Time (s)', YTITLE='Data', COLOR='Purple' cgImage, data2, /NOERASE, /AXES, AXKEY={AXISCOLOR: 'Purple'}, POSITION=pos[*,1], TITLE='Hurricane Gilbert', XTITLE='Lat', YTITLE='Lon', CTINDEX=15 cgImage, data3, /NOERASE, /AXES, AXKEY={AXISCOLOR: 'Blue'}, POSITION=pos[*,2], TITLE='Red Blood Cells', XTITLE='Height (um)', YTITLE='Length (um)', CTINDEX=3 =========== Z Buffer Example =========== ;Set up the Z Buffer xsize = 400 ysize = 600 thisDevice = !D.Name Set_Plot, 'Z' Device, Get_Pixel_Depth=thisDepth Device, Set_Pixel_Depth=8, Set_Resolution=[xsize, ysize], Z_Buffer=0 cgErase, 'White' ;Create data data1 = cgDemoData(1) data2 = cgDemoData(13) data3 = cgDemoData(21) ;Create window and positions window, /Free, XSize=xsize, YSize=ysize pos = cgLayout([1,3]) ;Draw plots and images cgPlot, data1, AXISCOLOR='Grey', POSITION=pos[*,0], TITLE='Time Series', XTITLE='Time (s)', YTITLE='Data', COLOR='Purple' cgImage, data2, /NOERASE, /AXES, AXKEY={AXISCOLOR: 'Purple'}, POSITION=pos[*,1], TITLE='Hurricane Gilbert', XTITLE='Lat', YTITLE='Lon', CTINDEX=15 cgImage, data3, /NOERASE, /AXES, AXKEY={AXISCOLOR: 'Blue'}, POSITION=pos[*,2], TITLE='Red Blood Cells', XTITLE='Height (um)', YTITLE='Length (um)', CTINDEX=3 ;Save the buffer img = cgSnapShot() wDelete, !D.Window ;Reset the device Device, Set_Pixel_Depth=thisDepth, Z_Buffer=1 Set_Plot, thisDevice ;Display the contents of the buffer window, /Free, XSize=xsize, YSize=ysize cgImage, img
Matthew Argall writes: > I am wondering there are any tricks to managing the color table in an 8-bit Z buffer. I read "Graphics without Graphics Windows" on the coyote website as well as comments in cgSetColorState. Both indicate why there are problems. > > Say I want to create several graphics, each with independent color choices. The last graphic seems to determine how all others will appear. An example is below. I can set the pixel depth to 24 and things work fine. The Pixel depth is 8-bits by default, though, which was making things not working out the way I wanted. Made me curious... The reason this works on your display is that the Coyote Graphics commands *always* work in a 24-bit color space if they can. The "if they can" part was also true for the Z-graphics buffer in the early days of Coyote Graphics. But, the Coyote Graphics system was way ahead of its time, and the author didn't realize there were still hundreds of programmers writing programs the same way they wrote them in the 1970s, so he had to give up his quixotic dreams of "one ring to control them all." The problem (explained more fully in the comments in cgSetColorState) is that although it is not a problem to put the Z-buffer into a 24-bit state, it is a lot more difficult to set it back to an 8-bit state. Basically, because of the way the Z-buffer works, setting the state back to 8-bit means you erase whatever is in the Z-buffer. This is problematic, because to do anything useful you have to take a picture of the buffer before you erase it, etc. A chicken and egg thing... If this is what you care about, though, just set the Z-buffer up as a 24-bit device and leave it there. The Coyote Graphics routines will work perfectly. :-) Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thue. ("Perhaps thou speakest truth.")